2

A simple html question i would like to make form that shows a different value to the one that it posts.

<form action="" method="post"> 
<input type="submit" name="action" value="Buy"/>
</form> 

for example shows a button with Buy written on it and Buy is also posted. I would like it to show Buy, but I would like it submit a differnet value.

asked Jul 24, 2011 at 12:28

3 Answers 3

1

In theory you can:

<button type="submit" name="action" value="a differnet value">Buy</button>

In practise, we have to operate on a WWW that includes Internet Explorer.

You would probably be better off encoding the data into the name attribute and checking that.

answered Jul 24, 2011 at 12:32
Sign up to request clarification or add additional context in comments.

Comments

0

probably the easiest way to do it is to attach an event to the form submission to change the value for that input button. You could probably also put an onclick for the submit button itself.

<form action="" method="post"> 
<input type="submit" name="action" value="Buy" onclick="this.value='some value';"/>
</form> 
answered Jul 24, 2011 at 12:39

Comments

0

The button within form is only for checking if the form is submitted or not. You don't need to get the value of the button. Simply write html code:

<form action="smth.php" method="post"> 
<input type="submit" name="action" value="Buy"/>
</form> 

And smth.php will look like that

if(isset($_GET['action']))
{
...
do smth
...
}
answered Jul 24, 2011 at 12:41

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.