|
 |
|
รบกวนดูโค้ดให้หน่อยคะ รบกวนดูโค้ดให้หน่อยคะ พอดีอยากทราบว่ากรณีที่ว่ามี old_code มากกว่า 1 ค่านะคะ |
|
 |
|
|
 |
 |
|
รบกวนดูโค้ดให้หน่อยคะ พอดีอยากทราบว่ากรณีที่ว่ามี old_code มากกว่า 1 ค่านะคะ ก็จะให้มันโชว์ข้อความว่า Grouping Codeนี้มี Code มากว่า 1 ตัวค่ะ โดยข้อความที่โชว์จะโชว์ตรงตารางแถวที่ 2 นะคะ ซึ่งตอนนี้สามารถโชว์ได้ 2 กรณีแล้วนะคะ และตรงช่อง textbox (old_code) ให้โชว์ว่า old_code มากกว่า 1 ค่า ขอบคุณค่ะ
test.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<title>test</title>
<style type="text/css">
<!--
.style1 {font-family: "Times New Roman", Times, serif}
-->
</style>
</head>
<script language="JavaScript">
var HttPRequest = false;
function doCallAjax(fCodeGroup,fMaoCode) {
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 = "code_group=" + encodeURI( document.getElementById(fCodeGroup).value);
HttPRequest.open('POST',url,true);
HttPRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=windows-874");
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 myCodegroup = HttPRequest.responseText;
if(myCodegroup != "")
{
var myArr = myCodegroup.split("|");
document.getElementById(fMaoCode).value = myArr[0];
document.getElementById("chklabel").innerHTML="Grouping Code นี้มี MaoCode แล้วค่ะ";
}else{
document.getElementById("chklabel").innerHTML="Grouping Codeนี้ยังไม่มี MaoCode ค่ะ";
return false;
}
}
}
}
</script>
<body>
<h1>Auto Fill Form</h1>
<form name="frmMain">
<table width="191" border="1">
<tr>
<th width="181">Group_Code </th>
</tr>
<tr>
<th>
<input type="text" name="code_group" id="code_group" onChange="JavaScript:doCallAjax('code_group','mao_code');"></th>
</tr>
<tr>
<th id="chklabel" > </th>
</tr>
<tr>
<th>
<input type="text" name="old_code" id="old_code" ></th>
</tr>
</table>
</form>
</body>
</html>
check.php
<?php
$strGroup= $_POST["code_group"];
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("mobiclubv2");
$strSQL = "SELECT distinct(C.code_group),Mc.old_code FROM Content C JOIN MaoContent Mc ON C.code=Mc.new_code WHERE code_group = '".$strGroup."' ";
$objQuery = mysql_query($strSQL) or die (mysql_error());
$objResult = mysql_fetch_array($objQuery);
if($objResult)
{
echo $objResult['old_code'];
}
mysql_close($objConnect);
?>
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2010-01-29 17:06:48 |
By :
ติ๊ก |
View :
735 |
Reply :
0 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
|
|

|
Load balance : Server 00
|