|
|
|
สอบถามเรื่องการติ๊กcheckboxเลือกก่อนsearchแล้วให้แสดงข้อมูล |
|
|
|
|
|
|
|
ตามหัวข้อเลยครับคือผมทำเว็บStockแล้วมันมีหน้าsearch ที่เค้าต้องการให้สามารถsearchและeditได้ในหน้าเดียวกัน
ซึ่งข้อมูลมีหลายตารางผมทำให้มันsearchได้แล้วแต่มันแสดงออกมาทุกตารางเลยครับ ผมต้องการให้searchแล้วมีแค่ข้อมูลที่ต้องการโชว์ขึ้นมาโดยการใช้checkboxครับ
Code
<html>
<head>
<title>SEARCH PART</title>
<script type="text/javascript">
<!--
function showMe (it, box) {
var vis = (box.checked) ? "block" : "none";
document.getElementById(it).style.display = vis;
}
//-->
</script>
</head>
<body>
<form name = "search" method = "GET" action = "<?php echo $_SERVER['SCRIPT_NAME'];?>" onSubmit="return check(this)">
<table width = "800" border = "0" align = "center">PART NO.
<input name = "txtKeyword" type = "text" id = "txtKeyword" value = "<?php echo $_GET["txtKeyword"];?>">
<input type="submit" name="onclick" id="onclick" onClick="function showMe (it, box)" value="Search">
<br><br>
<input type="checkbox" name="modtype" value="value1" onClick="showMe('div1', this)" />Equipment
<input type="checkbox" name="modtype" value="value2" onClick="showMe('div2', this)" />Laptop
<input type="checkbox" name="modtype" value="value3" onClick="showMe('div3', this)" />Desktop
<input type="checkbox" name="modtype" value="value4" onClick="showMe('div4', this)" />Software
</table>
</form>
<form action = "updaterecord.php?partno=<?php echo $_GET["txtKeyword"];?>" name = "frmEdit" method = "POST" >
<?php
if($_GET["txtKeyword"] != "")
{
$objConnect = mysql_connect("localhost","root","123456") or die("Error Connect to Database");
$objDB = mysql_select_db("stock");
//Search By part no.
$strSQL = "SELECT * FROM tbl_part WHERE partno = '".$_GET["txtKeyword"]."' ";
//$strSQL = "SELECT * FROM tbl_part WHERE model = '".$_GET["txtKeyword"]."' ";
//$strSQL = "SELECT * FROM tbl_part WHERE type = '".$_GET["txtKeyword"]."' ";
//$strSQL = "SELECT * FROM tbl_part WHERE description = '".$_GET["txtKeyword"]."' ";
//$strSQL = "SELECT * FROM tbl_part WHERE sn = '".$_GET["txtKeyword"]."' ";
//$strSQL = "SELECT * FROM tbl_part WHERE po = '".$_GET["txtKeyword"]."' ";
//$strSQL = "SELECT * FROM tbl_part WHERE companame = '".$_GET["txtKeyword"]."' ";
//$strSQL = "SELECT * FROM tbl_part WHERE bin = '".$_GET["txtKeyword"]."' ";
//$strSQL = "SELECT * FROM tbl_part WHERE plant = '".$_GET["txtKeyword"]."' ";
//$strSQL = "SELECT * FROM tbl_part WHERE warranty = '".$_GET["txtKeyword"]."' ";
//$strSQL = "SELECT * FROM tbl_part WHERE status = '".$_GET["txtKeyword"]."' ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<p> </p>
<div id = "div1">
<table width = "1260" border = "1">
<tr>
<th width = "20" align = "center"> ID </th>
<th width = "120" align = "center"> Part No. </th>
<th width = "100" align = "center"> Model </th>
<th width = "80" align = "center"> Type </th>
<th width = "180" align = "center"> Description </th>
<th width = "100" align = "center"> Serial No. </th>
<th width = "100" align = "center"> PO No. </th>
<th width = "100" align = "center"> Supplier </th>
<th width = "100" align = "center"> Store bin </th>
<th width = "80" align = "center"> Plant </th>
<th width = "100" align = "center"> Warrant </th>
<th width = "100" align = "center"> Status </th>
</tr>
<?php
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr>
<td align = "center"><?php echo $objResult["id"];?></td>
<td align = "center"><input type = "text" name = "txtpartno" size = "15" value = "<?php echo $objResult["partno"];?>"></td>
<td align = "center"><input type = "text" name = "txtmodel" size = "10" value = "<?php echo $objResult["model"];?>"></td>
<td align = "center"><input type = "text" name = "txttype" size = "10" value = "<?php echo $objResult["type"];?>"></td>
<td align = "center"><input type = "text" name = "txtdescription" size = "25" value = "<?php echo $objResult["description"];?>"></td>
<td align = "center"><input type = "text" name = "txtsn" size = "10" value = "<?php echo $objResult["sn"];?>"></td>
<td align = "center"><input type = "text" name = "txtpo" size = "10" value = "<?php echo $objResult["po"];?>"></td>
<td align = "center"><input type = "text" name = "txtcompaname" size = "10" value = "<?php echo $objResult["companame"];?>"></td>
<td align = "center"><input type = "text" name = "txtbin" size = "10" value = "<?php echo $objResult["bin"];?>"></td>
<td align = "center"><input type = "text" name = "txtplant" size = "10" value = "<?php echo $objResult["plant"];?>"></td>
<td align = "center"><input type = "text" name = "txtwarranty" size = "10" value = "<?php echo $objResult["warranty"];?>"></td>
<td align = "center"><input type = "text" name = "txtstatus" size = "10" value = "<?php echo $objResult["status"];?>"></td>
</tr>
<?php
}
?>
</table>
<input type = "submit" name = "submit" value = "submit">
</div>
<?php
}
?>
</form>
<form action = "updatelaptop.php?comname=<?php echo $_GET["txtKeyword"];?>" name = "frmEdit" method = "POST" >
<?php
if($_GET["txtKeyword"] != "")
{
$objConnect = mysql_connect("localhost","root","123456") or die("Error Connect to Database");
$objDB = mysql_select_db("stock");
//Search By part no.
$strSQL = "SELECT * FROM tbl_laptop WHERE comname = '".$_GET["txtKeyword"]."' ";
//$strSQL = "SELECT * FROM tbl_laptop WHERE model = '".$_GET["txtKeyword"]."' ";
//$strSQL = "SELECT * FROM tbl_laptop WHERE tag = '".$_GET["txtKeyword"]."' ";
//$strSQL = "SELECT * FROM tbl_laptop WHERE site = '".$_GET["txtKeyword"]."' ";
//$strSQL = "SELECT * FROM tbl_laptop WHERE mouse = '".$_GET["txtKeyword"]."' ";
//$strSQL = "SELECT * FROM tbl_laptop WHERE adapter = '".$_GET["txtKeyword"]."' ";
//$strSQL = "SELECT * FROM tbl_laptop WHERE companame = '".$_GET["txtKeyword"]."' ";
//$strSQL = "SELECT * FROM tbl_laptop WHERE user = '".$_GET["txtKeyword"]."' ";
//$strSQL = "SELECT * FROM tbl_laptop WHERE position = '".$_GET["txtKeyword"]."' ";
//$strSQL = "SELECT * FROM tbl_laptop WHERE depart = '".$_GET["txtKeyword"]."' ";
//$strSQL = "SELECT * FROM tbl_laptop WHERE warranty = '".$_GET["txtKeyword"]."' ";
//$strSQL = "SELECT * FROM tbl_laptop WHERE status = '".$_GET["txtKeyword"]."' ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<p> </p>
<div id = "div2">
<table width = "1200" border = "1">
<tr>
<th width = "20" align = "left"> ID </th>
<th width = "50" align = "left"> Computer Name </th>
<th width = "50" align = "left"> Model </th>
<th width = "50" align = "left"> Tag </th>
<th width = "30" align = "left"> Site </th>
<th width = "50" align = "left"> Mosuse </th>
<th width = "50" align = "left"> Adapter </th>
<th width = "50" align = "left"> Supplier </th>
<th width = "30" align = "left"> User </th>
<th width = "50" align = "left"> Position </th>
<th width = "50" align = "left"> Department </th>
<th width = "50" align = "left"> Warranty </th>
<th width = "50" align = "left"> Status </th>
</tr>
<?php
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr>
<td align = "center"><?php echo $objResult["id"];?></td>
<td align = "center"><input type = "text" name = "txtcomname" size = "10" value = "<?php echo $objResult["comname"];?>"></td>
<td align = "center"><input type = "text" name = "txtmodel" size = "10" value = "<?php echo $objResult["model"];?>"></td>
<td align = "center"><input type = "text" name = "txttag" size = "10" value = "<?php echo $objResult["tag"];?>"></td>
<td align = "center"><input type = "text" name = "txtsite" size = "10" value = "<?php echo $objResult["site"];?>"></td>
<td align = "center"><input type = "text" name = "txtmouse" size = "10" value = "<?php echo $objResult["mouse"];?>"></td>
<td align = "center"><input type = "text" name = "txtadapter" size = "10" value = "<?php echo $objResult["adapter"];?>"></td>
<td align = "center"><input type = "text" name = "txtcompaname" size = "10" value = "<?php echo $objResult["companame"];?>"></td>
<td align = "center"><input type = "text" name = "txtuser" size = "10" value = "<?php echo $objResult["user"];?>"></td>
<td align = "center"><input type = "text" name = "txtposition" size = "10" value = "<?php echo $objResult["position"];?>"></td>
<td align = "center"><input type = "text" name = "txtdepart" size = "10" value = "<?php echo $objResult["depart"];?>"></td>
<td align = "center"><input type = "text" name = "txtwarranty" size = "10" value = "<?php echo $objResult["warranty"];?>"></td>
<td align = "center"><input type = "text" name = "txtstatus" size = "10" value = "<?php echo $objResult["status"];?>"></td>
</tr>
<?php
}
?>
</table>
<input type = "submit" name = "submit" value = "submit">
</div>
<?php
}
?>
</form>
</body>
</html>
Tag : MySQL, HTML/CSS, JavaScript, jQuery, Windows
|
|
|
|
|
|
Date :
2016-07-27 08:45:58 |
By :
choiyusung |
View :
1128 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองศึกษาเรื่อง $.Ajax $.Jquery การดึงข้อมูลมาแสดงโดยไม่รีเฟรชหน้า นะครับ ช่วยได้แน่นอน
|
|
|
|
|
Date :
2016-07-27 09:58:04 |
By :
Dragons_first |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|