Multiple Reply Buttons

At the top of my “Display Private Message” page, I have a “Reply” Form Button that users can click on to respond to the PM. There is also a “Delete” Form Button like this…


	<div id='commandBar'>
		<input type='submit' name='submit' value='Reply'/>
		<input type='submit' name='submit' value='Delete'/>
	</div>

By naming each Form Button “submit”, it streamlines my PHP code, because when the Form is submitted, my code always knows to look for the value assigned to “submit” like this…


        if ($_POST['submit']=="Reply"){
            // Do some reply stuff...
        }elseif ($_POST['submit']=="Delete"){
            // Do some delete stuff...
        }

(Someone taught me this technique, and it is way easier to manage than having different names for each Button.)

However, my problem is that I want to add a second set of “Reply” and “Delete” Form Buttons at the bottom of my “Display Private Message” page so Users don’t have to scroll to the top of the page on long messages.

If I use the same code above I will have two sets of Form Submit Buttons with duplicate values

And if I give each set of Buttons unique Values, then that screws up the Button Label. (It would look silly to have “Reply” and “Delete” at the top of the page, and “Reply2” and “Delete2” at the bottom of the page?!) :rolleyes:

Is there a way to accomplish what I want, and hopefully not have to change the scheme I am currently using?

Sincerely,

Debbie

If the buttons do exactly the same (so you don’t need to discern them in PHP) there is no problem with giving them the same value.
You can’t give elements the same name or id, but you can re-use values as many times as you like (otherwise it wouldn’t be possible to have multiple checkboxes on a page, for starters).

Well, you can obviously have multiple Buttons with the same name because that is what I am currently doing…

But I guess you are saying having this…


	<div id='commandBar'>
		<input type='submit' name='submit' value='Reply'/>
		<input type='submit' name='submit' value='Delete'/>
	</div>


…in TWO PLACES isn’t an issue if they point to the same PHP code?

Debbie

Ah yes, you can indeed have elements with the same name, my bad. The latter just overrides the former in case of regular inputs and in case of submits it sends the value of the one that was clicked (as described here).

And yes, that’s what I was saying [that it isn’t an issue to put the same value in multiple places as long as they point to the same PHP code].