troubleshooting Question

How do you add items to a listbox with javascript?

Avatar of jazz__man
jazz__man asked on
JavaScript.NET ProgrammingASP.NET
15 Comments1 Solution293 ViewsLast Modified:

I have the following code.....

<script language="javascript" type="text/javascript">
    function openbrWindow() {
        var RetVal = window.showModalDialog("Popup/popupFrame.aspx?qs=../Pickers/TestForm.aspx",
        'dialogHeight=300px;dialogWidth=700px,toolbar=no,unadorned=yes,directories=no,status=no,menubar=no,scrollbars=no,resizable=no ,modal=yes',

        var LstItems = document.getElementById("<%= lstItems.ClientID %>");

The code up to here works, but the following code is what I am trying to fix...

        //LstItems.add(new Option(RetVal, 1));

        var newOption = document.createElement('option');
        newOption.value = RetVal;
        newOption.innerHTML = RetVal;


As you can see, I am trying to add the window return value to a listbox control. The problem is the item displays for a second then disappears from the control.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 15 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 15 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros