Jump to content

get values from many(4) multiple select Drop downs - and put that values in empty DD


roberto68
 Share

Recommended Posts

I have 4 multuiple select elemts - Dropdown lists. When user selects an option I want that option appear in blank DD (or some textbox...)

. If it's to complicated meaybe it'll be enough just to detect taht values selected in those dropdowns on button click. Here's my html

	<form name="dropdowns" id="dropdowns"><label for='educationForm'>select what you wanna learn<br><div align="center"><select multiple="multiple" name="mydropdown1[]" id="dd1"><option value="1">IT-programing</option><option value="2">IT-sys_admin</option><option value="3">IT</option><option value="4">science</option><option value="5">electronic engineering</option><option value="6">math&physics</option><option value="7">mechanical_engineering</option></select></div></label><label for='sportFrom'>move urself up!<br><div align="center"><select multiple="multiple" name="mydropdown2[]" id="dd2"><option value="8"></option><option value="9"></option><option value="10"></option><option value="11"></option><option value="12"></option><option value="13"></option>.......

what should I do - chcek every of the dropdown to change and if changed get value /text of that option and append it to that "newly" created dropdown?

Edited by roberto68
Link to comment
Share on other sites

Your HTML is full of errors. You have unclosed elements and duplicate IDs. In order for Javascript to work properly you need to correct the errors. http://validator.w3.org/

 

In Javascript you can get a list of selected options by looking through all the option elements and choosing values from those that have a selected property that evaluates to true. You can use those values to populate a dropdown or other element.

Link to comment
Share on other sites

ok so now I've corrected it - to explain it better : currently I've one multiselect Dropdown with devided by optgroup tags, but I've have template where there are 4 ( 3 are blank cause that's the problem how to post 4 dropdowns in 1 form) but that 1 Dropdown is working well right now - but I want 4 and optionaly show user what they've selected in some extra DD which'll be blank on document.ready

Link to comment
Share on other sites

I'm not sure what the problem is. Nothing is stopping you from having four <select> elements in the same form.

 

You can add a fifth select element outside of the form (so that it doesn't get submitted to the server, unless that's what you want) in which you display the selected results of the other dropdown elements.

Link to comment
Share on other sites

but the probelm is with that from retrieving on another page - cause the form consist of 4 multiple select dropdowns. yeah but now i have an idea i retireve it like this

var DD1 = <?php echo json_encode($_GET["mydropdown1"]) ?>; var DD2 = <?php echo json_encode($_GET["mydropdown2"]) ?>; ....

and then I can concatenate those 4 fields into one, is it a good idea?

Edited by roberto68
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...