JonesJ
12-22-2011, 10:15 PM
Hi,
This button changes the button text when clicked, but it is always calling the same function. How to make the button depending on the button text to call different functions on onclick?
[CODE]
<script type = "text/javascript">
function button_switch(){
if (document.switch_form.switch_b.value == "Adam"){
document.switch_form.switch_b.value="Eva";
}
else{
document.switch_form.switch_b.value = "Adam";
}
}
</script>
<form name = "switch_form">
<input type = "button" name = "switch_b" id = "switch_b" value = "Adam" onclick = "button_switch()" />
</form>
[CODE]
This button changes the button text when clicked, but it is always calling the same function. How to make the button depending on the button text to call different functions on onclick?
[CODE]
<script type = "text/javascript">
function button_switch(){
if (document.switch_form.switch_b.value == "Adam"){
document.switch_form.switch_b.value="Eva";
}
else{
document.switch_form.switch_b.value = "Adam";
}
}
</script>
<form name = "switch_form">
<input type = "button" name = "switch_b" id = "switch_b" value = "Adam" onclick = "button_switch()" />
</form>
[CODE]