|
 |
|
ต้องการทำให้เวลาเราต้องการเลื่อนช่อง textbox ไปในช่องถัดไปโดยไม่ต้องใช้ mouse ค่ะ |
|
 |
|
|
 |
 |
|
เขียนให้เลยครับ
Code (JavaScript)
<html>
<head>
<title>ThaiCreate.Com Tutorial</title>
</head>
<body>
<form name="frmMain" action="" method="post">
<script language="JavaScript">
document.onkeydown = chkEvent
function chkEvent(e) {
var keycode;
if (window.event) keycode = window.event.keyCode; //*** for IE ***//
else if (e) keycode = e.which; //*** for Firefox ***//
if(keycode==13)
{
return false;
}
}
function setNextFocus(objId,objId2){
if (event.keyCode == 13 || event.keyCode == 40){ // Submit and Down
if(objId=='submit')
{
document.frmMain.submit();
}
else
{
var obj=document.getElementById(objId);
if (obj){
obj.focus();
}
}
}
if (event.keyCode == 38){ // Up
if(objId2 != null)
{
var obj=document.getElementById(objId2);
if (obj){
obj.focus();
}
}
}
}
</script>
Textbox 1 <input type="text" name="txt1" value="" onKeyDown="setNextFocus('txt2',null);"> <br>
Textbox 2 <input type="text" name="txt2" value="" onKeyDown="setNextFocus('txt3','txt1');"> <br>
Textbox 3 <input type="text" name="txt3" value="" onKeyDown="setNextFocus('submit','txt2');"><br>
<input type="submit" name="btnSubmit" value="Submit">
</form>
</body>
</html>
|
 |
 |
 |
 |
Date :
2011-10-26 21:45:37 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่เห็นเลื่อนได้เลยค่ะ
|
 |
 |
 |
 |
Date :
2011-10-27 09:45:23 |
By :
fight2932 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|