M
mike
I have a select list defined like:
<select name="cri2" multiple style="height:220px; width:300px;"
onClick="show_content(this);">
</select>
I add content to it dynamically using a function like:
function addOption(theSel, theText, theValue, optionColor)
{
var newOpt = new Option(theText, theValue);
var selLength = theSel.length;
theSel.options[selLength] = newOpt;
theSel.options[selLength].style.color = optionColor;
}
Sometimes the text content is so large that I need the user to be able
to see it using the onclick event in the select like:
function show_content(obj)
{
//this did not work i got an error about the object not
supporting this property or method
//alert(obj.options[obj.selectedIndex].value);
for ( var i=0; i<obj.length; i++ )
{
if (obj.selected){alert(obj.value);break;}
}
}
The pointer seems all screwed up. the first time i click on it i get
nothing. then the next time i get the alert. If there are 3 items the
alert is for the last item i clicked on.
Any help is appreciated.
Mike
<select name="cri2" multiple style="height:220px; width:300px;"
onClick="show_content(this);">
</select>
I add content to it dynamically using a function like:
function addOption(theSel, theText, theValue, optionColor)
{
var newOpt = new Option(theText, theValue);
var selLength = theSel.length;
theSel.options[selLength] = newOpt;
theSel.options[selLength].style.color = optionColor;
}
Sometimes the text content is so large that I need the user to be able
to see it using the onclick event in the select like:
function show_content(obj)
{
//this did not work i got an error about the object not
supporting this property or method
//alert(obj.options[obj.selectedIndex].value);
for ( var i=0; i<obj.length; i++ )
{
if (obj.selected){alert(obj.value);break;}
}
}
The pointer seems all screwed up. the first time i click on it i get
nothing. then the next time i get the alert. If there are 3 items the
alert is for the last item i clicked on.
Any help is appreciated.
Mike