Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > เพิ่ม Record ทำยังไงคะ ใน record ประกอบด้วย text box , combo box



 

เพิ่ม Record ทำยังไงคะ ใน record ประกอบด้วย text box , combo box

 



Topic : 059530



โพสกระทู้ ( 367 )
บทความ ( 0 )



สถานะออฟไลน์




test

จะให้มี ปุ่ม add เมื่อคลิก แล้วมันจะเพิ่ม record ให้
โดยใน record ก็จะเหมือน record ดังภาพนะคะ เพื่อให้กรอกรายละเอียด

และไม่ทราบว่า เว็บเก็บ ต้องให้ตัวแปรเป็น array ใช่ไม๊คะ

ทำยังไงอะคะ

มีตัวอย่างไหม



Tag : PHP, Ms Access







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2011-05-01 23:57:49 By : unzeen View : 1184 Reply : 4
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

Code (JavaScript)
<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","root");
mysql_select_db("mydatabase");
$strSQL = "SELECT * FROM customer";
$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["Name"];?>", "<?=$objResult["CustomerID"];?>"); 
		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><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;
		}	
	}	
</script>
<body>
<form name="frmMain" method="post">
<table width="445" border="1" id="tbExp">
  <tr>
    <td><div align="center">Column 1 </div></td>
    <td><div align="center">Column 2 </div></td>
    <td><div align="center">Column 3 </div></td>
    <td><div align="center">Column 4 </div></td>
    <td><div align="center">Column 5 </div></td>
  </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();">
</form>
</body>
</html>


Screenshot


Create new Option List Menu Firefox

Create new Option List Menu Chrome


createElement('select'); สร้าง Element ของ Select Option พร้อมกับ ดึงข้อมูลจาก MySQL Database ครับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-05-02 07:30:08 By : webmaster
 


 

No. 2



โพสกระทู้ ( 367 )
บทความ ( 0 )



สถานะออฟไลน์


ทำไม ข้อมูลที่ เป็น ชื่อยาวๆ มันดึงมาใส่ combo box ไม่ได้อะคะ

มันกลายเป็นว่า เวลากด + มันไม่ขึ้นอะไรให้เลย

แต่ข้อมูลที่ดึงมามันเยอะมากประมาณ สองหมื่อน

แต่ ถ้าเราเปลี่ยนฟิลด์ให้มันดึง code มัน มันดึงได้อะ งงมากๆๆคะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-05-02 10:29:36 By : unzeen
 

 

No. 3



โพสกระทู้ ( 367 )
บทความ ( 0 )



สถานะออฟไลน์


มีคำถามนึงคะ ตอนที่ Delete Row อะ จะให้ Delete เฉพาะ Row นั้น ๆ อะคะ

ะำะ

เราต้องทำยังไงอะคะ

Code (PHP)
<?php
	include("../../includes/config.php");
	include(TEMPLATES_PATH."tpl_header.php");

$lineitem_unit		= array("แผ่น","ชีต","กล่อง");
$type_pcs			= array("แผ่นตัด","แผ่นเต็ม");

$sSql_productTiles = "select productName_en,material_code from tbl_spt_productTiles";
$result_productTiles = odbc_exec($link,$sSql_productTiles);


?>
<script language="javascript">

	function CreateSelectOption(ele,selecttype,intLine)
	{
		var objSelect = document.getElementById(ele);
		var Item = new Option("", ""); 
		objSelect.options[objSelect.length] = Item;
		if(selecttype=="productTiles"+intLine){
		<?
		while($objResult_productTiles = odbc_fetch_array($result_productTiles))
		{
		?>
		var Item = new Option("<? echo $objResult_productTiles["material_code"];?>", "<? echo $objResult_productTiles["material_code"];?>"); 
		objSelect.options[objSelect.length] = Item;
		<?
		}
		?>
		}else if(selecttype=="unit"+intLine){
		//alert(selecttype);
		<?php
		foreach($lineitem_unit as $key => $value){
		?>
		var Item = new Option("<? echo $value;?>", "<? echo $value;?>"); 
		objSelect.options[objSelect.length] = Item;
		<?php
		}
		?>
		}else if(selecttype=="typepcs"+intLine){
		//alert(selecttype);
		<?php
		foreach($type_pcs as $key => $value){
		?>
		var Item = new Option("<? echo $value;?>", "<? echo $value;?>"); 
		objSelect.options[objSelect.length] = Item;
		<?php
		}
		?>
		}
		
	}

	function CreateNewRow()
	{
		var intLine = parseInt(document.frm_request.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=\"txtProductName1"+intLine+"\" ID=\"txtProductName1"+intLine+"\"></SELECT></center>";
		
		//*** Create Option ***//
		CreateSelectOption("txtProductName1"+intLine,"productTiles"+intLine,intLine)

		//*** Column 2 ***//
		newCell = newRow.insertCell(1);
		newCell.id = newCell.uniqueID;
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"20\" NAME=\"txtProductID1"+intLine+"\" ID=\"txtProductID1"+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=\"1\" NAME=\"size1"+intLine+"\" ID=\"size1"+intLine+"\"  VALUE=\"\"> X <INPUT TYPE=\"TEXT\" SIZE=\"1\" NAME=\"size2"+intLine+"\" ID=\"size2"+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=\"size2"+intLine+"\"  ID=\"size2"+intLine+"\" VALUE=\"\"></center>";
		
		//*** Column 5 ***//
		newCell = newRow.insertCell(4);
		newCell.id = newCell.uniqueID;
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<center><SELECT NAME=\"unit"+intLine+"\" ID=\"unit"+intLine+"\"></SELECT></center>";
		
		//*** Create Option ***//
		CreateSelectOption("unit"+intLine,"unit"+intLine,intLine)
		
		//*** Column 6 ***//
		newCell = newRow.insertCell(5);
		newCell.id = newCell.uniqueID;
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<center><SELECT NAME=\"typepcs"+intLine+"\" ID=\"typepcs"+intLine+"\"></SELECT></center>";
		
		//*** Create Option ***//
		CreateSelectOption("typepcs"+intLine,"typepcs"+intLine,intLine)
		
		//*** Column 7 ***//
		newCell = newRow.insertCell(6);
		newCell.id = newCell.uniqueID;
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"1\" NAME=\"size_subpcs1"+intLine+"\" ID=\"size_subpcs1"+intLine+"\"  VALUE=\"\"> X <INPUT TYPE=\"TEXT\" SIZE=\"1\" NAME=\"size_subpcs2"+intLine+"\" ID=\"size_subpcs2"+intLine+"\"  VALUE=\"\"></center>";
		
		//*** Column 8 ***//
		newCell = newRow.insertCell(7);
		newCell.id = newCell.uniqueID;
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"5\" NAME=\"priceperunit"+intLine+"\" ID=\"priceperunit"+intLine+"\"  VALUE=\"\"></center>";

		//*** Column 9 ***//
		newCell = newRow.insertCell(8);
		newCell.id = newCell.uniqueID;
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"5\" NAME=\"pricetotal"+intLine+"\" ID=\"pricetotal"+intLine+"\"  VALUE=\"\"></center>";


		//*** Column 9 ***//
		newCell = newRow.insertCell(9);
		newCell.id = newCell.uniqueID;
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"15\" NAME=\"remark"+intLine+"\" ID=\"remark"+intLine+"\"  VALUE=\"\"></center>";

		newCell = newRow.insertCell(10);
		newCell.id = newCell.uniqueID;
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<center><input name=\"btnDel\" type=\"button\" id=\"btnDel\" value=\"-\" onClick=\"RemoveRow();\"></center>";
		
		document.frm_request.hdnMaxLine.value = intLine;
	}
	
	function RemoveRow()
	{
		intLine = parseInt(document.frm_request.hdnMaxLine.value);
		if(parseInt(intLine) > 0)
		{
			if(confirm('คุณต้องการลบแถวนี้?')){
				theTable = document.getElementById("tbExp");				
				theTableBody = theTable.tBodies[0];
				theTableBody.deleteRow(intLine);
				intLine--;
				document.frm_request.hdnMaxLine.value = intLine;
			}
		}	
	}	
</script>
<body>
<form name="frm_request" method="post">
<table width="1000px" border="1" id="tbExp">
  <tr>
    <th>ชื่อกระเบื้อง</th>
	<th>รหัสกระเบื้อง</th>
	<th>ขนาด</th>
	<th>จำนวน</th>
	<th>หน่วย</th>
	<th>ประเภทแผ่น</th>
	<th>ขนาดแผ่นตัด</th>
	<th>ราคา/หน่วย</th>
	<th>ราคารวม</th>
	<th>หมายเหตุ</th>
	<th></th>
  </tr>
</table>
<input type="hidden" name="hdnMaxLine" value="0">
<input name="btnAdd" type="button" id="btnAdd" value="+" onClick="CreateNewRow();">

</form>
</body>
</html>

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-05-02 12:15:19 By : unzeen
 


 

No. 4



โพสกระทู้ ( 11,835 )
บทความ ( 10 )

สมาชิกที่ใส่เสื้อไทยครีเอท Hall of Fame 2012

สถานะออฟไลน์


Simple add/delete table row with jQuery by PlaKriM
เผื่อช่วยได้
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-05-02 19:17:34 By : PlaKriM
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : เพิ่ม Record ทำยังไงคะ ใน record ประกอบด้วย text box , combo box
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 00
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่