'input index 값 구하기'에 해당되는 글 1건

  1. 2010.03.25 input index 값 구하기
반응형

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE> New Document </TITLE>
  <META NAME="Generator" CONTENT="EditPlus">
  <META NAME="Author" CONTENT="">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
 </HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
 function test(obj){
  var tc = document.getElementsByName(obj.name);
  for(var i=0; tc.length; i++){
   if(tc[i] == obj){
    var j = i;
    break;
   }
  }
  alert(j);

 }
//-->
</SCRIPT>
 <BODY>
  <INPUT TYPE="text" NAME="aaa" ONCLICK="test(this);"><INPUT TYPE="button" name="btn" VALUE="" ONCLICK="test(this);">
   <INPUT TYPE="text" NAME="aaa" ONCLICK="test(this);"><INPUT TYPE="button"  name="btn" VALUE="" ONCLICK="test(this);">
 </BODY>
</HTML>

Posted by 1010