Click to See Complete Forum and Search --> : how to get information from submit-button?


mc_hammer
01-17-2007, 12:14 PM
Hi there,

I'm wondering how I can get more serious information from the submit-button which has been pressed.

Considering following html:

<form id="FormName" action="" method="post" name="FormName">
<button name="button" value="Button1" type="submit">Create a new entry</button>
<button name="button" value="Button2" type="submit">Delete selected entry</button>
</form>

with
echo $_POST['button'];
I would get 'Create a new entry' (if I press the first button) - but instead of the label I would rather get the information from value since I could work better with that and wouldn't need to do string-operations first... is this somehow possible?

Thx for any advice!
Oliver

NogDog
01-17-2007, 12:59 PM
Interesting: IE uses the text between the opening and closing button tags as the post value, but FF uses the value of the value attribute and ignores the text between the tags. It therefore appears that if you want to use a button element like this, then for multi-browser compatibility you need to supply the same value for both the value attribute and the text between the tags.

I guess my best suggestion would be to rethink the user interface for whatever you are trying to do. Not much help, I know... :(

mc_hammer
01-17-2007, 01:48 PM
very strange indeed - didn't know that IE behaves different :eek:

well, in that case I could at least refine it a little bit like the following:

<input type="submit" name="new" value="Create new entry" />