For Programmers: Free Programming Magazines  


Home > Archive > C# > November 2004 > How to get list of options from HTMLSelectElementClass?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How to get list of options from HTMLSelectElementClass?
Mark MacRae

2004-11-18, 3:58 pm

Ok, maybe I'm doing this all wrong, but the subject pretty asks what I
think I need to know.

I am trying to grab all of the options from an HTML "select" control,
and then display them in a combo box.

I'm reading the HTML document using a AxSHDocVw.AxWebBrowser, but I
don't think that really matters...

To work with a select control, I can get the element (of type
"HTMLSelectElementClass") from the current document and I see that
there is a property called ".options" attached to it, but apparently
it's not really a collection of "options" objects - that would be too
easy. It actually seems to be another copy of the select object...
who wrote these classes??

Anyway. I can successfully get the length of the
HTMLSelectElementClass which matches the actual number of options(with
the .length property), which leads me to believe that I should be able
to somehow iterate through all the options, but unfortunately that
doesn't seem to be the case in practise - at least I can't figure out
how to do it without writing something that parses through the
"innerHTML".

Any hints?
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com