|
 |
|
ขอสอบถามเรื่องการส่งค่าผ่าน URL ไปยัง Popup Window หน่อยครับ ไม่ทราบว่าเพราะเหตุใดค่าที่ส่งไปจึงช้าไปหนึ่งคลิ๊กน่ะครับ |
|
 |
|
|
 |
 |
|
จากหัวข้อขอยกตัวอย่างนะครับ
ผมเลือก List/Menu ครั้งที่ 1 แล้ว Submit ค่าที่ไป จะยังไม่มีค่าอะไร
แต่เมื่อผมเลือกค่าใหม่ที่ไม่ซ้ำ จะได้ค่าแรกที่ Submit ไปในครั้งก่อนหน้า และจะช้าแบบนี้ 1 ครั้งเสมอครับ
รบกวนช่วยดูโค้ตให้ด้วยนะครับ ว่าผิดพลาดตรงไหน ขอบคุณครับ
[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=windows-874" />
<title>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" method="post" >
<select name="select_col" id="select_col">
<option value="">Select.....</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<input type="submit" name="btn_ok" id="btn_ok" value=" OK " onclick="window.open('2.php?vars=<?= "$select_col"; ?>','popup','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=200,height=200,left = 200,top = 200')" />
</form>
</body>
</html>
[2.php]
<? echo $_POST["vars"];?>
Tag : PHP, HTML/CSS

|
|
 |
 |
 |
 |
Date :
2011-05-05 17:11:15 |
By :
iammonster |
View :
2722 |
Reply :
5 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เพราะว่าตัวแปร $select_col ตรงบรรทัด '2.php?vars=<?= "$select_col";
ตอนโหลดหน้าเพจครั้งแรกมันยังไม่มีค่าครับ หลังจากคุณ submit ไปนึงครั้งมันถึงมีค่าขึ้นมา
ส่วนการแก้ไข ตามที่พี่วินบอกเลยครับ
|
ประวัติการแก้ไข 2011-05-05 17:22:13
 |
 |
 |
 |
Date :
2011-05-05 17:21:31 |
By :
naskw |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณทั้งวิธีแก้ และคำอะธิบายนะครับ ได้ความรู้เพิ่มอีกแล้วครับ (^ ^ )
ปล. ขอแก้ไขที่หน้า 2.php นิดนึงนะครับ ให้ใช้แค่
<? echo $vars ?>
ก็พอครับ รับค่าเรียบร้อยดีครับ และนำไปประยุคใช้เรียบร้อยครับ ขอบคุณมากๆครับ
|
ประวัติการแก้ไข 2011-05-05 18:02:40 2011-05-05 18:04:24
 |
 |
 |
 |
Date :
2011-05-05 17:28:08 |
By :
iammonster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอถามต่อหน่อยครับ
คือถ้าผมต้องการส่งค่าตัวแปรไปพร้อมกับ window.open()
โดยไม่ต้องให้กดปุ่ม submit
ประมาณว่าให้มันsleepสักห้าวิ แล้วเปิดหน้าที่เราต้องการขึ้นมาเอง
โดยเราสามารถเอาค่าจากหน้าที่แล้วมาด้วยได้
มีวีธีไหมครับ
**หมายเหตุ ยังไม่มีโค้ดน่ะครับ คือตอนนี้ใช้วิธีเขียนไฟล์และอ่านไฟล์.txtในการส่งค่าตัวแปรเอาน่ะครับ
|
 |
 |
 |
 |
Date :
2011-05-06 14:09:21 |
By :
solid-water |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|