Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Two buttons, One Validate

Status
Not open for further replies.

cohans

Programmer
Aug 21, 2001
35
US
I have 2 buttons on a form. I want to call one validate function and perform 1 of 2 actions based on what button was pressed. How can I first determine what button was pressed in the validate funtion, and then two, how do I specify the action within the validate function.
 
I've concluded it is probably better to just have 2 funtions eliminating the first question. Within each funtion, I'd like to set the action to go to one of 2 different jsp pages (i.e., funtion one goes to one.jsp and funtioon 2 goes to two.jsp.)
 
Well, just add this script:
<script language=&quot;javascript&quot; type=&quot;text/javascript&quot;>
function goto(button)
{
if (button == 1)
{
window.location.href=&quot;one.jsp&quot;;
}
else if (button == 2)
{
window.location.href=&quot;two.jsp&quot;;
}
}
</script>
Then in each buttons code you add:
onclick=&quot;goto(1);&quot; to button number one and onclick=&quot;goto(2);&quot; to button number two
//Daniel
 
Thanks, Daniel. Will all of the form parameters get passed on as well, since we're not using the action of the form?
 
You will have to include them in the script, or you do as you say, create another page that should be the action, that should have a lot of JavaScript on it to work.....
//Daniel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top