|
|
|
php กำหนด ค่าเริ่มต้นของแถวให้เท่ากับ 5 แถว ต้องทำไงอ้ะค้ะ... |
|
|
|
|
|
|
|
ถ้าต้องการกำหนด ค่าเริ่มต้นของแถวให้เท่ากับ 5 แถว ต้องทำไงอ้ะค้ะ
Code (PHP)
<? session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>บันทึกใบสั่งซื้อรถ</title>
</head>
</html>
<?
include"connect.php";
$strSQL = "SELECT * FROM user u ,prefix p WHERE u.user_id = '".$_SESSION['user_id']."' AND u.prefix = p.prefix_id";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
$fullname = $objResult['prefix_name'].$objResult['fname']." ".$objResult['lname'];
?>
<script language="javascript">
function CreateNewRow()
{
var intLine = parseInt(document.frmMain.hdnMaxLine.value);
intLine++;
var theTable = document.getElementById("tbExp");
var newRow = theTable.insertRow(theTable.rows.length)
newRow.id = newRow.uniqueID
var newCell
//*** Column No ***//
newCell = newRow.insertCell(0);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
newCell.innerHTML = "<center>"+intLine+"</center>";
//*** Column type_id ***//
newCell = newRow.insertCell(1);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
//newCell.setAttribute("OnClick", "OpenPopup('"+intLine+"')");
newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" NAME=\"type_id[]\" SIZE=\"5\" ID=\"type_id"+intLine+"\" VALUE=\"...\" OnClick=\"OpenPopup('"+intLine+"')\"></center>";
//*** Column type_name ***//
newCell = newRow.insertCell(2);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" NAME=\"type_name[]\" ID=\"type_name"+intLine+"\" VALUE=\"\"></center>";
//*** Column color_name ***//
newCell = newRow.insertCell(3);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
//newCell.setAttribute("OnClick", "OpenPopup('"+intLine+"')");
newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" NAME=\"color_name[]\" ID=\"color_name"+intLine+"\" VALUE=\"...\" OnClick=\"OpenPopup2('"+intLine+"')\"></center>";
//*** Column unit ***//
newCell = newRow.insertCell(4);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" NAME=\"unit[]\" ID=\"unit"+intLine+"\" VALUE=\"คัน\"></center>"
//*** Column amount ***//
newCell = newRow.insertCell(5);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" NAME=\"amount[]\" ID=\"amount"+intLine+"\" VALUE=\"\" OnChange=\"chkNum(this);textsum("+intLine+");\" onfocus=\"textsum("+intLine+");\" onblur=\"textsum("+intLine+");\" onkeyup=\"textsum("+intLine+");\"></center>";
//*** Column price ***//
newCell = newRow.insertCell(6);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" NAME=\"price[]\" ID=\"price"+intLine+"\" VALUE=\"\" OnChange=\"chkNum(this);textsum("+intLine+");\" onfocus=\"textsum("+intLine+");\" onblur=\"textsum("+intLine+");\" onkeyup=\"textsum("+intLine+");\" ></center>";
document.frmMain.hdnMaxLine.value = intLine;
//*** Column total ***//
newCell = newRow.insertCell(7);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" NAME=\"total[]\" ID=\"total"+intLine+"\" VALUE=\"\" OnChange=\"chkNum(this);textsum("+intLine+");\" onfocus=\"textsum("+intLine+");\" onblur=\"textsum("+intLine+");\" onkeyup=\"textsum("+intLine+");\"></center>";
document.frmMain.hdnMaxLine.value = intLine;
}
function RemoveRow()
{
intLine = parseInt(document.frmMain.hdnMaxLine.value);
if(parseInt(intLine) > 0)
{
theTable = document.getElementById("tbExp");
theTableBody = theTable.tBodies[0];
theTableBody.deleteRow(intLine);
intLine--;
document.frmMain.hdnMaxLine.value = intLine;
}
}
</script>
<table width="778px" height="40" align="center" style="font-size:13px">
<tr>
<td>
<div align="left" style="font-size:13px;"><img src="image/Motorcycle.png" width="45" height="45" /><b>บันทึกใบสั่งซื้อรถ</b></div>
<hr />
</td></tr>
</table>
<body OnLoad="CreateNewRow(2);">
<form name="frmMain" method="post" action="save_frm_store.php">
<br />
<br />
<div align="center"> <input type="submit" name="submit" value=" บันทึก "></div>
<!--
<div align="right">
<a href="javascript:window.close()"><img src="image/exit.png" width="40" height="40" border="0" />
<font color="#003300" size="2"><b>ปิดหน้าต่าง</b></font>
</a>
</div>
-->
<table width="856" height="78" border="1" id="tbExp" cellpadding="0" cellspacing="0" style="font-size:13px; ">
<tr>
<th width="59"><div align="center">ลำดับ </div></th>
<th width="51"><div align="center">รหัส </div></th>
<th width="129"><div align="center">รายละเอียด </div></th>
<th width="104"><div align="center">สี </div></th>
<th width="89"><div align="center">หน่วย </div></th>
<th width="82"><div align="center">จำนวน</div></th>
<th width="151"><div align="center">ราคา:หน่วย (บาท)</div></th>
<th width="220"><div align="center">รวมเป็นเงิน (บาท)</div></th>
</tr>
</table>
<input type="hidden" name="hdnMaxLine" value="0" >
<input name="btnAdd" type="button" id="btnAdd" value="+" onClick="CreateNewRow();">
<input name="btnDel" type="button" id="btnDel" value="-" onClick="RemoveRow();">
<input type="submit" name="btnSubmit" value="บันทึกข้อมูล" />
</form>
</body>
</html>
Tag : PHP
|
|
|
|
|
|
Date :
2013-05-02 10:09:01 |
By :
lookpla26 |
View :
740 |
Reply :
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เอาแบบง่ายๆนะครับ
...
<script language="javascript">
CreateNewRow();
CreateNewRow();
CreateNewRow();
CreateNewRow();
CreateNewRow();
</script>
</body>
</html>
|
|
|
|
|
Date :
2013-05-02 10:16:59 |
By :
Naizan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แทรกก่อนแท็ก </body> นะครับ
|
|
|
|
|
Date :
2013-05-02 10:29:41 |
By :
Naizan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ได้เเล้ว...ขอบคุณค่ะ
|
|
|
|
|
Date :
2013-05-02 10:32:52 |
By :
lookpla26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|