the form submitting via ajax is the hard part... to clear your values just run through each input field and set the value to nothing... here is how its done in jQuery:
Code:
$(#containDiv input).val('');
that wont do select drop downs but you get the idea
Is there a way to do it without a library like JQuery?
I am looking to do the same thing, but didn't want to use a library like JQuery. I was trying to use something like document.myform.reset() in the ajax function after it sends the the data to the php script but that isn't working.
Basically after it runs the ajax stuff to send the data to the database (my php file handles all that) I'd like the form to clear. The code works as it should except for clearning the form after. I also tried clearing the value of each input field as you suggested but that didn't work as well. I tried moving the one line of code to clear the form to the 3rd ajax function that handles the returned data but that didn't work either. Any other suggestions or do you need to see more of the code? Thanks for your help.
I threw some alerts in to try and troubleshoot and they popping up okay. I only have the one form on the page so there shouldn't be any conflicts there. I'll keep playing with it and if I find a solution will post.
Yeah! I fixed the problem. According to Mozilla's dev center any control holding the name or id "reset" will mask the form.reset() function. I had a reset button on the form also and it's name was "reset". Changing the name of the button to "clear" solved the problem.
Yeah! I fixed the problem. According to Mozilla's dev center any control holding the name or id "reset" will mask the form.reset() function. I had a reset button on the form also and it's name was "reset". Changing the name of the button to "clear" solved the problem.
Ah, interesting to know. Thanks for posting the solution.
I've switched careers...
I'm NO LONGER a scientist,
but now a web developer...
awesome.
Bookmarks