How do I post a form using ajax?

  • Thread starter Thread starter cjgtaz2510
  • Start date Start date
C

cjgtaz2510

Guest
Currently I have a form that posts to a php script and is functional, but I need it to Post in the background with Ajax. I've seen a bunch of tutorials on posting with Ajax, but I'm not sure how to conform them to my use.

Here is my code right now:

<head>
<title>Hide/Show textarea</title>

<script language="JavaScript">
function showhide(happyval,divid)
{
if(happyval=="no")
{document.getElementById(divid).style.visibility="visible"}
}
</script>

<style type="text/css">
input#radimage {
display:none;
}
</style>

</head>
<body>
<div id="help_form">
<form name="help" >
<input type="image" src="smile.png" name="happy" value="yes" onClick="this.form.action='post.php';this.form.submit;" />Â*Â*Â*Â*
<label for="radimage"><input type="radio" id="radimage" name="sad" value="no" onClick="showhide(this.value,'divtxta')" /><img src="sad.png"/></label>
<div id="divtxta" style="visibility:hidden;">
<textarea name="txta" rows="5" cols="30"></textarea><br />
<input type="submit" value="submit" onClick="this.form.action='post.php';this.form.submit;" />
</div>
</div>
</form>
</body>



Any help/pointers would be greatly appreciated.

Thank you.
 
Back
Top