:: Forum >>

How to retrieve ListItem.Value and ListItem.Text of vb.NET by JavaScript?

Hello, I have arrayList of ListItem which has different Text and Value.
such as {{James Dean, 123}, {Bruce Lee, 456}}
I bound the arrayList to a ListBox1.
The ListBox displays only James Dean and Bruce Lee.
How can I retrieve the Value by using javascript?
I tried as;
var source = document.getElementById('ListBox1');
var dest = document.getElementById('TextBox1');

var finalText = '';
for (var x=0; x<source.options.length; x++)
{
if (source.options[x].text != '')
{
finalText += source.options[x].text + " ";
finalText += source.options[x].value + ",";
}
}

dest.value = shadowText;

I expected to see both Texts and Values, however, the TextBox1 displayed 'James Dean James Dean, Bruce Lee Bruce Lee'.

How can I get the string 'James Dean 123, Bruce Lee 456' by using javascript?

Thanks in advance
Rex Cho
Saturday, July 29, 2006

This topic is archived.


Back to support forum

Forum search