Enter HTML input type value without changing column value?

Let's say that I have a really simple html form:

<form action="./whatever.php" method="POST">
    <input type="submit" name="TheButton" value="Apples">
</form>

Which, of course, does the button that the user sees, says "Apples." I want the post request to be TheButton=Oranges... Is there an easy way to handle this in HTML, or will I need to do something with action = javascript?

+5
source share
1 answer

A simple way is:

<button type="submit" name="TheButton" value="Oranges">Apples</button>

... but it will break in Internet Explorer (IIRC, up to version 7).

If you have only one button:

<input type="submit" value="Apples">
<input type="hidden" name="TheButton" value="Oranges">

... will work fine.

Otherwise, using server-side logic is the best approach:

<input type="submit" name="TheButton_Oranges" value="Apples">

, TheButton_, . , JS.

+9

All Articles