[RESOLVED] Passing multiple select options through POST
I have got a select box set up and I'm trying to pass all the options through the POST method. I've spent some time trying to figure out how to do this online and was wondering if there is an easy way. I have it set to display all options on the following page (through a foreach loop). I want to avoid creating another PHP page in between the two page, but if necessary I will do that.
I haven't been able to do this yet, I have it to select all options, but can't figure out how to send all options though.
Last edited by iamanubcake; 09-15-2010 at 07:57 PM.
Could you give a little more background on what you are trying to accomplish? Maybe walk us through the flow and the results you want so we can give you our best recommendation.
I have a select element set up and I have it so that the user clicks on some options and when the click a button it adds those options to the select list (it starts off blank). I want to be able to pass ALL option elements in the select list when the Submit button is hit and display them on the next page.
Then every item in the list will be submitted to the server.
<select name="myList" multiple="multiple">
<option value="1">Item 1</option>
<option value="2">Item 2</option>
<option value="3">Item 3</option>
for(i = 0; i < document.forms.myList.length; i++)
document.forms.myList[i].selected = true;
This is what I already had. I have tested it otherwise and it does select all options. I have it set on the "onclick" event on the submit button.
Is there anything wrong with that code at all? How do I display it on the next page?
for (var i = 0; i < document.getElementById("timeSlot").options.length; i++)
document.getElementById("timeSlot").options[i].selected = true;
Here is what I have and I think it will provide the results you want.
and the php that I have just prints the array from the form values
for (var i = 0; i < document.getElementById("cars").options.length; i++)
document.getElementById("cars").options[i].selected = true;
<form action="handle_event.php" onsubmit="return selectAll()" method="post">
<select id="cars" name="cars" multiple="multiple" size="4">
<input type="submit" name="submit" value="That's My Car" />
Array (  => volvo  => saab  => mercedes  => audi )
Thank you very much. It works perfectly fine.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)