|
|
|
กรอกข้อมูลใน textbox1 แล้วกด enter แล้วสร้าง textbox2 เองอัตโนมัติ รบกวนท่านผู้รู้ครับ |
|
|
|
|
|
|
|
โค้ดมั่วเรื่องตัวแปลนิดๆ นะครับ พอดีใจร้อนไม่ได้เปลี่ยนให้สื่อความหมาย
โค้ดเก่าเป็นการเลือก Line ก่อน แล้วพอกรอก barcode ก็ดึงข้อมูลอัตโนมัติมาแบบ Auto Fill แล้ว focus ไป Textbox ต่อไป แต่อยากได้แบบไม่ต้องเลือก Line ครับ
Code (PHP)
<?
session_start();
if($_SESSION["Username"] == "")
{
header("location:AjaxPHPLoginForm1.php?error=Login please.");
exit();
}
?>
<html>
<head>
<title>ThaiCreate.Com PHP & MySQL Tutorial</title>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
<script language="JavaScript">
var HttPRequest = false;
function doCallAjax(fProductID,fProductName,fPrice) {
HttPRequest = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
HttPRequest = new XMLHttpRequest();
if (HttPRequest.overrideMimeType) {
HttPRequest.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try {
HttPRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
HttPRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!HttPRequest) {
alert('Cannot create XMLHTTP instance');
return false;
}
var url = 'AjaxGetFill.php';
var pmeters = "tProductID=" + encodeURI( document.getElementById(fProductID).value);
HttPRequest.open('POST',url,true);
HttPRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
HttPRequest.setRequestHeader("Content-length", pmeters.length);
HttPRequest.setRequestHeader("Connection", "close");
HttPRequest.send(pmeters);
HttPRequest.onreadystatechange = function()
{
//if(HttPRequest.readyState == 3) // Loading Request
//{
//document.getElementById(fProductName).innerHTML = "..";
//}
if(HttPRequest.readyState == 4) // Return Request
{
var myProduct = HttPRequest.responseText;
if(myProduct != "")
{
var myArr = myProduct.split("|");
document.getElementById(fProductName).value = myArr[0];
document.getElementById(fPrice).value = myArr[1];
}
}
}
}
</script>
<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){
if (event.keyCode == 13){
var obj=document.getElementById(objId);
if (obj){
obj.focus();
}
}
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
.style1 {color: #0000FF}
.style2 { font-size: 24px;
font-weight: bold;
color: #006600;
}
.style3 {
color: #FF3300;
font-weight: bold;
}
.style5 {color: #FF3300}
.style7 {
font-size: 18px;
color: #FF00FF;
}
-->
</style>
</head>
<body>
<form action="phpMySQLAddSave.php" name="frmMain" method="post" id="form1" name="form1">
<p align="center"><span class="style2">:: Add Products Order ::</span></p>
<table width="50%" border="0" align="center">
<tr>
<td width="31%" align="right"><span class="style3">Select Line : </span></td>
<td width="22%"><select name="menu1" onChange="MM_jumpMenu('parent',this,0)">
<?
for($i=1;$i<=50;$i++)
{
if($_GET["Line"] == $i)
{
$sel = "selected";
}
else
{
$sel = "";
}
?>
<option value="<?=$_SERVER["PHP_SELF"];?>?Line=<?=$i;?>&&txtUser=<? echo $txtUser;?>" <?=$sel;?>>
<?=$i;?>
</option>
<?
}
?>
</select></td>
<td width="47%"><strong><span class="style5">User Name:</span> <span class="style7"><? echo $txtUser; ?> <a href="logout.php"><LOGOUT></a></span></strong></td>
</tr>
</table>
<table border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000">
<tr>
<th width="177"><span class="style1">:: Barcode ::</span></th>
<th width="197" align="center"><span class="style1">:: Serial Number ::</span></th>
<th width="420" align="center"><span class="style1">:: Product Name ::</span></th>
<th width="247" align="center"><span class="style1">:: Date ::</span></th>
</tr>
<?
$line = $_GET["Line"];
if($line == 0){$line=1;}
for($i=1;$i<=$line;$i++)
{
?>
<tr>
<td align="center"><input type="text" name="txtCustomerID<?=$i;?>" onChange="JavaScript:doCallAjax('txtCustomerID<?=$i;?>','txtName<?=$i;?>','txtEmail<?=$i;?>');" onKeyDown="setNextFocus('txtCustomerID<?=$i+1;?>');"></td>
<td align="center"><input type="text" name="txtName<?=$i;?>"></td>
<td align="center"><input name="txtEmail<?=$i;?>" type="text" size="70"><input name="txtStatus<?=$i;?>" type="hidden" value="2" ></td>
<td align="center"><input type="text" name="txtDate<?=$i;?>" value="<? echo date("d-m-Y"); ?>"><input type="hidden" name="txtUser<?=$i;?>" value="<? echo $txtUser; ?>"></td>
</tr>
<?
}
?>
</table>
<div align="center"><br>
<input type="submit" name="submit" value="Save">
<input type="hidden" name="hdnLine" value="<?=$i;?>">
</div>
</form>
</body>
</html>
|
|
|
|
|
Date :
2012-10-02 16:32:53 |
By :
pook039 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ผมเห็นคุณถามหลายกระทู้แล้วน่ะครับ ตัวอย่างที่คุณโพส ๆ มามันก็สามารถ apply ได้ไม่ยากครับ
|
|
|
|
|
Date :
2012-10-03 09:31:47 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|