Generic Form Parsing
Posted: Mon Apr 14, 2008 4:31 pm
I am looking for short snippet of code to output the names and values of all the inputs of a form for an ajax app.
This is the setup:
Form with button set so that onclick links to an ajax function which picks up the string of variables in GET format for the form to send in the request.
The only problem is that this list of variables is variable and so can't be hard coded into the script. I have found some attempts at this, but none are this simple and want to help validate the inputs.
Layout:
Then the javascript:
I know it's a simple FOR statement, but I'm new to javascript and this would be a great help.
Thanks
This is the setup:
Form with button set so that onclick links to an ajax function which picks up the string of variables in GET format for the form to send in the request.
The only problem is that this list of variables is variable and so can't be hard coded into the script. I have found some attempts at this, but none are this simple and want to help validate the inputs.
Layout:
Code: Select all
<form>
<inputs and stuff>
<input type=button onclick=process(this.form)>
</form>
Code: Select all
function process(form){
getform=getform(form);
DO AJAX STUFF using the string formed with the getform function from the form
}
Thanks