Hi everyone, I’m trying out prototype for handling ajax requests. I used a tutorial on submitting a form with it and it works great. Now 'm trying to figure out how to get it to work with submitting only the selected forms input.
So say I have two forms with the same class names and same function called on submit of each form that will process the request and submit to a php file to add the data to a database. Adding different class names isn’t really an option as the script with the forms will be generated by a php script with varying amounts of forms. I guess the best example would be comments on a facebook feed.
So from the tutorial the js is:
<script>
function sendRequest2() {
new Ajax.Request("../results/process.php",
{
method: 'post',
postBody: 'name2='+ $F('name2'),
onComplete: showResponse
});
}
function showResponse(req){
$('show').innerHTML= req.responseText;
}
</script>
<form id="test" onsubmit="return false;">
<textarea name="name2" id="name2">
Content goes here.
</textarea>
<input type="submit" value="submit" onClick="sendRequest2()">
</form>
Any help would be great, I’ve a feeling it’s not that difficult but I’m not to familiar with prototype at the moment and the docs aren’t as well written as jquerys.
Thanks