|
|
|
PHP เอาโค้ด java เกี่ยวกับ การ autosuggest มาใช้ แล้วทำให้ เวลากด enter ไม่ไปอ่าครับ |
|
|
|
|
|
|
|
พอดีว่า ผมเอาโค้ด java เกี่ยวกับ การ autosuggest มาใช้ แล้วทำให้ เวลากด enter ไม่ไปอ่าครับ ต้องกด button submit อย่างเด่ว
ซึ่งหากไม่มีโค้ด java ในส่วน ของ autosuggest ก็จะสามารถ กดenter ได้ตาม ปกติอ่าครับ
รบกวน พอมีใคร ที่สามารถแก้ไข ให้สามารถ กดenter ได้บ้างอ่าครับ
ขอบคุณล่วงหน้านะครับ
Code (PHP)
<html>
<head>
<title>store engineering</title>
<script type="text/javascript" src="js/bsn.AutoSuggest_c_2.0.js"></script>
<link rel="stylesheet" href="css/autosuggest_inquisitor.css" type="text/css" media="screen" charset="utf-8" />
<style type="text/css">
body {
font-family: Lucida Grande, Arial, sans-serif;
font-size: 10px;
text-align: center;
margin: 0;
padding: 0;
}
table
{
border: 1px;
background-color: #999;
font-size: 10px;
}
tr
{
vertical-align: top;
}
th
{
text-align: left;
background-color: #ccc;
}
th,
td
{
padding: 2px;
font-family: Lucida Grande, Arial, sans-serif;
font-size: 1.2em;
}
td
{
background-color: #fff;
}
a {
font-weight: bold;
text-decoration: none;
color: #f30;
}
a:hover {
color: #fff;
background-color: #f30;
}
#wrapper {
width: 600px;
margin: 10px auto;
text-align: left;
}
#content {
font-size: 1.2em;
line-height: 1.8em;
}
#content h1 {
font-size: 1.6em;
border-bottom: 1px solid #ccc;
padding: 5px 0 5px 0;
}
#content h2 {
font-size: 1.2em;
margin-top: 3em;
}
label
{
font-weight: bold;
}
</style>
</head>
<body>
<form name="form1" method="get" action="<?=$_SERVER['SCRIPT_NAME'];?>" onsubmit="return clicksearch();">
<p> </p>
<table border="0" cellspacing="0" cellpadding="0" width="700" align="center">
<tr>
<td><h5 class="style1">ค้นหาข้อมูล:</h5></td>
<td><select name="group">
<option value="" selected="selected">เลือกกลุ่ม</option>
<option value="ES">ES</option>
<option value="FC">FC</option>
<option value="FH">FH</option>
<option value="FR">FR</option>
<option value="FS">FS</option>
<option value="GS">GS</option>
<option value="LG">LG</option>
<option value="P1">P1</option>
<option value="BC">BC</option>
<option value="PE">PE</option>
<option value="PK">PK</option>
<option value="SC">SC</option>
<option value="SH">SH</option>
<option value="ST">ST</option>
<option value="TF">TF</option>
<option value="VC">VC</option>
<option value="WT">WT</option>
<option value="WUM">WUM</option>
<option value="WES">WES</option>
<option value="WET">WET</option>
<option value="WAE">WAE</option>
<option value="WSG">WSG</option>
</select></td>
<td><input id="search" type="text" name="search" maxlength="50" style="width: 300px"></td>
<td><span class="style1"><h5>Status:</h5></span></td>
<td><select name="listStatus">
<option value="">-----------------------------------------------------------</option>
<option value="Status normaly">Status normaly</option>
<option value="Old part or fake part and need new part">Old part or fake part and need new part</option>
<option value="Old part or fake part but not need to order">Old part or fake part but not need to order</option>
<option value="Need to be write-off for this part">Need to be write-off for this part</option>
<option value="Don't have this part and no need to order">Don't have this part and no need to order</option>
<option value="Already write-off but code still on Oracle">Already write-off but code still on Oracle</option>
</select></td>
<td><input type="submit" name="Submit" value="ค้นหา"></td>
</tr></table></form>
<script type="text/javascript">
var options = {
script:"autosearch.php?json=true&",
varname:"input",
json:true,
callback: function (obj) { document.getElementById('testid').value = obj.id; }
};
var as_json = new AutoSuggest('testinput', options);
var options_xml = {
script:"autosearch.php?",
varname:"input"
};
var as_xml = new AutoSuggest('search', options_xml);
</script>
<?php
$key=$_GET["group"];
$key1=$_GET["txtKeyword"];
if($key1==""){
$key1="";
}
include("dbconn.inc.php");
include("inc/paging.inc.php");
$current_page = 1;
if(isset($_GET['page'])) {
$current_page = $_GET['page'];
}
$rows_per_page = 10;
$start_row = paging_start_row($current_page, $rows_per_page);
$hostname_connection = "localhost";
$database_connection = "storeengineering";
//$database_connection = "storeengineering";
$username_connection = "root";
$password_connection = "1234";
$searchValue = "$search";
$group=$_GET['group'];
if (isset($search)){
$searchsTmp = explode(" ", $searchValue);
$searchs = array();
foreach($searchsTmp as $value){
if(!empty($value)){
$searchs[] = "(UPPER(CONCAT_WS(' ',code, description)) LIKE UPPER('%{$value}%'))";
}
}
$search_sql = "";
if(!empty($searchs)) $search_sql = "(".implode(" AND ", $searchs).") AND ";
$connection = mysql_pconnect($hostname_connection, $username_connection, $password_connection) or trigger_error(mysql_error(),E_USER_ERROR); mysql_query("SET NAMES UTF8") ;
mysql_select_db($database_connection, $connection);
$sql = "select SQL_CALC_FOUND_ROWS * from tb_inven where {$search_sql} code LIKE '{$group}%' ORDER by id_inven LIMIT $start_row, $rows_per_page";
#$sql = "SELECT SQL_CALC_FOUND_ROWS *
# FROM machine_table where machineID LIKE '%$key1%' or description LIKE '%$key1%' or machineID LIKE '$key%'
# LIMIT $start_row, $rows_per_page;";
$result = mysql_query($sql);
$found_rows = mysql_query("SELECT FOUND_ROWS();");
$total_rows = mysql_result($found_rows, 0, 0);
if(mysql_num_rows($result) == 0) {
echo "<p align=center>ไม่พบสิ่งนี้</p>
</body></html>";
exit;
}
?>
<table width=700 cellpadding=7 cellspacing=0 bgcolor=whitesmoke align=center>
<?php
$page_range = 5;
$qry_str = "group=$group&search=$value&listStatus=$listStatus";
$total_pages = paging_total_pages($total_rows, $rows_per_page);
$pagenum = paging_pagenum($current_page, $total_pages,$page_range, $qry_str);
echo "<tr bgcolor=white>
<td colspan=3 align=center>";
echo "หน้า: " . $pagenum;
echo "</td></tr>";
?>
<?php
while($data = mysql_fetch_array($result)) {
echo "<tr>
<td style=\"border-bottom: dotted 1px gray;\">
<b>» {$data['code']}</b>
</td>
<td style=\"border-bottom: dotted 1px gray;\">
<b>» {$data['location']}</b>
</td>
<td style=\"border-bottom: dotted 1px gray;\">
<b>» {$data['description']}</b>
</td>
</tr>";
}
echo "<tr bgcolor=white>
<td colspan=3 align=center>";
echo "หน้า: " . $pagenum;
echo "</td></tr>";
}
?>
</table>
</body>
</html>
Tag : PHP, MySQL, HTML/CSS, JavaScript, CakePHP
|
|
|
|
|
|
Date :
2011-03-13 17:41:05 |
By :
pae |
View :
853 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
โค้ดส่วนเนี่ยอ่าครับ ที่ทำให้ enter ไม่ไปสักที
Code (PHP)
<script type="text/javascript">
var options = {
script:"autosearch.php?json=true&",
varname:"input",
json:true,
callback: function (obj) { document.getElementById('testid').value = obj.id; }
};
var as_json = new AutoSuggest('testinput', options);
var options_xml = {
script:"autosearch.php?",
varname:"input"
};
var as_xml = new AutoSuggest('search', options_xml);
</script>
|
|
|
|
|
Date :
2011-03-13 17:42:33 |
By :
pae |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|