A way to go is giving the form and all inputs an id and use the ajax
function $.post
example :
<form id="form" action="test.php">
<input type="text" name="text" id="text"><br>
<input type="submit" value="send" id="send">
</form>
the javascript code would be
$("send").click(function(){
$.post("test.php",
{test: $("text").val()},
function(xml){ $("form").html('Email send'); }
);
return false;
});
Or you could go the php way and change a variable when the form is
posted and wrap an if else around the form.
<?php
if(count($_POST) > 0) { $var = 1; }
if($var == 1){
?>
Email send
<?php }else{ ?>
<form id="form" action="test.php">
<input type="text" name="text" id="text"><br>
<input type="submit" value="send" id="send">
</form>
<?php } ?>
This is quick code so don't put it on you site like it is.
Hambo Design (Steven) schreef:
Is it possible to recreate the newsletter signup at
www.thinkvitamin.com <http://www.thinkvitamin.com/> using jQuery? I am
not very proficient with jQuery (only just used the scroll feature
today!).
At the moment I have a php form which just squirts an h3 at the
beginning if the send is successful but I’d love to just instantly
hide the form and replace it with a ‘Your email has been sent’ message.
Thanks in advance,
Steven Hambleton
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.11.6/430 - Release Date: 28/08/2006
------------------------------------------------------------------------
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/