|
 |
|
รบกวนช่วยดู โค๊ดทีครับ ไม่ค่อยรู้เรื่อง javascript เลย ผมอยากเขียน code insert ข้อมูล ใน text filde ลง DB อะครับ แต่มันไม่มี ชื่อ text filde ผมเลย งงๆ อะครับ |
|
 |
|
|
 |
 |
|
จากโค๊ดตัวอย่างนี้อะครับ ผมอยากเขียน code insert ข้อมูล ใน text filde ลง DB อะครับ แต่มันไม่มี ชื่อ text filde ผมเลย งงๆ อะครับ ผมจะรับค่าใน text filde ได้ยังไงอะคับ ช่วยทีนะครับ ผมพยายามลองหลายวิธีแล้ว ไม่ได้จริงๆ ขอบคุณครับ
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com JavaScript Add/Remove Element</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<?
mysql_connect("localhost","root","1234");
mysql_select_db("e_book");
$strSQL = "SELECT * FROM contain";
$objQuery = mysql_query($strSQL);
?>
<script language="javascript">
function CreateSelectOption(ele)
{
var objSelect = document.getElementById(ele);
var Item = new Option("", "");
objSelect.options[objSelect.length] = Item;
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
var Item = new Option("<?=$objResult["id_magazine"];?>", "<?=$objResult["year"];?>");
objSelect.options[objSelect.length] = Item;
<?
}
?>
}
function CreateNewRow()
{
var intLine = parseInt(document.frmMain.hdnMaxLine.value);
intLine++;
var theTable = document.all.tbExp
var newRow = theTable.insertRow(theTable.rows.length)
newRow.id = newRow.uniqueID
var newCell
//*** Column 1 ***//
newCell = newRow.insertCell(0);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"5\" NAME=\"Column1_"+intLine+"\" ID=\"Column1_"+intLine+"\" VALUE=\"\"></center>";
//*** Column 2 ***//
newCell = newRow.insertCell(1);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"5\" NAME=\"Column2_"+intLine+"\" ID=\"Column2_"+intLine+"\" VALUE=\"\"></center>";
//*** Column 3 ***//
newCell = newRow.insertCell(2);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"5\" NAME=\"Column3_"+intLine+"\" ID=\"Column3_"+intLine+"\" VALUE=\"\"></center>";
//*** Column 4 ***//
newCell = newRow.insertCell(3);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"5\" NAME=\"Column4_"+intLine+"\" ID=\"Column4_"+intLine+"\" VALUE=\"\"></center>";
//*** Column 5 ***//
newCell = newRow.insertCell(4);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
newCell.innerHTML = "<center><SELECT NAME=\"Column5_"+intLine+"\" ID=\"Column5_"+intLine+"\"></SELECT></center>";
//*** Create Option ***//
CreateSelectOption("Column5_"+intLine)
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;
}
}
function GenerateRow()
{
var intRows = parseInt(document.frmMain.txtCount.value);
for(i=0;i<intRows;i++)
{
CreateNewRow();
}
}
</script>
<body>
<form name="frmMain" method="post" action="add_magazine_test.php">
<table width="863" border="1" id="tbExp">
<tr>
<td><div align="center">id_magazine</div></td>
<td><div align="center">years</div></td>
<td><div align="center">at </div></td>
<td><div align="center">month</div></td>
<td><div align="center">year</div></td>
</tr>
</table>
<input type="hidden" name="hdnMaxLine" value="0">
<input type="text" name="txtCount" value="1" size="5">
<input type="submit" name="button" id="button" value="Submit" />
<input name="btnCreate" type="button" id="btnCreate" value="+" onClick="GenerateRow();">
<input name="btnDel" type="button" id="btnDel" value="-" onClick="RemoveRow();">
</form>
</body>
</html>
Tag : PHP, MySQL, JavaScript

|
|
 |
 |
 |
 |
Date :
2011-08-30 23:48:44 |
By :
joethippy |
View :
731 |
Reply :
7 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่มีใครตอบเลย ฮือๆ
|
 |
 |
 |
 |
Date :
2011-08-31 00:01:32 |
By :
joethippy |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
รู้สึกจะเอามาจากบทเรียนไม่ใช่หรอครับ มันมีบอกอยู่แล้วหรือเปล่า
|
 |
 |
 |
 |
Date :
2011-08-31 00:01:57 |
By :
ikikkok |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ใช่ครับเอามาจากบทเรียน แต่มันไม่มีบอกอะครับ
|
 |
 |
 |
 |
Date :
2011-08-31 00:04:06 |
By :
joethippy |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
รบกวนพี่ ไกด์ไลน์ ให้ผมสักนิดได้ไหมอะครับ ผมไม่รู้ว่ารับค่าเอาลง DB ยังไงอะครับ
|
 |
 |
 |
 |
Date :
2011-08-31 00:25:16 |
By :
joethippy |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
<?
include ("../php/config.init.php");
$id_magazine = $_POST["Column1_"+intLine+""];
$years = $_POST["yeasr"];
$at = $_POST["at"];
$month = $_POST["month"];
$year = $_POST["year"];
$strSQL ="INSERT INTO contain(id_magazine, years, at, year) values('$id_magazine', '$years', '$at', '$month', '$year')";
mysql_db_query ($dbname ,"SET NAMES tis620");
$objQuery = mysql_query($strSQL);
echo $strSQL;
?>
ผมลองรับค่าแล้ว ลอง echo ดูค่าก็ไม่ถูกส่งมาอะครับ ช่วยทีนะครับ ขอบคุณครับ
|
 |
 |
 |
 |
Date :
2011-08-31 00:41:52 |
By :
joethippy |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณครับ พี่
|
 |
 |
 |
 |
Date :
2011-08-31 01:19:44 |
By :
joethippy |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|