|
|
|
insert data เข้า database จาก dynamic elements ไม่ได้ค่ะ |
|
|
|
|
|
|
|
submit ข้อมูลเข้า db ไม่ได้ค่ะ ลองทำแล้ว
ดูโค้ดจาก https://www.thaicreate.com/php/php-mysql-multiple-upload-file-to-mysql-not-array.html แล้วก็ยัง งงๆ อยู่
แล้วอีกอย่าง ทำไม function fncCreateSelectOption ถึงใช้กับคอลัมเหมือนใน function CreateSelectOption ไม่ได้คะ ทั้งๆที่ attribute มันเหมือนกัน
ช่วยหน่อยค่ะ T_T
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com JavaScript Add/Remove Element</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<?php
mysql_connect("xxx","root","xxx");
mysql_select_db("xxxx");
$strSQL = "SELECT * FROM member";
$objQuery = mysql_query($strSQL);
?>
<script language="javascript">
function CreateSelectOption(ele)
{
var objSelect = document.getElementById(ele);
var Item = new Option("", "");
objSelect.options[objSelect.length] = Item;
<?php
$objQuery = mysql_query($strSQL);
while($objResult = mysql_fetch_array($objQuery))
{
?>
var Item = new Option("<?php echo $objResult["Firstname"];?>",
"<?php echo $objResult["UserID"];?>");
objSelect.options[objSelect.length] = Item;
<?php
}
?>
}
function fncCreateSelectOption(ele)
{
var objSelect = ele;
var Item = new Option("Thailand", "TH");
objSelect.options[objSelect.length] = Item;
var Item = new Option("English", "EN");
objSelect.options[objSelect.length] = Item;
var Item = new Option("United States", "US");
objSelect.options[objSelect.length] = Item;
}
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 1 ***//
newCell = newRow.insertCell(0);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
newCell.innerHTML = "<center><SELECT NAME=\"txtTitle_"+intLine+"\" ID=\"txtTitle_"+intLine+"\"></SELECT></center>";
//*** Column 2 ***//
newCell = newRow.insertCell(1);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"15\" NAME=\"txtFname_"+intLine+"\" ID=\"txtFname_"+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=\"15\" NAME=\"txtLname_"+intLine+"\" ID=\"txtLname_"+intLine+"\" VALUE=\"\"></center>";
//*** Column 4 ***//
newCell = newRow.insertCell(3);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
newCell.innerHTML = "<center><SELECT NAME=\"txtRole_"+intLine+"\" ID=\"txtRole_"+intLine+"\"></SELECT></center>";
//*** Create Option ***//
CreateSelectOption("txtTitle_"+intLine)
fncCreateSelectOption("txtRole_"+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;
}
}
</script>
<body Onload="CreateNewRow();">
<form name="frmMain" method="post" action="upload_multiple.php">
<table width="445" border="1" id="tbExp">
<tr>
<td width="96"><div align="center">Title</div></td>
<td width="171"><div align="center">Firstname</div></td>
<td width="171"><div align="center">Lastname</div></td>
<td width="156"><div align="center">Status</div></td>
</tr>
</table>
<input type="hidden" name="hdnMaxLine" value="0">
<input name="btnAdd" type="button" id="btnAdd" value="add" onClick="CreateNewRow();">
<input name="btnDel" type="button" id="btnDel" value="delete" onClick="RemoveRow();">
</form>
<input type="submit" name="submitTeam" id="submitTeam" value="Submit">
</body>
</html>
Tag : PHP, Ms Access, HTML/CSS, JavaScript
|
|
|
|
|
|
Date :
2016-02-16 01:08:02 |
By :
um0000um |
View :
827 |
Reply :
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ครอบโค๊ดด้วย icon พิเศษ ขนขวา ช่องกรอกข้อความ ด้วยครับ ช่วยให้ก๊อปมาทดสอบง่าย หรืออ่านง่าย
|
|
|
|
|
Date :
2016-02-16 08:53:53 |
By :
Chaidhanan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองดูตัวนี้ครับ แก้ปัญหา Web Browser แล้ว
URL
|
|
|
|
|
Date :
2016-02-16 10:43:22 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127.</form>
128.<input type="submit" name="submitTeam" id="submitTeam" value="Submit">
สลับบันทัดกันหรือเปล่า
|
|
|
|
|
Date :
2016-02-16 11:28:09 |
By :
Chaidhanan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แก้แล้วค่ะ ลองรันมันใช้ได้กับ firefox ได้อยู่แล้ว
แต่งงตอนเก็บลง db ค่ะ ว่าสรุปเราต้องเอาคำไหนมาใช้เป็นตัวแปร
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com JavaScript Add/Remove Element</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<?php
mysql_connect("xxx","xxxx","xxxx");
mysql_select_db("xxx");
$strSQL = "SELECT * FROM member";
$objQuery = mysql_query($strSQL);
?>
<script language="javascript">
function CreateSelectOption(ele)
{
var objSelect = document.getElementById(ele);
var Item = new Option("", "");
objSelect.options[objSelect.length] = Item;
<?php
$objQuery = mysql_query($strSQL);
while($objResult = mysql_fetch_array($objQuery))
{
?>
var Item = new Option("<?php echo $objResult["Firstname"];?>",
"<?php echo $objResult["UserID"];?>");
objSelect.options[objSelect.length] = Item;
<?php
}
?>
}
function fncCreateSelectOption(ele)
{
var objSelect = ele;
var Item = new Option("Thailand", "TH");
objSelect.options[objSelect.length] = Item;
var Item = new Option("English", "EN");
objSelect.options[objSelect.length] = Item;
var Item = new Option("United States", "US");
objSelect.options[objSelect.length] = Item;
}
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 1 ***//
newCell = newRow.insertCell(0);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
newCell.innerHTML = "<center><SELECT NAME=\"txtTitle_"+intLine+"\" ID=\"txtTitle_"+intLine+"\"></SELECT></center>";
//*** Column 2 ***//
newCell = newRow.insertCell(1);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"15\" NAME=\"txtFname_"+intLine+"\" ID=\"txtFname_"+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=\"15\" NAME=\"txtLname_"+intLine+"\" ID=\"txtLname_"+intLine+"\" VALUE=\"\"></center>";
//*** Column 4 ***//
newCell = newRow.insertCell(3);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
newCell.innerHTML = "<center><SELECT NAME=\"txtRole_"+intLine+"\" ID=\"txtRole_"+intLine+"\"></SELECT></center>";
//*** Create Option ***//
CreateSelectOption("txtTitle_"+intLine)
CreateSelectOption("txtRole_"+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;
}
}
</script>
<body Onload="CreateNewRow();">
<form name="frmMain" method="post" action="upload_multiple.php">
<table width="445" border="1" id="tbExp">
<tr>
<td width="96"><div align="center">Title</div></td>
<td width="171"><div align="center">Firstname</div></td>
<td width="171"><div align="center">Lastname</div></td>
<td width="156"><div align="center">Status</div></td>
</tr>
</table>
<input type="hidden" name="hdnMaxLine" value="0">
<input name="btnAdd" type="button" id="btnAdd" value="add" onClick="CreateNewRow();">
<input name="btnDel" type="button" id="btnDel" value="delete" onClick="RemoveRow();">
<input type="submit" name="submitTeam" id="submitTeam" value="Submit">
</form>
</body>
</html>
ต้องแก้ตรงไหนคะ รบกวนด้วยค่ะ
Code (PHP)
mysql_connect("localhost","xxx","xxxx") or die (mysql_error());
mysql_select_db("edpex_db");
for($i=1;$i<=(int)($_POST["hdnMaxLine"]);$i++)
{
$strSQL = "INSERT INTO assessorteam";
$strSQL .="(teamTitle,teamFname,teamLname,teamRole)
VALUES ('".$_POST["txtTitle_".$i]."',
'".$_POST["txtFname_".$i]."'
'".$_POST["txtLname_".$i]."'
'".$_POST["txtRole_".$i]."')";
mysql_query($strSQL);
}
mysql_close();
|
|
|
|
|
Date :
2016-02-16 14:41:49 |
By :
um0000um |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|