I have a situation where I need to track which button of the submit button I need to do in order to set the variables accordingly. Below is the test code,
<script>
function submitForm(form) {
alert(document.getElementById('sb').value);
if (document.getElementById('sb').value=="One") {
}
return true;
}
</script>
<form action="" method="get" onsubmit="return submitForm(this);">
<input type="submit" name="sb" value="One">
<input type="submit" name="sb" value="Two">
<input type="submit" name="sb" value="Three">
</form>
A warning always shows “One,” even if I press the “Two” or “Three” button. But the URL is changed using the clickable parameter. How to warn the value that is in the pressed submit button?
Note. I need a solution without jQuery
EDIT: I change the bit of code that onsubmit calls submitForm (this); The problem is even to use document.forms [0] .sb.value its undefined because document.forms [0] .sb returns a node list of all submit buttons just like document.getElementById ('sb')