Results 1 to 8 of 8

Thread: Three submit buttons

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2002
    Location
    Hampton Beach
    Posts
    513

    Question Three submit buttons

    I have three submit buttons on my form.

    Two of the submit buttons are to navigate through a recordset by using a Next and Previous (Submit) button.

    My third Submit button is to actually submit the data to the server. This is how I have it working:


    This is the third Submit button.
    <INPUT Type=Submit Value="Add Record" onClick="this.form.action='deleterecord.asp';">

    This works fine!

    ** I have a validating function that when the user clicks the third submit button I want the Validate function that I created to run before submitting the data to the server.

    But the problem is with three submit buttons. Can anyone help me out???

  2. #2
    Hyperactive Member bsw2112's Avatar
    Join Date
    Nov 2001
    Location
    ottawa, canada
    Posts
    292
    hello,
    i don't know if this is want you want to do but maybe you can
    pass a value to the submit function to see which submit button triggerd the function. that way you can validate based on the value of you flag variable

    but maybe i am way off so...


    <html><head><title></title>
    <script>

    var flag=0;

    function vali(a) {

    if (flag) { alert("you clicked the first submit") }
    else
    { alert("you clicked the second submit") }
    }


    </script>
    </head>


    <form name= "form1" action="" onSubmit="return vali(this)">
    <input type = "text" name="txtFirst">
    <br>
    <input type = "text" name="txtSecond"><br>
    <input type = "submit" name="sub1" value="go1" onClick="flag=true"><br><br>
    <input type = "submit" name="sub2" value="go2" onClick="flag=false">
    </form>

    </head>
    <body>


    </body>

    </html>

  3. #3
    scoutt
    Guest
    your best bet is to change the 2 submit buttons to buttons since you are using javascript anyway. then that would leave the third one to do what you want.

    the vlaidate has to be javascript as when you submit it will go in order as the script that takes the submit.

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2002
    Location
    Hampton Beach
    Posts
    513

    Question

    I need to have them as submit buttons because I am posting the data to navigate through a recordset...

    Can you think of any work arounds?

  5. #5
    scoutt
    Guest
    but the thing is when you do the onclick it by passes the forms action and adds its own. have you tried it yet?

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2002
    Location
    Hampton Beach
    Posts
    513
    So what you are saying is try Onclick within the submit3 tag

  7. #7
    scoutt
    Guest
    what's your form code look like?

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2002
    Location
    Hampton Beach
    Posts
    513
    PROBLEM RESOLVED:

    I changed the third button to a button type and created two seperate forms on the same page. For the third submit button I used javascript to call the submit function...


    Works like a charm..

Posting Permissions

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



Click Here to Expand Forum to Full Width