I have been ripping my hair out for days trying to figure out how to make this work without javascript (although that's something that CAN be used if necessary). I have a form with a SAVE and DELETE button required in the same form (they share the same fields and information). What I want to be able to do is be able to tell WHICH button was pushed. via $_POST would be great, but I dont' know if its possible. This is what I have, and it does not pass a value for "save" or "delete": <input type=image src=save.gif border=0 name=save alt='Save Trade Settings' value='true'> <input type=image src=delete.gif border=0 name=delete alt='Delete This Trade' value='true'> Any help, please...
I don't really understand what is the problem if your button have two different id's.... you give them two different id's and then set up the $_post to take a variable from whichever of them you want. no?
That's what I thought too. if($_POST[save] == "true"){do this} elseif($_POST[delete] == "true"){do that} But this DOES NOT seem to work.
<input type = "submit" name = "save" value = "Save" /> <input type = "submit" name = "delete" value = "Delete" /> Code (markup): if($_POST['save'] || $_POST['save'] == 'Save') { do ..... } if($_POST['delete'] || $_POST['delete'] == 'Delete') { do ..... } PHP:
Try this <input type=image src=save.gif border=0 name=action[] alt='Save Trade Settings' value='true'> <input type=image src=delete.gif border=0 name=action[]alt='Delete This Trade' value='true'> PHP: by placing the two action buttons in an array the one pushed will be passed with the post data, $_POST[action][0][true] might be best to use the value's as save and delete rather that true make it easyier for comparsion Hope this what you require
You have two ways to solve your problem. * Using img submits, which when are clicked, send an X/Y variable of where it was clicked. * Create a hidden field, when users click on delete, you change the original value of 0 to 1, and you process the form based on that hidden field. If user has Javascript off (small possibility), the item will not get removed, or maybe give the user a message to turn it on. Peace,
The hidden field idea was one that I played with but I don't know javascript well enough to dynamically change that field based on the button push, is there an EXTREMELY simple script that will do this for me that someone can share? I haven't had time to try any of these yet, I leave on Vacation in less than 24hrs.