TheWebExpert Posted September 28, 2023 Share Posted September 28, 2023 I really need this particular form to have two separate submit buttons. I have a listbox, on which I've selected the item in question. With button1, I want to simply "check" or "uncheck" a box, and then redisplay the list. With the other, I want to do other editing. However, no matter how I do it (either same name, different values) or (different name, different values), I'm not seeing the buttons at all. <form action = "processedit.php" method = "post" style = "z-index: 1; width: 898px; height: 232px; position: absolute; top: 30px; left: -1px"> <input type = "image" name = "sbutton" alt = "Submit" value = "Select" id = "zz" ... <input type = "image" name = "abutton" alt = "Submit" value = "Activate" id = "qq" ... <input type = 'hidden' name = 'uname' id = 'uname' value = '<? echo $uname; ?>'/> <select name = "books" class = "auto-style1" value = '' size = "40" style = "width: 543px; height: 203px; z-index: 1; position: absolute; top: 11px; left: 15px"> ... if (isset($_POST['abutton'])) $func = $_POST['abutton']; if (isset($_POST['sbutton'])) $func = $_POST['sbutton']; Quote Link to comment Share on other sites More sharing options...
Barand Posted September 28, 2023 Share Posted September 28, 2023 21 minutes ago, TheWebExpert said: I'm not seeing the buttons at all. Your image buttons don't specify image sources Quote Link to comment Share on other sites More sharing options...
TheWebExpert Posted September 28, 2023 Author Share Posted September 28, 2023 That's because I intentionally cut the line off for the forum. It's the first part (the name/value) of the buttons I was posting. The $_POST just isn't getting the information. Quote Link to comment Share on other sites More sharing options...
TheWebExpert Posted September 28, 2023 Author Share Posted September 28, 2023 if ($_POST['select_button_x'] > 0) { echo "select"; } if ($_POST['activate_button_x'] > 0) { echo "activate"; } This got the job done. Quote Link to comment Share on other sites More sharing options...
Barand Posted September 28, 2023 Share Posted September 28, 2023 or.. <?php if ($_SERVER['REQUEST_METHOD']=='POST') { echo $_POST['btnSub']; //==> Select/Activate } ?> <form method = "post" > <input type = "submit" name = "btnSub" value = "Select" id = "zz"> <input type = "submit" name = "btnSub" value = "Activate" id = "qq"> </form> Quote Link to comment Share on other sites More sharing options...
ginerjm Posted September 28, 2023 Share Posted September 28, 2023 Now that Barand has shown you to setup the buttons, you just need to write code to not only recognize that your for has been 'posted' but then checkk and see what $_POST['btnSub'] is equal to and proceed to your logic. Quote Link to comment Share on other sites More sharing options...
requinix Posted September 29, 2023 Share Posted September 29, 2023 By the way, if you ever want a submit button with a value that's separate from the label - or want a button that is more than just text - then <button> exists to help you out: <button type = "submit" name = "btnSub" value = "something" id = "zz">Select</button> where the btnSub value in $_POST will be "something". Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.