jsp 라디오 더블 클릭 취소

1735 단어 Radio
  <table width="80%" border="1">
			<tr>
				<td >
					  <input name="radiobutton1" type="radio" value="20" onclick="isCheck(this);" />
					  <input name="radiobutton1" type="radio" value="0" onclick="isCheck(this);"/>  (20,0)
				</td>
			</tr>
			<tr>
				<td>
					  <input name="radiobutton2" type="radio" value="50" onclick="isCheck(this);"/>
					  <input name="radiobutton2" type="radio" value="0"  onclick="isCheck(this);"/> (50,0)
				</td>
			</tr>
	</table>
<script type="text/javascript">
<!--
	var radioArr = new Array();
	function isCheck(obj){
		var hasCheck = false;
		
		for(var i=0; i<radioArr.length; i++){
			if(radioArr[i]==obj){
				radioArr[i].checked = false;
				radioArr.splice(i,1); //    
				hasCheck = true;
				break;
			}
		}

		if(!hasCheck){
			initRadioArr();
		}
		//alert(radioArr.join("-"));
	}
	//      radio
	function initRadioArr(){
		radioArr = new Array();

		//         radio   。
		var radios = document.getElementsByTagName("input");
		for(var i=0; i<radios.length; i++){
			if(radios[i].type.toLowerCase()=="radio" && radios[i].checked){
				radioArr.push(radios[i]);
			}
		}
	}
//-->
</script>

 radio_test.html

좋은 웹페이지 즐겨찾기