I am unable to get the value of the clicked button when two buttons share the same name but have a different value in a form.
function submit_form(form) {
var status = form.status.value;
alert(status);
}
<form onsubmit="return submit_form(this)">
<button type="submit" name="status" value="1">Submit</button>
<button type="submit" name="status" value="2">Save as Draft</button>
</form>
It will work if there is only one button.
Please take note that this operation is triggered during the form submission and not when the button is clicked.
The input element will work fine but I want the button to work since I need to declare two values if I use the input.
The element i used here is , not . Please!