Link to home
Start Free TrialLog in
Avatar of kyama1
kyama1

asked on

dropdown list

i written code for dropdown list which is multiple selecion list.what i need is i want to refer each selected item by its name so that i can use that name in somewhere else.
i am using name attribute for option tag also, i donot know option tag has name attribute.
<select name=menu multiple>
buffer.append("<OPTION name=on24url"+i+" value="+urlroot+sChon24[i]+">Consumer: health</OPTION>");
</select>

why i need this is i used check box
<input type=checkbox name=on24url"+i+" value="+urlroot+sChon24[i]+"> iam using this one in the following code.
sChurl[i]=portal.getUser().getProperty("on24url"+i);
iam trying to implement drop down list instead of checkbox.
i need solution immediatly
Avatar of freshmeat
freshmeat

u don't need to put name in "option"
only let the value is unique, that is enough i think
the code of a multiple select is this:

<select name="myselect" multiple>
 <option value="value1">text1</option>
 <option value="value2">text2</option>
 <option value="value3">text3</option>
 <option value="value4">text4</option>
</select>

so you must generate in this way:

<select name=menu multiple>
buffer.append("<OPTION value="+urlroot+sChon24[i]+">Consumer: health</OPTION>");
</select>

and if you need to refer to the selected items in the same page you can use javascript:

<script language="javascript">
<!--
idSelect = document.my_form_name.myselect
for (iTmp=0; iTmp < idSelect.options.lengt; iTmp++) {
  if (idSelect.options[iTmp].selected) {
    alert("Option selected " + idSelect.options[iTmp].text + " value: " + idSelect.options[iTmp].value)
  }
}
//-->
</script>

xabi

ps: Please write me if you need more help or my answer is now correct.
ASKER CERTIFIED SOLUTION
Avatar of xabi
xabi

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kyama1

ASKER

i think i got idea, but iam not sure it will work for my case.anyway thanks for your help. if i need help i will mail you again