หนูเอาตัวอย่าง การส่งค่า pop up มายังฟอร์มหลัก แต่หนูเพิ่มปุ่ม ค้นหา ข้อมูลแล้วมันไม่ส่งค่ามาให้นะคะ รบกวนแนะนำด้วยคะ
หนูเอาตัวอย่าง การส่งค่า pop up มายังฟอร์มหลัก แต่หนูเพิ่มปุ่ม ค้นหา ข้อมูลแล้วมันไม่ส่งค่ามาให้นะคะ รบกวนแนะนำด้วยคะ
หนูลองแก้แล้วคะ มันไม่ส่งค่าให้ รบกวนแนะนำด้วยคะ
Code คะ
หน้าหลัก
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<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 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 Name ***//
newCell = newRow.insertCell(1);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"5\" NAME=\"Name"+intLine+"\" ID=\"Name"+intLine+"\" VALUE=\"\"></center>";
//*** Column Lastname ***//
newCell = newRow.insertCell(2);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"5\" NAME=\"LastName"+intLine+"\" ID=\"LastName"+intLine+"\" VALUE=\"\"></center>";
//*** Column 3***//
newCell = newRow.insertCell(3);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"5\" NAME=\"city"+intLine+"\" ID=\"city"+intLine+"\" VALUE=\"\"></center>";
//*** Column 4***//
newCell = newRow.insertCell(4);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"5\" NAME=\"province"+intLine+"\" ID=\"province"+intLine+"\" VALUE=\"\"></center>";
//*** Column 7 ***//
newCell = newRow.insertCell(5);
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">Name </div></td>
<td><div align="center">Lastname </div></td>
<td><div align="center">City</div></td>
<td><div align="center">Province </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>
หน้า getdata.php คะ
<?php
include "Connect.php";
?>
<html>
<head>
<title>data</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
</head>
<script language="javascript">
function selData(intLine,Name,LastName,city,province)
{
var sName = self.opener.document.getElementById("Name" +intLine);
sName.value = Name;
var sLastName = self.opener.document.getElementById("LastName" +intLine);
sLastName.value = LastName;
var scity = self.opener.document.getElementById("city" +intLine);
scity.value = city;
var sprovince = self.opener.document.getElementById("province" +intLine);
sprovince.value = province;
window.close();
}
</script>
<style type="text/css">
.ui-datepicker{
width:150px;
font-family:tahoma;
font-size:11px;
text-align:center;
}
TABLE {
border: 4px double green;
border-collapse: collapse;
}
TH {
text-align: left;
background:
padding: 1px;
border: 1px solid green;
}
TD {
padding: 1px;
border: 1px solid green;
}
</style>
<body>
<form name="frmSearch" method="get" action="<?=$_SERVER['SCRIPT_NAME'];?>">
<fieldset>
<table align="left" style="font-size:15px" >
<tr>
<th align="center">ค้นหา:</th>
<td>
<input name="txtKeyword" type="text" id="txtKeyword" value="<?=$_GET["txtKeyword"];?>">
</td>
<td><button type="submit" name="Submit" value="Search" /> ค้นหา</button></td>
</tr>
</table>
</fieldset>
</form>
<?
$strSQL = "SELECT clientdata.ID, clientdata.`Name`, clientdata.LastName, clientdata.City, clientdata.Province
FROM clientdata
WHERE Name LIKE '%".$_GET["txtKeyword"]."%' OR LastName LIKE '%".$_GET["txtKeyword"]."%'";
//$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysql_num_rows($objQuery);
$Per_Page = 200; // Per Page
$Page = $_GET["Page"];
if(!$_GET["Page"])
{
$Page=1;
}
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$Page_Start = (($Per_Page*$Page)-$Per_Page);
if($Num_Rows<=$Per_Page)
{
$Num_Pages =1;
}
else if(($Num_Rows % $Per_Page)==0)
{
$Num_Pages =($Num_Rows/$Per_Page) ;
}
else
{
$Num_Pages =($Num_Rows/$Per_Page)+1;
$Num_Pages = (int)$Num_Pages;
}
$strSQL .=" order by Name LIMIT $Page_Start , $Per_Page";
$objQuery = mysql_query($strSQL);
?>
<table width="80%" border="1">
<tr>
<th width="98"> <div align="center">Name </div></th>
<th width="198"> <div align="center">Lastname </div></th>
<th width="97"> <div align="center">City </div></th>
<th width="59"> <div align="center">Province </div></th>
</tr>
<?
$i=1;
if($Page > 1)
{
$i = ($Per_Page * ($Page-1)) + 1;
}
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr>
<td><div align="center"><a href="#" OnClick="selData('<?=$_GET["Line"];?>' ,'<?=$objResult["Name"];?>', '<?=$objResult["LastName"];?>','<?=$objResult["City"];?>' ,'<?=$objResult["Province"];?>');">
<?=$objResult["Name"];?>
</a></div></td>
<td><?=$objResult["LastName"];?></td>
<td><?=$objResult["City"];?></td>
<td><div align="center"><?=$objResult["Province"];?></div></td>
</tr>
<?
$i++;
}
?>
</table>
<div align="center">มีทั้งหมดจำนวน
<?= $Num_Rows;?>
รายการ :
<?=$Num_Pages;?>
หน้า :
<?
if($Prev_Page)
{
echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Back</a> ";
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]";
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>Next>></a> ";
}
?>
</table>
</body>
</html>
หน้า readdata.php คะ
<html>
<head>
<title>test</title>
</head>
<body>
<?
for($i=1;$i<=(int)$_POST["txtKeyword"];$i++)
{
echo $_POST["Name".$i];
echo "<br>";
echo $_POST["LastName".$i];
echo "<br>";
echo $_POST["city".$i];
echo "<br>";
echo $_POST["province".$i];
echo "<br>";
}
?>
</body>
</html>Tag : PHP, MySQL
Date :
2014-03-04 12:06:10
By :
แอน
View :
739
Reply :
3
Date :
2014-03-04 15:24:36
By :
A
ไม่มีใครช่วยแนะนำหนูเลย หนูพยายามแก้แล้ว แต่พอ search แล้วมันไม่ส่งค่ามาอะคะ ถ้าไม่ search คลิกเลือกก็ส่งมาปกติ งงจริง ๆ เลย
Date :
2014-03-06 15:20:09
By :
แอน
pop upปกติจะส่งไปเป็น $_GET นะครับมิไช่ $_POST
EX. เอาไปลองสร้างไฟล์ชื่อตามนี้ดูนะครับมี 2 ไฟล์
z1_main.php
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script>
function popup(url,name,windowWidth,windowHeight){
myleft=(screen.width)?(screen.width-windowWidth)/2:100;
mytop=(screen.height)?(screen.height-windowHeight)/2:100;
properties = "width="+windowWidth+",height="+windowHeight;
properties +=",scrollbars=yes, top="+mytop+",left="+myleft;
window.open(url,name,properties);
}
</script>
<? $send="สามีตีตรา"; ?>
<a href="javascript:popup('z2_popup.php?xxx=<?=$send?>','',650,600)"> กดคร้าบ </a>
z2_popup.php
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?=$_GET['xxx']; ?>
Date :
2014-03-06 15:44:52
By :
meannerss
Load balance : Server 03