Home All Groups Group Topic Archive Search About

<select> <option> an element in DOM ?

Author
11 May 2007 1:36 AM
John Grandy
For an html <select> control , does the browser store each <option> as a
separate element in the DOM tree ?

Or are the select options stored in some other manner ?

Author
11 May 2007 9:35 AM
Teemu Keiski
Something like

<select name="sample" id="sample">
            <option value="1">The first</option>
            <option value="2">The Second</option>
            <option value="3">The Third</option>
        </select>
        <script type="text/javascript">
            function showOptions()
            {
                var ddl=document.getElementById('sample');
                for(i=0;i<ddl.options.length;i++)
                {


                    alert('Text:' + ddl.options[i].text + ',value:' +
ddl.options[i].value);
                }
            }
        </script>
        <input type="button" onclick="showOptions()" value="Show options"
/>

should show you the idea


--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net


Show quoteHide quote
"John Grandy" <johnagrandy-at-gmail-dot-com> wrote in message
news:OunvWz2kHHA.4900@TK2MSFTNGP05.phx.gbl...
> For an html <select> control , does the browser store each <option> as a
> separate element in the DOM tree ?
>
> Or are the select options stored in some other manner ?
>