View Full Version : dynamic options woun't stay open

02-12-2004, 02:10 PM
I built a script which generates dynamicaly a list according to check boxes checked. The phoney thing is that the list woun't stay open when click the arrow, so I can not select an option... Any ideea?

function bla(){
var o1 ='<option>';
var o2 = '</option>';
var c='';
var a = new Array()
a[i] = document.forms[0].elements['ch'][i];
if(a[i].checked == true){b=o1+a[i].value+o2;}
document.getElementById('sel').innerHTML = '<select>'+o1+o2+c+'</select>';

<body onclick="bla()">
<input name="ch" type="checkbox" value="one" onclick="bla()">
one <br>
<input name="ch" type="checkbox" value="two" onclick="bla()">
two <br>
<input name="ch" type="checkbox" value="three" onclick="bla()">
three <br>
<input name="ch" type="checkbox" value="four" onclick="bla()">
four <br>
<input name="ch" type="checkbox" value="five" onclick="bla()">
five <br>
<div id="sel">

02-12-2004, 02:17 PM
innerHTML doesn't actually add new options to a dropdown. you have to manaully add them using the add options method seen here at MSDN (http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/add.asp?frame=true)

02-12-2004, 02:22 PM
Oh, but it does... Anyway, I found out what happened. Silly me, I wrote something stupid in body

<body [b]onclick{/b]...

I remove the stupidity and It works OK.

Well yes, maybe is a more correct ideea to build dinamically using createElement()...

Thus, I am not sure that I can sumbit some values from those options, but I will check it out.


EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum