|
-
Jul 16th, 2002, 10:23 AM
#1
Thread Starter
Fanatic Member
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???
-
Jul 16th, 2002, 10:52 AM
#2
Hyperactive Member
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>
-
Jul 17th, 2002, 09:16 PM
#3
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.
-
Jul 17th, 2002, 09:31 PM
#4
Thread Starter
Fanatic Member
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?
-
Jul 17th, 2002, 10:52 PM
#5
but the thing is when you do the onclick it by passes the forms action and adds its own. have you tried it yet?
-
Jul 18th, 2002, 11:39 AM
#6
Thread Starter
Fanatic Member
So what you are saying is try Onclick within the submit3 tag
-
Jul 18th, 2002, 08:17 PM
#7
what's your form code look like?
-
Jul 18th, 2002, 08:20 PM
#8
Thread Starter
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|