Code: Select all
<input type="submit" name="action" value="Forward" />
<input type="submit" name="action" value="Back" />Moderator: General Moderators
Code: Select all
<input type="submit" name="action" value="Forward" />
<input type="submit" name="action" value="Back" />Code: Select all
<script type="text/javascript">
function goto(_action)
{
document.forms.mainform.action = _action;
document.forms.mainform.submit();
}
</script>Code: Select all
<form action="#" id="mainform" method="post">
...
<input type="button" onclick="goto('frw.php');" name="forward" value="Forward" />
<input type="button" onclick="goto('back.php');" name="back" value="Back" />
...
</form>Please pay attention on the names of your buttons. Every name should be unique.tecktalkcm0391 wrote:Code: Select all
<input type="submit" name="action" value="Forward" /> <input type="submit" name="action" value="Back" />
And how would that behave if I simply pressed 'Enter' while one the form's fields had been having the focus? To me it seems that catching form's 'onsubmit' event is much better approach.Code: Select all
<input type="button" onclick="goto('frw.php');" name="forward" value="Forward" />
Ok. We can choose default form action which will call when we press enter.Weirdan wrote: And how would that behave if I simply pressed 'Enter' while one the form's fields had been having the focus? To me it seems that catching form's 'onsubmit' event is much better approach.
Code: Select all
<form action="#" id="mainform" method="post">
...
<input type="button" onclick="goto('frw.php');" name="forward" value="Forward" />
<input type="button" onclick="goto('back.php');" name="back" value="Back" />
...
</form>This won't get us at neither to frw.php nor to back.php, though I see you point. As to determining the element to which the event was originally dispatched it what the 'target' event property is for.Code: Select all
<form action="#" id="mainform" method="post">
Code: Select all
<form action="frw.php" id="mainform" method="post">
...
<input type="button" onclick="goto('frw.php');" name="forward" value="Forward" />
<input type="button" onclick="goto('back.php');" name="back" value="Back" />
...
</form>Thanks. I'll try itAs to determining the element to which the event was originally dispatched it what the 'target' event property is for.