天天看點

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>