amalafrida Posted January 30, 2012 Share Posted January 30, 2012 $_POST['select'] permits me access to the selected value of my combo box named 'select'. are any other attributes of the box accessible? in particular, index # ... etc.? thanks in advance for any light you might shed on the topic. Quote Link to comment https://forums.phpfreaks.com/topic/256013-select-box-attributes/ Share on other sites More sharing options...
Pikachu2000 Posted January 30, 2012 Share Posted January 30, 2012 What index# are you talking about? Anything accessible in the $_POST array can be seen with: echo '<pre>'; print_r($_POST); echo '</pre>'; Quote Link to comment https://forums.phpfreaks.com/topic/256013-select-box-attributes/#findComment-1312411 Share on other sites More sharing options...
scootstah Posted January 30, 2012 Share Posted January 30, 2012 Not with PHP. You would need Javascript for that. Quote Link to comment https://forums.phpfreaks.com/topic/256013-select-box-attributes/#findComment-1312420 Share on other sites More sharing options...
amalafrida Posted January 30, 2012 Author Share Posted January 30, 2012 I have 5 items in the select/combo box when I _POST that item, I am returned the text contained in the box. BUT, can I know WHICH of the 5 items in the combo box it is? i.e. can I get its index number? ............. ok, yes. thanks. I feared I was skirting that treacherous line betwixt the 2. thanks for the help. you folks are invariably straight up, spot on, not to mention accurate. Quote Link to comment https://forums.phpfreaks.com/topic/256013-select-box-attributes/#findComment-1312422 Share on other sites More sharing options...
scootstah Posted January 30, 2012 Share Posted January 30, 2012 No. I have 5 items in the select/combo box when I _POST that item, I am returned the text contained in the box. BUT, can I know WHICH of the 5 items in the combo box it is? i.e. can I get its index number? No. Quote Link to comment https://forums.phpfreaks.com/topic/256013-select-box-attributes/#findComment-1312433 Share on other sites More sharing options...
DavidAM Posted January 30, 2012 Share Posted January 30, 2012 You can get whatever you assign as the "value" attribute of the OPTION selected. <SELECT name="cmbChoose"> <OPTION>Me</OPTION> <OPTION>Her</OPTION> </SELECT> Using this example, you will get either "Me" or "Her" from $_POST['cmbChoose'] <SELECT name="cmbChoose"> <OPTION value="1">Me</OPTION> <OPTION value="2">Her</OPTION> </SELECT> Using this example, you will get either "1" or "2" from $_POST['cmbChoose'] Quote Link to comment https://forums.phpfreaks.com/topic/256013-select-box-attributes/#findComment-1312450 Share on other sites More sharing options...
amalafrida Posted January 30, 2012 Author Share Posted January 30, 2012 yes! that is precisely what I was looking for. saves me two trips to the database and much unnecessary parsing. once again, many thanks. Quote Link to comment https://forums.phpfreaks.com/topic/256013-select-box-attributes/#findComment-1312514 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.