Canman2005 Posted August 26, 2009 Share Posted August 26, 2009 Hi all I have a List/Menu which looks lik <select name="users1[]" id="users1[]" multiple="multiple"> <option value="Dolor">Dolor</option> <option value="Donec">Donec</option> <option value="Integer">Integer</option> <option value="Lacus">Lacus</option> <option value="Leo">Leo</option </select> Is it possible to use foreach($_POST['users1'] as $d) on all items in the List/Menu, despite if they have been selected or not? thanks in advance ed Quote Link to comment Share on other sites More sharing options...
redarrow Posted August 26, 2009 Share Posted August 26, 2009 only if all the value name are in a array ok. i think you have set the form correctly have you tested it yet? Quote Link to comment Share on other sites More sharing options...
Canman2005 Posted August 26, 2009 Author Share Posted August 26, 2009 If I try and submit the form without any being selected, I get Warning: Invalid argument supplied for foreach() whereas I want it to ignore the fact none are selected and just carry through all the values from the List/Menu even the ones which are not selected. Quote Link to comment Share on other sites More sharing options...
redarrow Posted August 26, 2009 Share Posted August 26, 2009 firstly you mean this i guess then what please? <select name="users1[]" id="users1[]" multiple="multiple"> <?php $array=array("Dolor","Donec","Integer","Lacus","Leo"); foreach($array as $result){ echo"<option value='$result'>$result</option>"; } ?> </select> Quote Link to comment Share on other sites More sharing options...
Canman2005 Posted August 26, 2009 Author Share Posted August 26, 2009 the problem is im unable to do $array=array("Dolor","Donec","Integer","Lacus","Leo"); simply because the values in "users1[]" are dynamically added from another List/Menu, its basically javascript passing over the values from one list to another. Quote Link to comment Share on other sites More sharing options...
redarrow Posted August 26, 2009 Share Posted August 26, 2009 try this a shot in the dark sorry. Please hold down ctl button to selct more then one option please. <br/><br/> <select name="users1[]" id="users1[]" multiple="multiple"> <?php $array=array("Dolor","Donec","Integer","Lacus","Leo"); foreach($array as $result){ echo"<option value='$result'>$result <br></option>"; } ?> </select> <br/><br/> <input type="submit" name="submit" value="SEND!"> <?php if(isset($_POST['submit'])){ foreach($users1 as $final_result){ echo "You Selected: $final_result"; } } ?> Quote Link to comment Share on other sites More sharing options...
Canman2005 Posted August 26, 2009 Author Share Posted August 26, 2009 but I don't know what values are being passed over from one List to another, therefore doing $array=array("Dolor","Donec","Integer","Lacus","Leo"); would not be possible unless I knew what values the user was going to pass from one to another Quote Link to comment Share on other sites More sharing options...
Canman2005 Posted August 26, 2009 Author Share Posted August 26, 2009 It's ok, im going to use a javascript to select all the items in the List/Menu when the submit button is clicked 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.