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 > ช่วยด้วยครับ ทำตามลิงค์เรื่อง "Passing Popup to Main Page" แต่กดบวก(+) แถวไม่ขึ้นครับ หาจุด error ไม่เจอครับ



 

ช่วยด้วยครับ ทำตามลิงค์เรื่อง "Passing Popup to Main Page" แต่กดบวก(+) แถวไม่ขึ้นครับ หาจุด error ไม่เจอครับ

 



Topic : 109644



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



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




Code (PHP)
<html>
<head>
<title>ThaiCreate.Com</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<?
mysql_connect("localhost","root","sol#254");
mysql_select_db("db_cooperative") or die("Error Connect to Database");
$strSQL = "SELECT * FROM customer";
$objQuery = mysql_query($strSQL);
?>
<script language="javascript">

	function OpenPopup(intLine)
	{
		window.open('getData.php?Line='+intLine,'myPopup','width=650,height=200,toolbar=0, menubar=0,location=0,status=1,scrollbars=1,resizable=1,left=0,top=0');
	}

	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["CountryName"];?>", "<?=$objResult["CountryCode"];?>"); 
		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 No ***//
		newCell = newRow.insertCell(0);
		newCell.id = newCell.uniqueID;
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<center>"+intLine+"</center>";

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

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

		//*** Column Email ***//
		newCell = newRow.insertCell(3);
		newCell.id = newCell.uniqueID;
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"5\" NAME=\"txtEmail_"+intLine+"\" ID=\"txtEmail_"+intLine+"\"  VALUE=\"\"></center>";
		
		//*** Column Country Code ***//
		newCell = newRow.insertCell(4);
		newCell.id = newCell.uniqueID;
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<center><SELECT NAME=\"txtCountryCode_"+intLine+"\" ID=\"txtCountryCode_"+intLine+"\"></SELECT></center>";
		//*** Create Option ***//
		CreateSelectOption("txtCountryCode_"+intLine)
		
		//*** Column Budget ***//
		newCell = newRow.insertCell(5);
		newCell.id = newCell.uniqueID;
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"5\" NAME=\"txtBudget_"+intLine+"\"  ID=\"txtBudget_"+intLine+"\" VALUE=\"\"></center>";
	
			//*** Column Used ***//
		newCell = newRow.insertCell(6);
		newCell.id = newCell.uniqueID;
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"5\" NAME=\"txtUsed_"+intLine+"\"  ID=\"txtUsed_"+intLine+"\" VALUE=\"\"></center>";	

			//*** Column 7 ***//
		newCell = newRow.insertCell(7);
		newCell.id = newCell.uniqueID;
		newCell.setAttribute("className", "css-name");
		//newCell.setAttribute("OnClick", "OpenPopup('"+intLine+"')");
		newCell.innerHTML = "<center><INPUT TYPE=\"BUTTON\" NAME=\"btnPopup_"+intLine+"\"  ID=\"btnPopup_"+intLine+"\" VALUE=\"...\" OnClick=\"OpenPopup('"+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>
<body OnLoad="CreateNewRow();">
<form name="frmMain" method="post" action="readData.php">
<table width="600" border="1" id="tbExp">
  <tr>
    <td><div align="center">No </div></td>
    <td><div align="center">CustomerID </div></td>
    <td><div align="center">Name </div></td>
    <td><div align="center">Email </div></td>
    <td><div align="center">Country Code </div></td>
    <td><div align="center">Budget </div></td>
	<td><div align="center">Used </div></td>
	<td><div align="center">Popup </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();">
<input type="submit" name="btnSubmit" value="Submit">
</form>
</body>
</html>




Tag : PHP, HTML/CSS, JavaScript, jQuery







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2014-07-02 18:20:19 By : san.saleah View : 767 Reply : 6
 

 

No. 1



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



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


จากลิงค์นี้ครับ
Code
https://www.thaicreate.com/community/javascript-passing-send-data-popup-to-main-page.html


ตัวอย่างแรก ผ่าน รันได้ แต่ตัวอย่างที่สองไม่กดบวก แต่ไม่ขึ้นแถวครับ

32






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-07-02 18:25:45 By : san.saleah
 


 

No. 2



โพสกระทู้ ( 9,556 )
บทความ ( 2 )



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


ใช้ crome หรือเปล่าครับ ถ้าใช้

3 ขีด ขวาบน คลิกครับ เลือก เครื่องมือ เลือก นักพัฒนาฯ จะมี split เครื่องมือมาให้ คลิก ที่ console
รีเฟรช หน้าเพจ crome จะแสดงเออเร่อร์ให้เห็นครับ

น่าจะเป็นส่วน ของ php mysql คิวรี่ข้อความผิดพลาด ทำให้ โครงสร้าง javascript เสียครับ

ในส่วนของ createSelectOption
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-07-02 18:50:38 By : Chaidhanan
 

 

No. 3



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



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


code getData.php

ครับ ลอกมาทุกอย่างเปลี่ยนแค่ฐานข้อมูลกับ ตารางเท่านั้นครับ

Code (PHP)
<html>
<head>
<title>ThaiCreate.Com</title>
</head>
<script language="javascript">
	function selData(intLine,CustomerID,Name,Email,CountryCode,Budget,Used)
	{
		var sCustomerID = self.opener.document.getElementById("txtCustomerID_" +intLine);
		sCustomerID.value = CustomerID;

		var sName = self.opener.document.getElementById("txtName_" +intLine);
		sName.value = Name;

		var sEmail = self.opener.document.getElementById("txtEmail_" +intLine);
		sEmail.value = Email;

		var sCountryCode = self.opener.document.getElementById("txtCountryCode_" +intLine);
		sCountryCode.value = CountryCode;

		var sBudget = self.opener.document.getElementById("txtBudget_" +intLine);
		sBudget.value = Budget;

		var sUsed = self.opener.document.getElementById("txtUsed_" +intLine);
		sUsed.value = Used;

		window.close();
	}
</script>
<body>
<?
$objConnect = mysql_connect("localhost","root","sol#254") or die("Error Connect to Database");
$objDB = mysql_select_db("db_cooperative");
$strSQL = "SELECT * FROM customer";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<table width="600" border="1">
  <tr>
    <th width="91"> <div align="center">CustomerID </div></th>
    <th width="98"> <div align="center">Name </div></th>
    <th width="198"> <div align="center">Email </div></th>
    <th width="97"> <div align="center">CountryCode </div></th>
    <th width="59"> <div align="center">Budget </div></th>
    <th width="71"> <div align="center">Used </div></th>
  </tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
  <tr>
    <td><div align="center"><a href="#" OnClick="selData('<?=$_GET["Line"];?>' ,'<?=$objResult["CustomerID"];?>', '<?=$objResult["Name"];?>','<?=$objResult["Email"];?>' ,'<?=$objResult["CountryCode"];?>','<?=$objResult["Budget"];?>' ,'<?=$objResult["Used"];?>');">
	<?=$objResult["CustomerID"];?>
	</a></div></td>
    <td><?=$objResult["Name"];?></td>
    <td><?=$objResult["Email"];?></td>
    <td><div align="center"><?=$objResult["CountryCode"];?></div></td>
    <td align="right"><?=$objResult["Budget"];?></td>
    <td align="right"><?=$objResult["Used"];?></td>
  </tr>
<?
}
?>
</table>
<?
mysql_close($objConnect);
?>
</body>
</html>

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-07-02 19:09:32 By : san.saleah
 


 

No. 4



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



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


แก้ไขได้แล้วครับ field ในตารางคนละตัวครับ ขอบคุณมากครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-07-02 19:12:49 By : san.saleah
 


 

No. 5



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



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


ถ้าต้องการ ลบ แถวแรก ตอนเรียกหน้าเพจนี้ ไม่ให้มัน ขึ้นมาจะต้องปรับแก้ โค้ดเก่า อย่างไร บ้างครับ

222
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-07-02 19:28:33 By : san.saleah
 


 

No. 6



โพสกระทู้ ( 9,556 )
บทความ ( 2 )



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


113. <body OnLoad="CreateNewRow();">

เอา onload ออก ครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-07-02 19:43:10 By : Chaidhanan
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ช่วยด้วยครับ ทำตามลิงค์เรื่อง "Passing Popup to Main Page" แต่กดบวก(+) แถวไม่ขึ้นครับ หาจุด error ไม่เจอครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ 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 01
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 อัตราราคา คลิกที่นี่