You should use javascript arrays. this is much more likely to work with other browsers. Plus it would be more efficient because you wouldn't have to have the thing parsing XML every time you clicked on the list box.
Basically, what you need to do is this...
You have 2 data structures (datareader, datatable in a dataset, etc)
Using the StringBuilder class, you construct the javascript that declares and populates an array.
sJSLookupTable = New System.Text.StringBuilder
sJSLookupTable.AppendFormat("var m_aryLookupData = new Array(-1);{0}", Environment.Newline)
for each record in the first set
for each record in the second set
sJSLookupTable.AppendFormat("m_aryLookupData(m_ary LookupData.length) = ['{1}', '{2}'];{0}", Environment.Newline, firstRecordField.Value, secondRecordField.Value)
next record from second set
next record from first set
For this sample data (to show how the relationships result in the
JS lookup data):
Code:
Table1 Table2
------ -----------------
Joe Joe Red
Fred Joe Green
Fred Blue
Fred Purple
You end up with this javascript
:
var m_aryLookupData = new Array(-1);
m_aryLookupData(m_aryLookupData.length) = ['Joe', 'Red'];
m_aryLookupData(m_aryLookupData.length) = ['Joe', 'Green'];
m_aryLookupData(m_aryLookupData.length) = ['Fred', 'Blue'];
m_aryLookupData(m_aryLookupData.length) = ['Fred', 'Purple'];
Now, you will need to create a
JS function that fills the second dropdownlist based on the selected value of the first. You'll need to clear out the list first, then populate it with options based on what matches from the lookup array.
If you want to have the option's text be something more than what's in the lookup array (which you are using for the option's value), you could add one more element to the line that fills the array so to provide the "text" of the option.
Peter
------------------------------------------------------
Work smarter, not harder.