...

View Full Version : Button 'value' attribute & IE



194673
12-02-2008, 10:42 PM
Was anyone else aware that IE doesn't send button "value"'s?

For example:
HTML:
<button name="button" type="submit" value="true">Click me</button>

PHP:


if ($_POST['button'] == "true")
{
echo 'button was pushed.';
}


If you're in IE, nothing will happen; if in any other standard-compliant browser, "button was pushed" will be echoed. Perhaps I'm missing something, but these are just my findings.

BoldUlysses
12-02-2008, 10:45 PM
http://www.w3schools.com/tags/tag_button.asp


Important: Be careful when using the button element in an HTML form. In a form the different browsers will submit different values. Internet Explorer will submit the text between the <button> and </button> tags, while other browsers will submit the content of the value attribute. When in a form, use the <input> tag instead.

Note: The type attribute for the button should always be specified. The default type for Internet Explorer is "button", while in other browsers (and the W3C specification) it is "submit".

194673
12-02-2008, 10:51 PM
Ahh, thanks for clearing that up :).

While I'm on the topic, is there any way to submit a value different from the button's text value (in all browsers)? The only way I would think of doing this is to use javascript to change the text on the button right before submission.

No particular reason why I want to know this, but I think it's pertinent.

Apostropartheid
12-02-2008, 11:30 PM
Ahh, thanks for clearing that up :).

While I'm on the topic, is there any way to submit a value different from the button's text value (in all browsers)? The only way I would think of doing this is to use javascript to change the text on the button right before submission.

No particular reason why I want to know this, but I think it's pertinent.
Why not use a hidden value?


<form action="post.php" method="post">
<fieldset>
<input type="hidden" id="session-id" name="session-id" value="192034"/>
<label for="name">Name</label>
<input type="text" id="name" name="name"/>
<input type="submit" value="Post!"/>
</fieldset>
</form>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum