Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple submit on same form, to different pages 1

Status
Not open for further replies.

TheJhereg

Programmer
Nov 12, 2001
31
US
Got a bit of a problem... I'm probably missing something really stupid...

I have a very simple form (code below) that has 2 different form submissions that need to coexist on the same form. My idea for getting this to work is to alter the action on click in the second submit (forms[0].action).

Sounds good in abstract, but I'm having problems. While I can alter the action easily enough, the submit button that alters the action will not submit once the script has been added to the onClick, and I cannot force the button to submit the form using script.

here's the code...


<form name=&quot;mlsSave&quot; id=mlsSave method=&quot;post&quot; action=&quot;find.php&quot;>
<input type=&quot;hidden&quot; name=&quot;mlsString&quot; value=&quot;&quot;>
<input type=&quot;hidden&quot; name=&quot;numStored&quot; value=&quot;0&quot;>
MLS #: <input type=&quot;text&quot; name=&quot;mlsNum&quot;>
<input type=&quot;submit&quot; name=&quot;store&quot; value=&quot; Store &quot;>
<input type=&quot;button&quot; name=&quot;submit&quot; value=&quot;Submit&quot; onclick=&quot;document.forms[0].action='sendSaved.php'; document.forms[0].submit();&quot; >
</form>

...forms[0].submit() doesn't work. neither does document.all.mlsSave.submit(). (both generate the error &quot;object doesn't support... this... method&quot;).

If I leave off the submit, then the onClick event removes the submit event, and only changes the action and nothing else.

I'd add another form, but I have a good reason for using only one. Any ideas for getting the submit to work in script, or any other ideas would be appreciated. The Jhereg
=~=~=~=~=~=~=~=~=~=~
I never lie.
I'm building a reputation for honesty so I can blow it when something big comes along... This ain't it.
 
how about making the onClick an onSubmit? <insert witticism here>
codestorm
 
No dice.... Neither onSubmit nor onBeforeSubmit are valid events for a input=submit.

and yeah, I tried it just to be sure. The Jhereg
=~=~=~=~=~=~=~=~=~=~
I never lie.
I'm building a reputation for honesty so I can blow it when something big comes along... This ain't it.
 
sorry I should have said more.
Put the onSubmit on the form tag ..
give both submit buttons id/names (same) and values (different) ..
check the value of the submit button(s) element (ie by name) and branch on that.
<insert witticism here>
codestorm
 
Okay, Problem solved.... The problem? I'm an idiot.

<input type=&quot;button&quot; name=&quot;submit&quot; value=&quot;Submit&quot; onclick=&quot;document.forms[0].action='sendSaved.php';>

Yanno, the code actually works if that's a submit button............

<slapsself> Aparently I need to go to bed... The Jhereg
=~=~=~=~=~=~=~=~=~=~
I never lie.
I'm building a reputation for honesty so I can blow it when something big comes along... This ain't it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top