Jump to content

Running a function after submitting form.


maxiscool
 Share

Recommended Posts

So I have a pretty simple question that is making me kind of confused.I have an HTML form setup and my goal is to generate a table from the data that is submitted by the form. Right now I have a validation function that is run "onsubmit". It checks all of the fields in the form and makes sure they are correct. What I don't understand is what do I do now that the form is validated. How do I run the function that actually does the stuff I want to do?Thank you

Link to comment
Share on other sites

You can either create the table using JavaScript, on the fly, but if you want your data to be persistent, you'll have to use a server-side language.http://w3schools.com/jsref/dom_obj_table.asp

Link to comment
Share on other sites

You can either create the table using JavaScript, on the fly, but if you want your data to be persistent, you'll have to use a server-side language.http://w3schools.com/jsref/dom_obj_table.asp
I do want to create it on the fly. What I don't understand is since "onsubmit" is being taken up by the validation function how do I call the function that creates the table?
Link to comment
Share on other sites

Just have another function that calls both:

function do_submit(form) {	validate(form);	generate_table(form);	return false;}

<form onsubmit="return do_submit(this)"></form>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...