본문 바로가기

카테고리 없음

인풋박스에 자동으로 포커스 되도록 하기

<!--// 이 부분을 head 에 넎는다 -->

function inputFocus(){

    document.forms[0].elements[0].focus();

}

 

<!--// 보디 부분에서 호출 //--->

<body onLoad="inputFocus();>

 

두번째  form 의 세번째 input 박스에 포커스가 가도록 지정할 경우는

document.forms[1].elements[2].focus();

 

--------------------------------------------------------------

 

window.onload = function(){ 
    var obj = document.getElementById("sail"); 
    obj.focus(); obj.select(); 
    // obj.value = "날코천재"; 
}

 

<form id="product" name="form" method="post" > 
<input type="text" name="PN" id="sail" /> 
</form>

 

===============================================

 

<script>
window.onload = function(){ 
    var obj = document.getElementById("sail"); 
    obj.focus(); obj.select(); 
    // obj.value = "날코천재"; 

</script>

 

------------------------------------------------------

 


     <table width="270" border="0" cellspacing="1" cellpadding="2" bgcolor="#d3d3d3">
<form method="post" name="frmAdminLogin" action="/sess/adm_chk.php" onsubmit="return AdminLogin()">
<input type="hidden" name="mem_chk" value="adm">
     <tr bgcolor="#f2f2f2">
     <td width="70" align="right">USER</td>
  <td><input type="text" name="adm_id" size="19" maxlength="30" id="sail" style="width:100%";></td>
     </tr>
     <tr bgcolor="#f2f2f2">
     <td align="right">PASS</td>
  <td><input type="password" name="adm_pw" size="20" maxlength="30" style="width:100%";></td>
     </tr>
     <tr bgcolor="#f2f2f2">
     <td align="center" colspan="2"><input type="submit" value="check"></td>
     </tr>
</form>
     </table>