jaikar Posted March 20, 2007 Share Posted March 20, 2007 Hi , how to get the values using post from a multiple list form when more than one value is selected ?.. is it possible ? please advice .. thanks in advance. jaikar Link to comment https://forums.phpfreaks.com/topic/43449-posting-form-list-multiple-values/ Share on other sites More sharing options...
skali Posted March 20, 2007 Share Posted March 20, 2007 Create multiple select list like this <select name="field_name[]" id="field_name[]" multiple="multiple" size="3"><option value="1">A</option><option value="2">B</option><option value="3">C</option><option value="4">D</option></select> In PHP you will get the values as an array of field_name in $_GET or $_POST whatever method you are using for form submission. $my_field = $_GET['field_name']; foreach($my_field as $key=>$value){ //loop through the array of selected items } Link to comment https://forums.phpfreaks.com/topic/43449-posting-form-list-multiple-values/#findComment-211003 Share on other sites More sharing options...
jaikar Posted March 20, 2007 Author Share Posted March 20, 2007 Exceeleeeeeeeeenttt !!........ Thanks a lot !... you are the best Syed !!....... i have on more Q.... is it possible to post the values without selecting it. my idea is that, there will be 2 list box and the user will move the items in one list box to the other list box and click submit. not i want to put all the data in the 2nd list box to the database. in this case the user has to select the items after moving correct ? but i want the user just to move the items and submit and the values in the 2nd list box should go to dbase.. is this possible ? Thanks again !!.. ~J Link to comment https://forums.phpfreaks.com/topic/43449-posting-form-list-multiple-values/#findComment-211012 Share on other sites More sharing options...
skali Posted March 20, 2007 Share Posted March 20, 2007 You can do it like that but i am not sure where you want to use this solution, Since your user will have to select an item in first select and will then move it to second one. Then why not just select the items in first one only. Link to comment https://forums.phpfreaks.com/topic/43449-posting-form-list-multiple-values/#findComment-211016 Share on other sites More sharing options...
jaikar Posted March 20, 2007 Author Share Posted March 20, 2007 you are correct, but the list is quite big, so if i have 2 list box, it could be easy for the user to see what he have selected.... its only for the user friendly interface.... if its possible, how to do it ?.. can you tell me any logic.. i had a logic that will select all the values while submit, butit did not worked for me.. can you help ? Thanks !! Link to comment https://forums.phpfreaks.com/topic/43449-posting-form-list-multiple-values/#findComment-211022 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.