 |
ติดปัญหาการแสดงข้อมูล รบกวนถามเรื่องการรับค่าจากหน้า pop up มาใส่ใน textbox หน้าหลัก แล้วดึงค่าจากฐานข้อมูลอัตโนมัติ |
|
 |
|
|
 |
 |
|
เอาไปเป็นแนวทางน่ะครับ
Code (form.html)
<meta charset="utf-8">
<p>Input : <input type="text" name="txt" id="txt"> <a href="#" onclick="window.open('popup.html','_blank','width=200,height=100');">Click me.</a></p>
Code (popup.html)
<meta charset="utf-8">
<p><a href="#" onclick="opener.document.getElementById('txt').value='สีเขียว';">สีเขียว</a></p>
<p><a href="#" onclick="opener.document.getElementById('txt').value='สีส้ม';">สีส้ม</a></p>
<p><a href="#" onclick="opener.document.getElementById('txt').value='สีน้ำตาล';">สีน้ำตาล</a></p>

|
 |
 |
 |
 |
Date :
2014-01-02 16:50:25 |
By :
mangkunzo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณมากเลยค่ะ ขั้นตอนนี้ทำได้แล้วค่ะ ถามต่อนะค่ะ พอส่งค่าจาก pop up มาลงใน textbox นี้ได้แล้ว จะให้ดึงค่าจากฐานข้อมูลอัตโนมัติอะค่ะ
ใช้โค้ดนี่ตามตัวอย่างแล้วโค้ดไม่ทำงาน (แต่ถ้ากรอกค่าลงเองใน textbox ข้างบน โค้ดจะทำงานค่ะ ) ต้องดัดแปลงตรงไหนหรอค่ะ หรือมีโค้ดอื่นเป็นตัวอย่างไหมค่ะ
Code (PHP)
<script type="text/javascript">
$(document).ready(function(){
$("#color_id").change(function(){
$.ajax({
url: "returnCustomer1.php" ,
type: "POST",
data: 'color_id=' +$("#color_id").val()
})
.success(function(result) {
var obj = jQuery.parseJSON(result);
if(obj == '')
{
$('input[type=text]').val('');
}
else
{
$.each(obj, function(key, inval) {
$("#color_id").val(inval["color_id"]);
$("#color").val(inval["color"]);
$("#pic").val(inval["pic"]);
});
}
});
});
});
</script>
|
 |
 |
 |
 |
Date :
2014-01-02 17:26:41 |
By :
kampong23 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

|
 |
 |
 |
 |
Date :
2014-01-03 09:07:25 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|