PDA

View Full Version : One button with two different action


edwin_javier
10-10-2002, 09:57 AM
Hi... Is there a script where you have a one submit button and it have a two different action in one form.


THANKS!

edwin

glenngv
10-10-2002, 10:23 AM
can you explain further on what you actually want to accomplish?

premshree
10-10-2002, 12:31 PM
You could use a button :


<input type="button" onClick="form1.submit();form2.submit">Click</button>


Is this what you want? Please explain more........

RadarBob
10-10-2002, 01:36 PM
You mean like a toggle switch, a light switch? Press once, "off", press again - "on", repeat...?

The basic idea is to have a value that you can check to see what the current state is. Then do the appropriate code for that state. And you DON'T have to use a button; this is just an example.


function DoYourThang(theButton) {
if (theButton.value == " Turn Me On, Big Fella! ") {
theButton.vlue = " Ohh, cool me down you... ";
// other code as needed
}else{
theButton.value = " Turn Me On, Big Fella!";
// other code as needed
}
}

<body>
. . .
<input type="button" value=" Turn Me On, Big Fella! "
onclick="DoYourThang(this);">