|
 |
|
ต้องการให้หน้าจอฟอร์มหลักแรกสุด ทำการ Refresh หรือ Reload เพื่อแสดงข้อมูลที่แก้ไข ??? |
|
 |
|
|
 |
 |
|
echo "<script>alert('Section Name : $sectionNameEdit\\n\\nUpdate completed.\\n(total : $result record)');</script>";
echo "<script>window.opener.location.reload();</script>";
exit();
|
 |
 |
 |
 |
Date :
2009-05-12 21:19:44 |
By :
plakrim |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
หรือลองทำเป็น aJax ให้มันอัพเดทแค่เรคคอร์ดที่เราแก้ก็ได้นะครับดูไฮเทคไปอีกแบบ (^-^)
|
 |
 |
 |
 |
Date :
2009-05-12 22:32:32 |
By :
melodyApinan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เรียน พี่ PlaKriM ที่รักยิ่ง
ผมได้ทำตามขั้นตอนจากคำแนะนำของพี่ PlaKriM แล้ว ยังไม่ได้ครับ มันไม่สามารถ reload หน้าจอฟอร์มหลัก (อันแรกสุดเลยนะครับ)
---------------------------------------------------------
จากโค๊ด -->
echo "<script>alert('Section Name : $sectionNameEdit\\n\\nUpdate completed.\\n(total : $result record)');</script>";
echo "<script>window.opener.location.reload();</script>"; // ส่วนที่เพิ่มจากพี่ PlaKriM
echo "<script>self.close();</script>"; // close window message alert popup (file :> sectionNameEditUpdate.php)
echo "<script>opener.self.close();</script>"; // close window popup (file :> sectionNameEdit.php)
exit();
-------------------------------------------------------
หรือ -->
echo "<script>alert('Section Name : $sectionNameEdit\\n\\nUpdate completed.\\n(total : $result record)');</script>";
echo "<script>window.opener.location.reload();</script>";
exit();
------------------------------------------------------
จากโค๊ดอันที่ 2 นี่ ยิ่งไปกันใหญ่เลยครับ เพราะจะทำให้ หน้าจอ alert ของ 2 อันสุดท้ายไม่ปิดลงไปเลยนะครับ...
จึงเรียนมาเพื่อขอความกรุณารบกวนพี่ PlaKriM อีกครั้งนะครับ
(ขอฝากเนื้อฝากตัวด้วยนะครับ -> MSN : [email protected])
ขอขอบคุณอย่างสูงไว้ ณ ที่นี้เลยนะครับ...
|
 |
 |
 |
 |
Date :
2009-05-13 10:53:15 |
By :
pukmtec |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
popup ต้องสร้างจาก window.open นะครับ ไม่ใช่ message dialog บางคนใช้ แล้วจะ refresh หน้าหลักผมงมยังไงก็ไม่ได้ หมดปัญญา
|
 |
 |
 |
 |
Date :
2009-05-13 12:00:29 |
By :
plakrim |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมลองทำแบบจำลองมา 2 แบบครับ ไม่ต้องใช้ database จริงๆ ลองเอาไปทดสอบดูนะครับ
<?php if (isset($_GET['sectionNameEdit'])): ?>
<!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" dir="ltr" lang="th" xml:lang="th">
<head>
<meta http-equiv="content-type" content="text/html; charset=tis-620" />
<title>sectionNameEdit</title>
<script type="text/javascript">
//<![CDATA[
//]]>
</script>
</head>
<body>
update record id = <?php echo (int)$_GET['id'] ?>
<form method="post" action="?sectionNameEditUpdate&id=<?php echo (int)$_GET['id'];?>">
<input type="text" name="test" />
<input type="submit" name="update" />
</form>
</body>
</html>
<?php elseif (isset($_GET['sectionNameEditUpdate'])): ?>
<!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" dir="ltr" lang="th" xml:lang="th">
<head>
<meta http-equiv="content-type" content="text/html; charset=tis-620" />
<title>sectionNameEditUpdate</title>
<script type="text/javascript">
//<![CDATA[
window.onload = function(){
alert('update complete');
}
//]]>
</script>
</head>
<body>
update completed
<button onclick="window.opener.location.reload();window.close();">close</button>
</body>
</html>
<?php else: //sectionName ?>
<!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" dir="ltr" lang="th" xml:lang="th">
<head>
<meta http-equiv="content-type" content="text/html; charset=tis-620" />
<title>sectionName</title>
<script type="text/javascript">
//<![CDATA[
function openEdit(n){
window.open ("?sectionNameEdit&id="+n,"openEdit","menubar=0,resizable=1,width=350,height=250");
}
//]]>
</script>
</head>
<body>
<?php echo 'load at '.date('H:i:s');?>
<br /><a href="javascript:openEdit(1);" >record 1</a>
<br /><a href="javascript:openEdit(2);" >record 2</a>
</body>
</html>
<?php endif; ?>
แบบที่ 2
<?php if (isset($_GET['sectionNameEdit'])): ?>
<!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" dir="ltr" lang="th" xml:lang="th">
<head>
<meta http-equiv="content-type" content="text/html; charset=tis-620" />
<title>sectionNameEdit</title>
<script type="text/javascript">
//<![CDATA[
window.onload = function(){
document.getElementById('extra').onsubmit = function(){
window.open ("about:blank","sectionNameEditUpdate","menubar=0,resizable=1,width=350,height=250");
}
}
//]]>
</script>
</head>
<body>
update record id = <?php echo (int)$_GET['id'] ?>
<form id="extra" target="sectionNameEditUpdate" method="post"
action="?sectionNameEditUpdate&id=<?php echo (int)$_GET['id'];?>">
<input type="text" name="test" />
<input type="submit" name="update" />
</form>
</body>
</html>
<?php elseif (isset($_GET['sectionNameEditUpdate'])): ?>
<!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" dir="ltr" lang="th" xml:lang="th">
<head>
<meta http-equiv="content-type" content="text/html; charset=tis-620" />
<title>sectionNameEditUpdate</title>
<script type="text/javascript">
//<![CDATA[
window.onload = function(){
alert('update complete');
}
//]]>
</script>
</head>
<body>
update completed
<button onclick="window.opener.opener.location.reload(); window.opener.close(); window.close();">close</button>
</body>
</html>
<?php else: //sectionName ?>
<!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" dir="ltr" lang="th" xml:lang="th">
<head>
<meta http-equiv="content-type" content="text/html; charset=tis-620" />
<title>sectionName</title>
<script type="text/javascript">
//<![CDATA[
function openEdit(n){
window.open ("?sectionNameEdit&id="+n,"openEdit","menubar=0,resizable=1,width=350,height=250");
}
//]]>
</script>
</head>
<body>
<?php echo 'load at '.date('H:i:s');?>
<br /><a href="javascript:openEdit(1);" >record 1</a>
<br /><a href="javascript:openEdit(2);" >record 2</a>
</body>
</html>
<?php endif; ?>
reference
|
 |
 |
 |
 |
Date :
2009-05-13 13:17:54 |
By :
num |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เรียน พี่ PlaKriM และ พี่ num
ก่อนอื่น ผมต้องกล่าวคำขอบคุณสำหรับคำแนะนำ และความช่วยเหลือ แก่พี่ PlaKriM และ พี่ num ครับ
ผมได้นำไฟล์ของ พี่ num ทั้ง 2 ตัวอย่างมาลองทำ และ run ดู พบจุดที่ต้องการคือว่า หน้าจอฟอร์มแรกมันเกิดทำการ refresh ตัวเอง (ผมสังเกตตรงเวลาที่มันเปลี่ยนหลังจากกดปุ่ม close ไปแล้ว)
จากนั้นจึงได้พยามแกะโค๊ด เลยนำเอาคำสั่งตรงส่วน
update completed
<button onclick="window.opener.opener.location.reload(); window.opener.close(); window.close();">close</button> // มันทำให้หน้าจอฟอร์มแรกเกิดการ refresh ตัวเองด้วย
ผมจึงได้นำมาประยุกต์และเพิ่มในคำสั่งของผมลงไปแล้วดังนี้ :-
echo "<script>alert('Section Name : $sectionNameEdit\\n\\nUpdate completed.\\n(total : $result record)');</script>";
echo "<script>window.opener.opener.location.reload(); window.opener.close(); window.close();script>";
exit();
-------------------------------------------------------
มันทำให้เกิดปิดหน้าจอ popup message ทั้งหมด หลังจากทำการ Update แล้ว จากนั้น ก็จะทำให้หน้าจอฟอร์มแรกสุดทำการ refresh ตัวเอง และแสดงข้อมูลล่าสุดที่เพิ่งแก้ไขลงเมื่อสักครู่ (อ้างอิงจากรูปภาพจากกระทู้ที่ตั้งไว้นะครับ)
ได้แล้วครับ ขอขอบคุณพี่ๆ ทั้ง 2 ท่านมากเลยครับ (จากใจจริง)
เด็กผีเมืองเพชร (c)
|
 |
 |
 |
 |
Date :
2009-05-13 14:21:44 |
By :
pukmtec |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มารยาทดีจัง 
|
 |
 |
 |
 |
Date :
2009-05-13 14:58:33 |
By :
num |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เด็กเพรชก็งี้แหละ อิอิอิ
|
 |
 |
 |
 |
Date :
2009-10-05 12:04:29 |
By :
เด็กบ้านลาด |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
กระทู้นี้มีสาระมาก
ขอบคุณค้าบบบ
^^
|
 |
 |
 |
 |
Date :
2011-10-12 15:35:21 |
By :
เเวะมาศึกษา |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|