Set the value of a dropdown using Javascript?

Last post 12-21-2007, 9:22 AM by Flintstone. 1 replies.
Sort Posts: Previous Next
  •  12-21-2007, 7:57 AM 35946

    Set the value of a dropdown using Javascript?

    How can I set the value of a dropdown using Javascript? e.g. Have Courier selected in the Default Font dropdown. This must be done using Javascript as the value I want to select depends on choices the user has made client side.
     
    I am able  to grab the element but am not able to find a way to set the selected index ... does anybody have any ideas?
     
    lp = document.getElementById('CE_ctl00_ctl01_bcr_PostForm___PostBody___Editor_IDfontname');
    if(lp)

        {
        ????????
        }


  •  12-21-2007, 9:22 AM 35949 in reply to 35946

    Re: Set the value of a dropdown using Javascript?

    Okay, I now have worked out how to change the innerHTML but the control remains the same ... is there a way to redraw / refresh it? Here is the code so far.
     
    lp = document.getElementById('CE_ctl00_ctl01_bcr_PostForm___PostBody___Editor_IDfontname');
    if(lp)

        {
            lp.childNodes.item(0).removeAttribute('selected')
            lp.childNodes.item(4).setAttribute('selected','True')
        ????????
        }
     

View as RSS news feed in XML