Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Posts
    436
    Thanks
    1
    Thanked 0 Times in 0 Posts

    2 submits for 1 form

    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

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    New York, USA
    Posts
    175
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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();">

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Posts
    436
    Thanks
    1
    Thanked 0 Times in 0 Posts

    thanks

    but do you know how can I submit only the inputs I want to submit?
    thanks alot for the previous answer.

  • #4
    Regular Coder
    Join Date
    Jul 2002
    Location
    Western US
    Posts
    169
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Posts
    1,404
    Thanks
    2
    Thanked 32 Times in 32 Posts
    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>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •