...

View Full Version : 2 submits for 1 form



ShMiL
08-06-2002, 10:48 PM
I have a form with 10 inputs.
I need one submit button which will submit the 10 inputs to page A.htm.
And another submit which will submit only 2 inputs to B.htm.
Thus I can choose which button to use (in term with my needs).
Thanks alot in advance,
ShMiL

boywonder
08-07-2002, 02:42 AM
try making your two buttons like this:

<input type="button" value="page a" onclick="this.form.action='pagea'; this.form.submit();">
<input type="button" value="page b" onclick="this.form.action='pageb'; this.form.submit();">

ShMiL
08-07-2002, 12:18 PM
but do you know how can I submit only the inputs I want to submit?
thanks alot for the previous answer.

ShriekForth
08-07-2002, 03:36 PM
It's going to post all of the fields on the form, you can just take the ones you want on pageb.

Or you could create a second form with the two elements in it. When they click the formB submit button, copy the two fields you need from from the furrent form into the two fields of the second form, and the submit that form instead of the first.

You would not have to change the action in that case, but your second submit button would have to do a bit more.

ShrikeForth

adios
08-08-2002, 02:16 AM
Works as long as .disabled is supported:


<html>
<head>
<title>untitled</title>
<script type="text/javascript" language="javascript">

var disableFields = new Object(); //list field names not to be submitted & action url
////////////////////////////////////key to submit button value
disableFields['Submit Some'] = new Array('input1','input3','input4','input5','input7','input8','input9','input10');
disableFields['Submit Some'].action = 'page2.htm';

disableFields['Submit Some Others'] = new Array('input1','input5','input7');
disableFields['Submit Some Others'].action = 'page3.htm';

function filter_upload(sub) {
if (disableFields[sub.value]) {
for (var i=0, f=sub.form; i<disableFields[sub.value].length; i++)
f[disableFields[sub.value][i]].disabled = true;
f.action = disableFields[sub.value].action;
}
}

</script>
</head>
<body>
<form action="page1.htm">
<input name="input1" value="1"><br>
<input name="input2" value="2"><br>
<input name="input3" value="3"><br>
<input name="input4" value="4"><br>
<input name="input5" value="5"><br>
<input name="input6" value="6"><br>
<input name="input7" value="7"><br>
<input name="input8" value="8"><br>
<input name="input9" value="9"><br>
<input name="input10" value="10"><br><br>
<input type="submit" value="Submit All" onclick="filter_upload(this)">
<input type="submit" value="Submit Some" onclick="filter_upload(this)">
<input type="submit" value="Submit Some Others" onclick="filter_upload(this)">
</form>
</body>
</html>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum