PDA

View Full Version : two submit buttons


wap3
12-02-2002, 04:21 PM
Hey everyone.

I was just wandering is it possible to have two buttons in a form which in effect submit the form but add an extra bit of info to the action line.

For example if the action was: thispage.php?action=

Could i have to buttons one which would make the action line into
thispage.php?action=actionone

and the second
thispage.php?action=actiontwo

Is that possible ??

Thanks :thumbsup:

wap3
12-02-2002, 04:28 PM
oops sorry i did search first but I couldn't find anything.

I just did another search and found exactly what I wanted.

sorry . . :o

:thumbsup:

ConfusedOfLife
12-02-2002, 04:43 PM
It wasn't that bad if you sent the things that you found, maybe someone else had the same problem! Anyway, I did that for a form, not like you adding something to the url, but I wanted to have an Edit and a Delete button for some records, that when the client checks some records and presses delete, they be deleted but if he/she presses Edit, then he/she be able to edit them and I fould that it's possible to have multiple submit buttons for a form and when it's submitted, you can always find out which submit button was pressed by checking isset($_POST[nameOfTheSubmitButton]).
I thought it's not bad to send this for documentaion/suggestion!

wap3
12-02-2002, 04:48 PM
yer good point. I was looking for what you described really but didn't know you could do that.

Anyway here is what I found:

http://www.codingforums.com/showthread.php?s=&threadid=868&highlight=submit+buttons

:thumbsup:

wap3
12-02-2002, 05:33 PM
umm I have a question about this now I just tried it.

Is it possible to use images as the submit buttons ?? I just tried but it only seems to allow regular buttons.

Thanks :thumbsup:

HormonX
12-03-2002, 01:56 AM
sure you can ... here is how



<input type='image' name='mybutton' value='gotopage' src='yourbutton.jpg' border='0'>


hope that helps

HormonX

wap3
12-03-2002, 08:38 AM
Thanks hormon x,

but I already knew how to use images as submit buttons. But it appears when I try to use them in replace of the ordinary submit buttons in the code example (in the search result I posted above) it appears it is not able to function properly.

Anyone know why ?? If it is possible ??

:thumbsup:

wap3
12-03-2002, 03:44 PM
anyone got some advice for me here ??

:confused:

ConfusedOfLife
12-03-2002, 04:01 PM
Can I see your code? I think you can do something with php ( I don't know PHP that well!) that when the "normal" submit button is pressed, then you add your values to the address bar? Am I right? Coz in any other case I see no problem with using images as submit buttons.

firepages
12-03-2002, 04:23 PM
if you use an image button then the button name is not passed as usual but the button click co-ordinates so clicking an image button called 'button' adds the variables 'button.x' and 'button.y' to the POST variables array

now PHP does not like the dot '.' so it converts that to an underscore '_'

so that boils down to, you need to check for

if($_POST['button_x']){ //etc

or $_POST['button_y'];

so if you echo $button_x & $button_y you get the co-ordinates of where you clicked on the button !

wap3
12-03-2002, 04:54 PM
Thanks for the responses. I thought I was goig to get stuck there for a minute.

Thats works great firepages thank you. That's another trick I have learnt know. Thanks for the responses everyone else 2.


:thumbsup:

ConfusedOfLife
12-03-2002, 05:24 PM
It's great firepages! Thanx!! It's cool to have you here!