|
|
|
รบกวนด้วยครับ ผมต้องการ active page when search or edit |
|
|
|
|
|
|
|
Code (PHP)
<h1>Stationary Stock System</h1>
<ol id="toc">
<li><a href="#showitem"><span>Show Item</span></a></li>
<li><a href="#alert"><span>Minimum</span></a></li>
<li><a href="#invoice"><span>Invoice</span></a></li>
<li><a href="#search"><span>Search</span></a></li>
<li><a href="#bring"><span>Bring</span></a></li>
<li><a href="#addpro"><span>Add Product</span></a></li>
<li><a href="#update"><span>Recieve</span></a></li>
<li><a href="#report"><span>Report</span></a></li>
<li><a href="#export"><span>Export</span></a></li>
<li><a href="index.php"><span>Logout</span></a></li>
<div align = "right">
<?php
$a=$_SESSION['SESS_MEMBER_ID'];
$sql= mysql_query("select fname from user where id = '$a'");
while($row = mysql_fetch_array($sql)){
echo '<h4> Welcome '.$row['fname'].'</h4>';
}
?>
</div>
</ol>
<div class="content" id="showitem">
<?php
include("db.php");
if($_POST["hdnCmd"] == "Update")
{
$strSQL = "UPDATE inventory SET item = '".$_POST["txtedititem"]."', supplier = '".$_POST["txteditsup"]."', qtyleft = '".$_POST["txteditqty"]."', unit = '".$_POST["txteditunit"]."'";
$strSQL .="WHERE id = '".$_POST["hdnEditID"]."' ";
$objQuery = mysql_query($strSQL);
}
?>
<form name="frmMain" method="post" action="<?php echo $_SERVER["PHP_SELF"];?>">
<input type="hidden" name="hdnCmd" value="">
<br><br>
<table width="100%">
<tr class="head">
<th>No</th>
<th>Item</th>
<th>Quantity</th>
<th>Unit</th>
<th>Supplier</th>
<th>Edit</th>
<?php
if($a == 3){ ?>
<th>Delete</th>
<?php } ?>
</tr>
<?php
$sql=mysql_query("select * from inventory order by item");
$i=1;
while($row=mysql_fetch_array($sql))
{
$id=$row['id'];
$item=$row['item'];
$qty=$row['qtyleft'];
$unit=$row['unit'];
$sup=$row['supplier'];
if($row["id"] == $_GET["ID"] and $_GET["Action"] == "Edit")
{ ?>
<tr>
<td><div align="center">
<?php echo $i;?>
<input type="hidden" name="hdnEditID" size="5" value="<?php echo $id;?>">
</div>
</td>
<td>
<input type="text" name="txtedititem" size="100" value="<?php echo $item;?>">
</td>
<td>
<input type="text" name="txteditqty" size="5" value="<?php echo $qty;?>">
</td>
<td>
<input type="text" name="txteditunit" size="5" value="<?php echo $unit;?>">
</td>
<td>
<input type="text" name="txteditsup" size="50" value="<?php echo $sup;?>">
</td>
<td colspan="2" align="right"><div align="center">
<input name="btnAdd" type="button" id="btnUpdate" value="Update" OnClick="frmMain.hdnCmd.value='Update';frmMain.submit();">
<input name="btnAdd" type="button" id="btnCancel" value="Cancel" OnClick="window.location='<?php echo $_SERVER["PHP_SELF"];?>';">
</div>
</td>
</tr>
<?php }
if($i%2) { ?>
<tr id="<?php echo $id; ?>" class="edit_tr">
<?php } else { ?>
<tr id="<?php echo $id; ?>" bgcolor="#f2f2f2" class="edit_tr">
<?php } ?>
<td>
<span class="text"><?php echo $i; ?></span>
</td>
<td>
<span class="text"><?php echo $item; ?></span>
</td>
<td>
<span class="text"><?php echo $qty; ?></span>
</td>
<td>
<span class="text"><?php echo $unit; ?></span>
</td>
<td>
<span class="text"><?php echo $sup; ?></span>
</td>
<td>
<span class="text"><a href="<?php echo $_SERVER["PHP_SELF"];?>?Action=Edit&ID=<?php echo $row["id"];?>"><img src="/inventory/images/edit.png" /></a></span>
</td>
<?php
if ($a == 3) { ?>
<td>
<span class="text"><a href="delete.php?id=<?php echo $row["id"];?>"><img src="/inventory/images/del.png" /></a></span>
</td>
<?php } ?>
</tr>
<?php
$i++;
}
?>
</table>
<br />
</div>
<div class="content" id="invoice">
<?php
include("db.php");
if($_POST["hdnCmd"] == "Update")
{
$strSQL = "UPDATE receive SET inv = '".$_POST["txteditinv"]."'";
$strSQL .="WHERE id = '".$_POST["hdnEditID"]."' ";
$objQuery = mysql_query($strSQL);
}
?>
<form name="frmMain" method="post" action="<?php echo $_SERVER["PHP_SELF"];?>">
<input type="hidden" name="hdnCmd" value="">
<br><br>
<table width="100%">
<tr class="head">
<th>No</th>
<th>Item</th>
<th>Quantity</th>
<th>Invoice</th>
<th>Receive Date</th>
<th>Edit</th>
<?php
if($a == 3){ ?>
<th>Delete</th>
<?php } ?>
</tr>
<?php
$sql=mysql_query("select receive.id, inventory.item, receive.qty, receive.inv, receive.r_date from inventory,receive where receive.item = inventory.id order by receive.r_date desc, receive.inv , inventory.item");
$i=1;
while($row=mysql_fetch_array($sql))
{
$id=$row['id'];
$item=$row['item'];
$qty=$row['qty'];
$inv=$row['inv'];
$rdate=$row['r_date'];
if($row["id"] == $_GET["ID"] and $_GET["Action"] == "Edit")
{ ?>
<tr>
<td><div align="center">
<?php echo $i;?>
<input type="hidden" name="hdnEditID" size="5" value="<?php echo $id;?>">
</div>
</td>
<td>
<?php echo $item;?>
</td>
<td>
<?php echo $qty;?>
</td>
<td>
<input type="text" name="txteditinv" size="5" value="<?php echo $inv;?>">
</td>
<td>
<?php echo $rdate;?>
</td>
<td colspan="2" align="right"><div align="center">
<input name="btnAdd" type="button" id="btnUpdate" value="Update" OnClick="frmMain.hdnCmd.value='Update';frmMain.submit();">
<input name="btnAdd" type="button" id="btnCancel" value="Cancel" OnClick="window.location='<?php echo $_SERVER["PHP_SELF"];?>';">
</div>
</td>
</tr>
<?php }
if($i%2) { ?>
<tr id="<?php echo $id; ?>" class="edit_tr">
<?php } else { ?>
<tr id="<?php echo $id; ?>" bgcolor="#f2f2f2" class="edit_tr">
<?php } ?>
<td>
<span class="text"><?php echo $i; ?></span>
</td>
<td>
<span class="text"><?php echo $item; ?></span>
</td>
<td>
<span class="text"><?php echo $qty; ?></span>
</td>
<td>
<span class="text"><?php echo $inv; ?></span>
</td>
<td>
<span class="text"><?php echo $rdate; ?></span>
</td>
<td>
<span class="text"><a href="<?php echo $_SERVER["PHP_SELF"];?>?Action=Edit&ID=<?php echo $row["id"];?>"><img src="/inventory/images/edit.png" /></a></span>
</td>
<?php
if ($a == 3) { ?>
<td>
<span class="text"><a href="delete.php?id=<?php echo $row["id"];?>"><img src="/inventory/images/del.png" /></a></span>
</td>
<?php } ?>
</tr>
<?php
$i++;
}
?>
</table>
<br />
</div>
<script src="activatables.js" type="text/javascript"></script>
<script type="text/javascript">
activatables('page', ['showitem', 'alert', 'invoice','search', 'bring', 'addpro', 'update', 'report', 'export']);
</script>
ผมออกแบบโค้ดประมาณนี้
โดยเมนูหลักจะเป็น tab ให้เลือกใช้งาน ตามความต้องการต่างๆ
ที่นี้ปัญหามีอยู่ว่า ถ้าผมใช้งาน Search Tab หรือ Update Tab
เวลาที่ป้อน Keyword ลงไป จากนั้นกด Submit หรือ กด Edit
มันจะไป default ที่ Tab แรกเสมอ (Show Item)
ผมต้องการให้มัน Active ที่ Tab นั้นๆ ผมต้องเพิ่มโค้ดหรือแก้ยังไงเอ่ย
รบกวนหน่อยครับ
Tag : - - - -
|
|
|
|
|
|
Date :
2017-01-11 10:48:55 |
By :
limberger |
View :
844 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ajax
-content, dataTable
-$.post
|
|
|
|
|
Date :
2017-01-13 15:15:49 |
By :
fossil31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|