I have a form returned back from a PHP request. The form has a submit button and a regular button. The submit seems to work just fine, but the regular one won't work! Please advise.
Here is my HTML:
<tr id='actionRow' name='actionRow' hidden='hidden'>
<td>
<input class='actionBtn' type='submit' id='confirm' name='confirm'
value='Confirm' onclick='genChanged();'/>
</td>
<td>
<input class='actionBtn' type='button' id='cancel' name='cancel'
value='Cancel' onclick='cancel();' />
</td>
</tr>
And here is the cancel() function:
function cancel(){
alert('in cancel');
document.getElementById('editRow').hidden = false;
document.getElementById('actionRow').hidden = true;
window.location.replace("admin.php");
};
The alert never appears!
Is it even right to put multiple non-submit buttons in one form?
UPDATE my form looks something like:
<form action='save.php' method='POST' id='myForm'>
I've added the line document.getElementById('myForm').submit();
to the getChange(); function, to make the button be:
<input class='actionBtn' type='button' id='confirm' name='confirm'
value='Confirm' onclick='genChanged();'/>
Yet, cancel(); function still doesn't work!