|
|
|
ส่งค่าจาก popup มา form หลัก............ทำไมมันส่งไม่ได้ค้ะ |
|
|
|
|
|
|
|
ขอดูโค๊ดที่คุณใช้ด้วยครับ
|
|
|
|
|
Date :
2013-04-30 10:06:46 |
By :
itpcc |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1.php
<?
mysql_connect("localhost","root","1234");
mysql_select_db("motor");
?>
<script language="javascript">
function OpenPopup(intLine)
{
window.open('2.php?Line='+intLine,'myPopup','width=650,height=200,toolbar=0, menubar=0,location=0,status=1,scrollbars=1,resizable=1,left=0,top=0');
}
</script>
<body>
<form name="frmMain" method="post" action="readData.php">
<table width="600" border="1">
<tr>
<td><div align="center">type_id </div></td>
<td><div align="center">type_name </div></td>
<td><div align="center"> POPUP</div></td>
</tr>
<tr>
<td><div align="center"><center><INPUT TYPE="TEXT" SIZE="5" NAME="type_id" ID="type_id" VALUE="" OnClick="OpenPopup(1)"></center> </div></td>
<td><div align="center"><center><INPUT TYPE="TEXT" SIZE="5" NAME="type_name" ID="type_name" VALUE="" OnClick="OpenPopup(1)"></center> </div></td>
<td><INPUT TYPE="BUTTON" NAME="btnPopup_1" ID="btnPopup_1" VALUE="..." OnClick="OpenPopup(1)"> </td>
</table>
<input type="hidden" name="hdnMaxLine" value="3">
<input type="submit" name="btnSubmit" value="Submit">
</form>
</body>
</html>
2.php
<!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>
<script language="javascript">
function selData(intLine,type_id,type_name)
{
var stype_id = self.opener.document.getElementById("type_id_" +intLine);
stype_id.value = type_id;
var stype_name = self.opener.document.getElementById("type_name_" +intLine);
stype_name.value = type_name;
window.close();
}
</script>
<body>
<?
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("motor");
mysql_query("SET character_set_results=utf8");
mysql_query("SET character_set_client=utf8");
mysql_query("SET character_set_connection=utf8");
$strSQL = "SELECT * FROM type";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<table width="600" border="1">
<tr>
<th width="91"> <div align="center">รหัส </div></th>
<th width="98"> <div align="center">รายละเอียด </div></th>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr>
<td><div align="center"><a href="#" OnClick="selData('<?=$_GET["Line"];?>' ,'<?=$objResult["type_id"];?>', '<?=$objResult["type_name"];?>');">
<?=$objResult["type_id"];?>
</a></div></td>
<td><?=$objResult["type_name"];?></td>
</tr>
<?
}
?>
</table>
<?
mysql_close($objConnect);
?>
</body>
</html>
|
ประวัติการแก้ไข 2013-04-30 10:11:25 2013-04-30 10:12:11 2013-04-30 10:14:50
|
|
|
|
Date :
2013-04-30 10:11:04 |
By :
lookpla26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (JavaScript)
//use jQuery
var parent = $(parent.document.body);
$(parent).find("#type_id_" +intLine).val(type_id);
$(parent).find("#type_name_" +intLine).val(type_id);
window.close();
ปล. ผมอยากแนะนำให้ใช้ popup แบบนี้มากกว่าอ่ะ ใช้ง่ายกว่า สวยกว่าด้วย อิอิ
http://jqueryui.com/dialog/
http://fancybox.net/
credit : http://stackoverflow.com/questions/2353011/jquery-popup-window-return-value-to-parent
|
ประวัติการแก้ไข 2013-04-30 10:23:14 2013-04-30 10:23:41
|
|
|
|
Date :
2013-04-30 10:18:48 |
By :
itpcc |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตอนนี้ทำได้เเล้ว แต่ว่าจะทำ POP UPเพิ่มอีก ใน textbox ฟิลด์ที่ชื่อว่า สี แต่มันทำไม่ได้ มันจะลิงค์ไปหน้า POPUP ของ อันเก่า
|
|
|
|
|
Date :
2013-04-30 10:51:45 |
By :
lookpla26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1.php
<!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>
<?
mysql_connect("localhost","root","1234");
mysql_select_db("motor");
mysql_query("SET character_set_results=utf8");
mysql_query("SET character_set_client=utf8");
mysql_query("SET character_set_connection=utf8");
?>
<script language="javascript">
function OpenPopup(intLine)
{
window.open('2.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 OpenPopup2(intLine)
{
window.open('3.php?Line='+intLine,'myPopup','width=650,height=200,toolbar=0, menubar=0,location=0,status=1,scrollbars=1,resizable=1,left=0,top=0');
}
</script>
<body>
<form name="frmMain" method="post" action="readData.php">
<table width="600" border="1">
<tr>
<td><div align="center">รหัสรถ </div></td>
<td><div align="center">รายละเอียด </div></td>
<td><div align="center">สีรถ </div></td>
<td><div align="center">หน่วย </div></td>
<td><div align="center">จำนวน </div></td>
<td><div align="center">ราคา:หน่วย </div></td>
<td><div align="center"> รวมเป็นเงิน</div></td>
</tr>
<!-- Rows 1 -->
<tr>
<td align="center"><INPUT TYPE="TEXT" SIZE="5" NAME="type_id_1" ID="type_id_1" VALUE="" OnClick="OpenPopup(1)"> </td>
<td align="center"><INPUT TYPE="TEXT" SIZE="5" NAME="type_name_1" ID="type_name_1" VALUE=""></td>
<td align="center"><INPUT TYPE="TEXT" SIZE="5" NAME="color_name_1" ID="color_name_1" VALUE="" OnClick="OpenPopup(2)"> </td>
<td align="center"><INPUT TYPE="TEXT" SIZE="5" NAME="unit" ID="unit" VALUE="" > </td>
<td align="center"><INPUT TYPE="TEXT" SIZE="5" NAME="amount" ID="amount" VALUE="" > </td>
<td align="center"><INPUT TYPE="TEXT" SIZE="5" NAME="price" ID="price" VALUE="" > </td>
<td align="center"><INPUT TYPE="TEXT" SIZE="5" NAME="total" ID="total" VALUE="" > </td>
</table>
<input type="hidden" name="hdnMaxLine" value="3">
<input type="submit" name="btnSubmit" value="Submit">
</form>
</body>
</html>
2.php
<!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>
<script language="javascript">
function selData(intLine,type_id,type_name)
{
var stype_id = window.opener.document.getElementById("type_id_" +intLine);
stype_id.value = type_id;
var stype_name = window.opener.document.getElementById("type_name_" +intLine);
stype_name.value = type_name;
window.close();
}
</script>
<body>
<?
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("motor");
mysql_query("SET character_set_results=utf8");
mysql_query("SET character_set_client=utf8");
mysql_query("SET character_set_connection=utf8");
$strSQL = "SELECT * FROM type";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<table width="600" border="1">
<tr>
<th width="91"> <div align="center">รหัส </div></th>
<th width="98"> <div align="center">รายละเอียด </div></th>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr>
<td><div align="center">
<a href="#" OnClick="selData('<?=$_GET["Line"];?>' ,'<?=$objResult["type_id"];?>', '<?=$objResult["type_name"];?>');">
<?=$objResult["type_id"];?>
</a></div></td>
<td><?=$objResult["type_name"];?></td>
</tr>
<?
}
?>
</table>
<?
mysql_close($objConnect);
?>
</body>
</html>
3.php
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script language="javascript">
function selData(intLine,color_id,color_name)
{
var scolor_id = window.opener.document.getElementById("color_id_" +intLine);
scolor_id.value = color_id;
var scolor_name = window.opener.document.getElementById("color_name_" +intLine);
scolor_name.value = color_name;
window.close();
}
</script>
<body>
<?
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("motor");
mysql_query("SET character_set_results=utf8");
mysql_query("SET character_set_client=utf8");
mysql_query("SET character_set_connection=utf8");
$strSQL = "SELECT * FROM color";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<table width="600" border="1">
<tr>
<th width="91"> <div align="center">รหัส </div></th>
<th width="98"> <div align="center">สี </div></th>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr>
<td><div align="center">
<a href="#" OnClick="selData('<?=$_GET["Line"];?>' ,'<?=$objResult["color_id"];?>', '<?=$objResult["color_name"];?>');">
<?=$objResult["color_id"];?>
</a></div></td>
<td><?=$objResult["color_name"];?></td>
</tr>
<?
}
?>
</table>
<?
mysql_close($objConnect);
?>
</body>
</html>
|
ประวัติการแก้ไข 2013-04-30 10:54:32
|
|
|
|
Date :
2013-04-30 10:53:54 |
By :
lookpla26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (JavaScript)
function OpenPopup(intLine)
19.
{
20.
window.open((intLine+1)+'.php?Line='+intLine,'myPopup','width=650,height=200,toolbar=0, menubar=0,location=0,status=1,scrollbars=1,resizable=1,left=0,top=0');
21.
}
22.
23.
|
|
|
|
|
Date :
2013-04-30 10:56:19 |
By :
itpcc |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตอบความคิดเห็นที่ : 6 เขียนโดย : itpcc เมื่อวันที่ 2013-04-30 10:56:19
รายละเอียดของการตอบ ::
อย่างนี้มั้ยค้ะ
<?
mysql_connect("localhost","root","1234");
mysql_select_db("motor");
mysql_query("SET character_set_results=utf8");
mysql_query("SET character_set_client=utf8");
mysql_query("SET character_set_connection=utf8");
?>
<script language="javascript">
function OpenPopup(intLine)
{
window.open((intLine+1)+'.php?Line='+intLine,'myPopup','width=650,height=200,toolbar=0, menubar=0,location=0,status=1,scrollbars=1,resizable=1,left=0,top=0');
}
</script>
<body>
<form name="frmMain" method="post" action="readData.php">
<table width="881" border="1">
<tr>
<td width="93"><div align="center">รหัสรถ </div></td>
<td width="154"><div align="center">รายละเอียด </div></td>
<td width="132"><div align="center">สีรถ </div></td>
<td width="114"><div align="center">หน่วย </div></td>
<td width="94"><div align="center">จำนวน </div></td>
<td width="144"><div align="center">ราคา:หน่วย </div></td>
<td width="104"><div align="center"> รวมเป็นเงิน</div></td>
</tr>
<!-- Rows 1 -->
<tr>
<td align="center"><INPUT NAME="type_id_1" TYPE="TEXT" class="tbl_box6" ID="type_id_1" OnClick="OpenPopup(1)" VALUE="" SIZE="15"> </td>
<td align="center"><INPUT TYPE="TEXT" SIZE="25" NAME="type_name_1" ID="type_name_1" VALUE=""></td>
<td align="center"><INPUT TYPE="TEXT" SIZE="15" NAME="color_name_1" ID="color_name_1" VALUE="" OnClick="OpenPopup(2)"> </td>
<td align="center"><INPUT TYPE="TEXT" SIZE="5" NAME="unit" ID="unit" VALUE="" > </td>
<td align="center"><INPUT TYPE="TEXT" SIZE="5" NAME="amount" ID="amount" VALUE="" > </td>
<td align="center"><INPUT TYPE="TEXT" SIZE="5" NAME="price" ID="price" VALUE="" > </td>
<td align="center"><font color="#FF0000"><INPUT TYPE="TEXT" SIZE="5" NAME="total" ID="total" VALUE="" ></font> </td>
</table>
<input type="hidden" name="hdnMaxLine" value="3">
<input type="submit" name="btnSubmit" value="Submit">
</form>
</body>
</html>
|
|
|
|
|
Date :
2013-04-30 11:03:05 |
By :
lookpla26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตอนนี้ POPUP ของสีรถได้เเล้ว
แต่ว่ายังไม่ส่งค่ามายังหน้าหลักค่ะ
|
|
|
|
|
Date :
2013-04-30 11:06:35 |
By :
lookpla26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|