天天看点

choose属性的使用(radio,checked)

<pre name="code" class="html"><c:choose>
	<c:when test="${buser.sex=='男' }">
		<input name="sex" value="男" type="radio"  checked="checked"/>
		<label >男</label> 
		<input name="sex" value="女" type="radio"  />
		<label >女</label> 						
	</c:when>
	<c:when test="${buser.sex=='女' }">
		<input name="sex" value="男" type="radio"  />
		<label >男</label> 
		<input name="sex" value="女" type="radio"  checked="checked"/>
		<label >女</label> 						
	</c:when>					
	<c:otherwise>
		<input name="sex" value="男" type="radio"  />
		<label >男</label> 
		<input name="sex" value="女" type="radio"  />
		<label >女</label> 						
	</c:otherwise>
</c:choose>
           

checked选中传回value值,不选中传null

<c:choose>
	<c:when test="isShare">
		<input name="isShare" type="checkbox" value="0" id="qf_eef8e4"  />
	</c:when>
	<c:otherwise>
		<input name="isShare" type="checkbox" value="0"  id="qf_eef8e4"  checked="checked"/>
	</c:otherwise>
</c:choose>
           

取消单选框

<div class="controls">
                   <input name="sex" type="radio"value="男"  οnclick='check(this)'/>
                   <label >男</label>  
                   <input name="sex" type="radio"value="女" οnclick='check(this)' />
                   <label >女</label>
          </div>
            <script> 
                 var tempradio= null;   
                 function check(checkedRadio)   
                 {   
                     if(tempradio== checkedRadio){ 
                         tempradio.checked=false; 
                         tempradio=null; 
                       }  
                        else{ 
                            tempradio=checkedRadio;   
                         } 
                  }          
             </script>