轻微怎么样判断html:multibox不能为空?
<html:multibox property= "search_popedom.check_pope " value= "1 " /> a
<html:multibox property= "search_popedom.check_pope " value= "2 " /> b
<html:multibox property= "search_popedom.check_pope " value= "3 " /> c
<html:multibox property= "search_popedom.check_pope " value= "4 " /> d
<html:multibox property= "search_popedom.check_pope " value= "5 " /> e
<html:multibox property= "search_popedom.check_pope " value= "6 " /> f
<html:form action= "pope.do? " onsubmit= "return check() ">
function check(){
alert(document.forms[0].search_popedom.check_pope.value);
}
为什么获取不到html:multibox的值,
我写成这样也不对
document.all[ 'search_popedom.check_pope '].value;
请问是什么原因?
------解决方案--------------------function checkbl(){
var list=document.getElementsByName( "search_popedom.check_pope ");
var bl=0;
for(var i=0;i <list.length;i++){
if(document.getElementsByName( "search_popedom.check_pope ")[i].checked){
bl++;
}
}
return bl==0;
}
然后再提交时调
function check(){
if(checkbl()){
alert( "不能为空 ");
}
}
------解决方案--------------------var boxe1 = document.getElementsByName( "checkCountry ");
var check1 = new Array();
for (var i = 0; i < boxe1.length; i++)
{
if (boxe1[i].checked)
{
check1[check1.length] = boxe1[i].value;
}
}
if(check1.length <1)
{
alert( "请选择一个country! ");
return false;
这是得到所有选中的值,自己改改应该可以的