|
 |
|
Ajax Auto Fill Textbox (PHP+MySQL )ใช้ภาษาไทยไม่ได้ค่ะ ช่วยหน่อย |
|
 |
|
|
 |
 |
|
ในฐานข้อมูลเป็นแบบ tis-260 ค่ะ ต้องแก้โค้ดไงบ้างค่ะ ถึงจะใช้ภาษาไทยได้ โปรเจ็คใกล้ส่งแล้วช่วยหน่อยค่ะ
Code index.php
<script language="JavaScript">
var HttPRequest = false;
function doCallAjax(fstu_id,fstu_name,fstu_surname) {
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 = "tstu_id=" + encodeURI( document.getElementById(fstu_id).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(fstu_name).value = myArr[0];
document.getElementById(fstu_surname).value = myArr[1];
}
}
}
}
</script>
<body>
<form id="frmMain" name="frmMain" method="post" action="">
<input name="stu_id" type="text" id="stu_id" onkeyup="JavaScript:doCallAjax('stu_id','stu_name','stu_surname');"/>
<input name="stu_name" type="text" id="stu_name" />
<input name="stu_surname" type="text" id="stu_surname" />
</form>
</body>
Code AjaxGetFill.php
<?php
/
$strstu_id = trim($_POST["tstu_id"]);
$objConnect = mysql_connect("127.0.0.1","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("db_accident");
$strSQL = "SELECT * FROM tb_student WHERE stu_id like '".$strstu_id."%' ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$objResult = mysql_fetch_array($objQuery);
if($objResult)
{
echo $objResult["stu_name"]."|".$objResult["stu_surname"];
}
mysql_close($objConnect);
?>
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2009-11-29 00:02:22 |
By :
hmamui |
View :
2007 |
Reply :
6 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้ายังไม่ได้
คงต้องใช้
Code (PHP)
echo iconv('tis-620','utf-8', $content);
|
 |
 |
 |
 |
Date :
2009-11-29 00:44:55 |
By :
danya |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณมากๆๆๆๆๆๆๆๆๆๆๆๆๆๆๆๆน่ะค่ะ
ทำได้แล้วค่ะ หลังจากที่งมมาหลายวันค่ะ
|
 |
 |
 |
 |
Date :
2009-11-29 12:55:25 |
By :
hmamui |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มีปัญหาเหมือนคุณ mui เลยค่ะ อยากทราบว่าทำไงถึงได้ภาษาไทยหรอคะ
ที่คุณดุนยาตอบมา ต้องแทรกไว้ตรงไหนหรอค่ะ
ขอบคุณทุกคำตอบเลยค่ะ
|
 |
 |
 |
 |
Date :
2009-11-30 02:20:53 |
By :
elfying |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เอาไปใส่ ตัวแปรที่มีปัญหา ไม่แสดงไทยไงครับ
|
 |
 |
 |
 |
Date :
2009-11-30 03:10:41 |
By :
danya |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ยังไม่เข้าใจเลยค่ะ ช่วยอธิบายหน่อยได้ไหมค่ะ พอดีเพิ่งหัดทำด้วยค่ะ
ขอบคุณมากนะค่ะ
|
 |
 |
 |
 |
Date :
2009-11-30 20:30:00 |
By :
elfying |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|