views:

32

answers:

2

So the convention of using input type submit is this

<input type='submit' value='Submit'>

this will give me a button that says "Submit" on it and inside the post array i will have

$_POST['submit'] = 'Submit'

is it possible to have the submit button to show Submit but have the post value to be different. In other words, I want a button that still says "Submit" on it but the

$_POST['submit'] = 1

Is this possible without JavaScript?

+2  A: 

You can create a hidden input field with the name 'submit' and set the value to 1. You don't have to set the value of the input button itself in order to capture this value.

Dylan West
this is not possible because i have multiple submit buttons, the user will press one of the submit buttons and the key for that submit will correspond to the value attached to the submit button that the user clicked.
denniss
but do each of these submit buttons have their own form? If so, it is possible. Are you using multiple submit buttons for one long form, then?
Dylan West
ooooh good one! i will try that
denniss
+1  A: 

From http://reference.sitepoint.com/html/input/type:

The "submit" input displays the text that you specify in the value attribute, but if no value is specified, the button face will simply display the word Submit.

You could register a click handler that changes the value to 1 when the form is submitted, e.g. something like

<input type="submit" name="submit" value="Go!" onclick="this.value=1;"/>

though an unobtrusive handler would be prettier.

Edit since you edited the question to ask for a non-JS solution, go with Dylan's answer

Gordon
can you give me the script that changes the value to 1?
denniss
do you think this is possible without javascript?
denniss