Comment

Chris Doors

I have cleaned up my code in previous example.

This is used if you have multiple button tags submitting the same form, so you can tell which button has submited form.

<form method="POST">
<input type=hidden id="submitbuttonpressedvalue" name="submitbuttonpressedvalue">

<button type="submit" onClick='buttonTagClicked(this.realvalue)' name='continuebutton' realvalue='continue'><img src="whatever.gif"></button>
<button type="submit" onClick='buttonTagClicked(this.realvalue)' name='backbutton' realvalue='back'><img src="whatever.gif"></button>
</form>
<script language="JavaScript" type="text/javascript">

function buttonTagClicked(buttonvalue)
{

document.getElementById('submitbuttonpressedvalue').value=buttonvalue;
}

</script>

Now in the post vars the realvalue of the button pressed should be in the
'submitbuttonpressedvalue' post var.

I think that's correct

Parent comment

Chris Doors

Yes this is blooming annoying; Here's what I did; I pairred each button tag with a hidden input field in the following way: '; '; And wrote this javascript function: Then when the button is submited it updates the related hidden field to 1. You can then use the hidden field variables to find which button tag was pressed as it will have value of 1. We should not have to do this but IE is obviously cr*p. Hope this helps

Replies

Richard Williams

I'm rather late finding this problem. Chris' solution works fine for IE6 etc. but fails for FireFox. I have both value=".." and realvalue=".." Then in my PHP script I test for submitbuttonpressedvalue="undefined" when I know it's not IE and get the proper POST variable value otherwise I use the submitbuttonpressedvalue.