Gafaddict Posted October 27, 2007 Share Posted October 27, 2007 Hey all -- I'm running into a problem with a select box. Its values in PHP are not properly parsed. <select name="frm_owners" size="10"> <option value="1">Apples</option> <option value="2">Oranges</option> </select> Now, if I were to select both options and then output $_POST[frm_owners] on another page, all I would get is "2." But I'm looking for a comma-seperated value like "1,2." Any ideas? I thought this would be a fairly common question--funny I haven't found any related threads on the board. Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/74954-solved-getting-all-select-box-values/ Share on other sites More sharing options...
Azu Posted October 27, 2007 Share Posted October 27, 2007 Try changing the frm_owners to frm_owners[] Link to comment https://forums.phpfreaks.com/topic/74954-solved-getting-all-select-box-values/#findComment-379020 Share on other sites More sharing options...
Gafaddict Posted October 27, 2007 Author Share Posted October 27, 2007 Brilliant! That turned it into an array, so I used foreach to compile a final variable. Thanks a lot Link to comment https://forums.phpfreaks.com/topic/74954-solved-getting-all-select-box-values/#findComment-379025 Share on other sites More sharing options...
dbo Posted October 27, 2007 Share Posted October 27, 2007 Just out of curiosity... when you do it this way how do you access the controls via Javascript? document.getElementById('frm_owners[]').value or something? How does that work? I've not tried it but I suspect it breaks or something, I dunno. Link to comment https://forums.phpfreaks.com/topic/74954-solved-getting-all-select-box-values/#findComment-379076 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.