Web Analytics Made Easy -
StatCounter dynamic options woun't stay open - CodingForum

Announcement

Collapse
No announcement yet.

dynamic options woun't stay open

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • dynamic options woun't stay open

    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?

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

    <
    body onclick="bla()">
    <
    form>
    <
    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>
    <
    br>
    <
    div id="sel">
    </
    div>
    </
    form>
    </
    body>
    </
    html
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #2
    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
    *keep it simple (TM)

    Comment


    • #3
      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.

      Tx
      KOR
      Offshore programming
      -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

      Comment

      Working...
      X