var s1=document.getElementById('list_Stencil');
stencilvalue= s1.options[s1.selectedIndex].value; 如果listbox中没有选中值 页面会报脚本错
如果没有选中值 执行s1.options[s1.selectedIndex].value 会直接提示报错
怎么样用来判断listbox中是否有选中值呢? 我想最后的判断是
if(stencilvalue=="")
{
alert("请选择一项");
}
stencilvalue= s1.options[s1.selectedIndex].value; 如果listbox中没有选中值 页面会报脚本错
如果没有选中值 执行s1.options[s1.selectedIndex].value 会直接提示报错
怎么样用来判断listbox中是否有选中值呢? 我想最后的判断是
if(stencilvalue=="")
{
alert("请选择一项");
}
{
alert("请选择一项");
}
if(s1.selectedIndex > -1)
{
stencilvalue= s1.options[s1.selectedIndex].value;
}
stencilvalue= s1.options[s1.selectedIndex].value; 这一句会报错
for(i = 0; i < a.length; i++)
{
if(a[i].checked)
{
value = a[i].value;
count++;
}
}
if(count==0)
{
alert('请选择...')
return;
}
for (var i = 0; i < sel.options.length; i++) {
if (sel.options[i].selected) {
return sel.options[i].value;
}
}
return null;
}
function MyClick() {
var s1 = document.getElementById('MainContent_list_Stencil');
stencilvalue = getSelected(s1);
if (!stencilvalue) {
stencilvalue = s1.options[0].value;
}
}