alternative Posted June 18, 2011 Share Posted June 18, 2011 I have the code below (taken from w3 and expanded by me), and I am trying to submit 2 forms when the userpresses submit with different lastnames, but I cant do it. Any ideas?<html> <head> <script type="text/javascript"> function second() { document.getElementById("a").value="duck"; document.forms["f"].submit(); } function preventDef(event) { event.preventDefault(); document.getElementById("a").value="minnie"; document.forms["f"].submit(); var t=setTimeout('second()',3000); } </script></head><body><form id="f" name="input" action="html_form_action.asp" method="get">First name: <input type="text" name="FirstName" value="Mickey" /><br />Last name: <input id="a" type="text" name="LastName" value="Mouse" /><br /><input type="submit" value="Submit" onclick="preventDef(event)" /></form> <p>If you click the "Submit" button, the form-data will be sent to a page called "html_form_action.asp".</p></body></html> Link to comment Share on other sites More sharing options...
Ingolme Posted June 18, 2011 Share Posted June 18, 2011 You can only send one form at a time. Once the form is sent, the user leaves the page. You can manipulate the page that processes the form data so that it can take more information. Link to comment Share on other sites More sharing options...
alternative Posted June 18, 2011 Author Share Posted June 18, 2011 You can only send one form at a time. Once the form is sent, the user leaves the page. You can manipulate the page that processes the form data so that it can take more information. thanks for the reply. But since the form is sent to a server, doesnt that mean that I cant manipulate that page? Link to comment Share on other sites More sharing options...
Ingolme Posted June 18, 2011 Share Posted June 18, 2011 You have to manipulate the page that's on the server, and add more fields to the form. Link to comment Share on other sites More sharing options...
jeffman Posted June 18, 2011 Share Posted June 18, 2011 If you want to send data to the server that is not visible to the user, consider adding an input of type="hidden". If you need to, you can change the value of any hidden inputs before you submit the form. Link to comment Share on other sites More sharing options...
jeffman Posted June 18, 2011 Share Posted June 18, 2011 If you really, really need a the same script to run 2 times with different data, consider using AJAX instead of a traditional form submission. (But it is hard to imagine why you would really need to do this.) Link to comment Share on other sites More sharing options...
thescientist Posted June 18, 2011 Share Posted June 18, 2011 it seems like it would just be easier to write the server side script to handle any data manipulation/duplication, etc... Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.