<a href> instead of the <input submit> button
I originally had a submit button.
<input class="submit" type="submit" class="input" value="Add" name="command" />
but now I would like to use <a href>. The problem is that it is value="Add"very important.
I am currently doing <a href>as follows.
<a href="javascript:document.register.submit();">submit</a>
Any suggestions? The problem is that the site does not pick up that this particular one <a href>was clicked and therefore will not run my php code.
+3
3 answers
First of all, I highly recommend jquery. This makes a world of difference when working with javascript and simplifies a number of problems, especially in different browsers.
I suggest creating hidden input to set the value with.
<script type="text/javascript">
function submitFormWithValue(val){
document.getElementById('command').value = val;
document.forms["test"].submit();
}
</script>
<form id="test" name="test" action="#" method="post">
<input type="hidden" name="command" value="" />
</form>
<a href="javascript:submitFormWithValue('foo')">Submit</a>
, , , . jquery, javascript!
+4