Click to See Complete Forum and Search --> : need help with dropdown list


kariba
03-25-2003, 05:47 PM
Hi all,

I need to find out what is the selected value of my dropdown list, can someone help me?


if(document.getElementById('Category').SelectedIndex.Value == '0'){
document.getElementById('Categoryjs').innerHTML = "<span class=\"ClientSideBigred\">This field must not be left blank.</span>";
document.all['Categoryjs'].style.visibility = "visible";
}else{
document.getElementById('Categoryjs').innerHTML = '';
document.all['Categoryjs'].style.display = "none";
}

Thanks,

Mike

Jona
03-25-2003, 06:06 PM
Value of a selected option:

var variableName = document.formName.selectboxName[document.formName.selectboxName.options.selectedIndex].value;

if(variableName=="0"){
document.getElementById("CategoryJS").innerHTML = "<SPAN class='ClientSideBigred'>This field must not be left blank. </SPAN>";
document.all['CategoryJS'].style.visibility="visible";
}else{
document.getElementById("CategoryJS").innerHTML = "";
document.all['CategoryJS'].style.display = "none";
}

You may also try style.visibility="hidden"; instead of display="none"; but both should work.