ITeye博客

JavaScript:radio object:实例1

ilusm · 2008-06-13 16:04 · JavaScript · Markdown

当然还可以用DWRUtil.getValue("selHotel");取值。在只有一个radio时,那么document.frm.selHotel.checked 值为true或flase,DWRUtil.getValue("selHotel")的值为true或flase,radio的值为document.frm.selHotel.value即true或flase。如果有多个radio时,那么document.frm.selHotel[i].checked 值为true或flase,DWRUtil.getValue("selHotel")的值为document.frm.selHotel[i].value,radio的值为document.frm.selHotel[i].value。

<script language="javascript">
function selHotel()
{
    var HotelCode ="";  
    var intValid = document.frm.selHotel.length;  
    if(document.frm.selHotel.checked == true )  
    {   
        HotelCode = document.frm.selHotel.value;  }     
	if(intValid >1){     
	    for(var i =0;i<document.frm.selHotel.length;i++){
	    //alert(document.frm.selHotel[i].checked);      
	    if (document.frm.selHotel[i].checked== true ){       
		HotelCode = document.frm.selHotel[i].value;       
		//alert(HotelCode);      
		}     
	    }    
	}
    }
</script>
 <form name="frm" action="">
<input type="radio" name ="selHotel' value="1">
<input type="radio" name="selHotel" value="2">
</form>

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。