ไม่สามารถแสดงข้อมูล Auto fill ได้ตามตัวอย่าง http://www.thaicreate.com/…/list-select-menu-auto-fill-text…
ขอสอบถามหน่อยครับ
ผมทำตามแบบที่ 2 link : https://www.thaicreate.com/…/list-select-menu-auto-fill-text…
แต่ข้อมูลไม่แสดงตามที่เลือกแบบ Auto แบบตัวอย่าง ผมตกหล่นตรงไหนครับ ดูใน Source ก็มี case แสดงข้อมูล
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com Tutorial</title>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<link href="default.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="select/docsupport/prism.css">
<link rel="stylesheet" href="select/chosen.css">
<style type="text/css" media="all">
/* fix rtl for demo */
.chosen-rtl .chosen-drop { left: 100px; }
</style>
</head>
<?php
mysql_connect("localhost","root","1234") or die(mysql_error());
mysql_select_db("asset");
?>
<script language="JavaScript">
function resutName(Asset)
{
switch(Asset)
{
<?php
$strSQL2 = "SELECT * FROM asset";
$objQuery2 = mysql_query($strSQL2);
while($objResult2 = mysql_fetch_array($objQuery2))
{
?>
case "<?php echo $objResult2["Asset"];?>":
form1.txtName1.value = "<?php echo $objResult2["AssetName"];?>";
break;
<?php
}
?>
default:
form1.txtName1.value = "";
}
}
</script>
<body>
<form name="form1" method="post" action="add_job2.php" onSubmit="JavaScript:return fncSubmit();">
<table width="800" border="0" align="center" cellpadding="0" cellspacing="7">
<tr bgcolor="#999999">
<td colspan="4"><div align="center">รายการ</div></td>
</tr>
<td>รหัสทรัพย์สิน</td>
<td width="28%"><select name="Asset" id="Asset" class="chosen-select" style="width:200px;" tabindex="2" OnChange="resutName(this.value);">
<option value="">== กรุณาเลือก ==</option>
<?
mysql_connect("localhost","root","1234");
mysql_select_db("asset");
mysql_query("SET NAMES tis620");
mysql_query("SET NAMES UTF8");
$strSQL ="select * from asset ORDER BY Asset ASC ";
$objQuery = mysql_query($strSQL);
while($objResuut = mysql_fetch_array($objQuery))
{
?>
<option value="<?php echo $objResuut["Asset"];?>"><?php echo $objResuut["Asset"];?></option>
<?php
}
?>
</select></td>
<td width="8%">รายละเอียด</td>
<td width="47%"><input name="txtName1" id="txtName1" type="text" disabled="disabled" value="" size="25"/></td>
</tr>
<td> </td>
<td colspan="3"><input type="submit" name="submit" value="บันทึก" />
<input type="reset" name="reset" value="ยกเลิก" /></td>
</tr>
</table>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
<script src="select/chosen.jquery.js" type="text/javascript"></script>
<script src="select/docsupport/prism.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
var config = {
'.chosen-select' : {},
'.chosen-select-deselect' : {allow_single_deselect:true},
'.chosen-select-no-single' : {disable_search_threshold:10},
'.chosen-select-no-results': {no_results_text:'Oops, nothing found!'},
'.chosen-select-width' : {width:"95%"}
}
for (var selector in config) {
$(selector).chosen(config[selector]);
}
</script>
</form>
</body>
</html>
<?php
mysql_close();
?>
Tag : PHP, MySQL
Date :
2017-03-06 11:10:21
By :
karurub
View :
845
Reply :
6
แก้ไขได้แล้วครับ
Code (PHP)
<script language="JavaScript">
function resutName(Asset)
{
switch(Asset)
{
<?php
$strSQL2 = "SELECT * FROM asset";
$objQuery2 = mysql_query($strSQL2);
while($objResult2 = mysql_fetch_array($objQuery2))
{
$AssetName = trim($objResult2["AssetName"]);
?>
case "<?php echo trim($objResult2["Asset"]);?>":
form1.txtName1.value = "<?php echo str_replace('"','',$AssetName);?>";
form1.txtBrance.value = "<?php echo trim($objResult2["Location"]);?>";
form1.txtFloor.value = "<?php echo trim($objResult2["Annotation"]);?>";
break;
<?php
}
?>
default:
form1.txtName1.value = "";
form1.txtBrance.value = "";
form1.txtFloor.value = "";
}
}
</script>
Date :
2017-03-08 00:51:36
By :
karurub
จัดไปครับ
Date :
2017-03-08 09:20:11
By :
mr.win
Load balance : Server 00