Click to See Complete Forum and Search --> : Three submit buttons
JohnSmith
Jul 16th, 2002, 10:23 AM
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???
bsw2112
Jul 16th, 2002, 10:52 AM
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>
scoutt
Jul 17th, 2002, 09:16 PM
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.
JohnSmith
Jul 17th, 2002, 09:31 PM
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?
scoutt
Jul 17th, 2002, 10:52 PM
but the thing is when you do the onclick it by passes the forms action and adds its own. have you tried it yet?
JohnSmith
Jul 18th, 2002, 11:39 AM
So what you are saying is try Onclick within the submit3 tag
scoutt
Jul 18th, 2002, 08:17 PM
what's your form code look like?
JohnSmith
Jul 18th, 2002, 08:20 PM
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..
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.