i have a select box and i want to pass every option of the select box with post not just what is selected in that box. I have it so there is a big list of options in 1 select box then you can move the diffrent options to other select boxes on the site depending on where you want to put them. when the user hits submit i want to take all the values from all the select boxes and use php to get them via post.
i was thinking maybe do a onclick on the submit button to take all of the options from list A and make a hidden field like
<input type="hidden" name="A[]" value="option1">
<input type="hidden" name="A[]" value="option2">
then for list B
<input type="hidden" name="B[]" value="option3">
<input type="hidden" name="B[]" value="option4">
but thats just a idea...anyone know how to do any of this?
passing all elements in a select box at once
Moderator: General Moderators
- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
never mind i fixed it...here is how i did it
i had a hidden field for each select box i wanted to pass all the info of and did this
then the submit button
as you can see i had 4 lists. the output was the $_POST[basic]->#,#,# the # being the option value. worked quite well.
i had a hidden field for each select box i wanted to pass all the info of and did this
Code: Select all
function getValues (select) {
var r = new Array();
for (var i = 0; i < select.options.length; i++)
rїr.length] = select.optionsїi].value;
return r;
}Code: Select all
<input type="e;submit"e; name="e;submit"e; value="e;submit"e;
onClick="e;this.form.basic_val.value = getValues(this.form.basic); this.form.medium_val.value = getValues(this.form.medium); this.form.specialist_val.value = getValues(this.form.specialist); this.form.expert_val.value = getValues(this.form.expert);"e;>