monkeytooth Posted June 26, 2008 Share Posted June 26, 2008 Is it possible to have multiple text/image form submits that have different values.. Like I know I can: <input type="submit" value="thing1" name="submit"> <input type="submit" value="thing2" name="submit"> <input type="submit" value="thing3" name="submit"> and with a bit o php use the name element to get the value being used to then do what I want, but with an image/text style submit button the: onclick="document.['mtlstsrv'].submit(); return false" So is it possible? Quote Link to comment https://forums.phpfreaks.com/topic/112073-possible-multiple-imagetext-submits-on-form/ Share on other sites More sharing options...
KevinM1 Posted June 26, 2008 Share Posted June 26, 2008 Yes, you can have multiple submits. However, it's best to give them different names. You can probably work around that by doing something like: <input type="submit" value="thing1" name="submit[]"> <input type="submit" value="thing2" name="submit[]"> <input type="submit" value="thing3" name="submit[]"> That may pass the submits to PHP/JavaScript as an array. I haven't tested it myself, so I can't say with 100% certainty. That said, for additional processing, you'll have to do some array manipulation in order to obtain the correct submit button. That's why I think it's just easier to give them different names. You can access them directly without having to jump through extra hoops. Quote Link to comment https://forums.phpfreaks.com/topic/112073-possible-multiple-imagetext-submits-on-form/#findComment-575353 Share on other sites More sharing options...
Wolphie Posted June 26, 2008 Share Posted June 26, 2008 I find it easier to give the submit buttons different names rather than passing them along to PHP as an array. If you passed them as an array you would need to validate each value, thereby giving each submit button a different appearance and having to write more code than necessary, whereas giving the submit buttons different names all of the submit buttons could appear the same (if you wanted them to). But regardless, I still find that giving the submit buttons different names easier. I think form controls such as checkboxes should be passed as an array because then it saves code, rather than having to assign the POST data to individual variables you could just loop through the array or use array keys. Quote Link to comment https://forums.phpfreaks.com/topic/112073-possible-multiple-imagetext-submits-on-form/#findComment-575364 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.