|
 |
|
[สอบถาม] คือผมทำเขียนโค้ดให้มีการแก้ไข้ในหน้าฟอร์มเดียวกัน ครับข้อมูลในส่วนของ redio กับ listmanu ไม่ยอมเลือกค่าให้ครับ |
|
 |
|
|
 |
 |
|
จากกระทู้นี้ครับ >>>> https://www.thaicreate.com/tutorial/ajax-edit-update-record.html
คือค่าของ redio กับ listmanu ไม่ยอมเลือกค่าเก่าให้นะครับ แต่ค่าของ textbox แสดงปรกติครับ
ไม่ทราบว่าส่วนของ radio กับ listmanu ต้องทำอย่างไรครับ
โค้ดในการแสดงข้อมูลครับ
Code (JavaScript)
function ShowEdit(exID,listname,amount,type_ex,type_pay,bankid)
{
//exID,listname,amount,type_ex,type_pay,bankid
//alert(exID + "," + listname + "," + amount + "," + type_ex + "," + type_pay + "," + bankid);
document.getElementById("editexpen").style.display = '';
document.getElementById("addexpen").style.display = 'none';
/////////////////////////////////////////////////////////////////////////////////////
document.getElementById('edit_listname').value = listname;
document.getElementById('edit_amount').value = amount;
if(type_pay == "Cash")//// Radio box
{
document.getElementById('edit_typepay1').checked;
}
else
{
document.getElementById('edit_typepay2').checked;
}
document.getElementById('edit_type').select(type_ex);////// listbox
document.getElementById('hdtypepay_edit').value = type_pay;
document.getElementById('hdexID').value = exID;
document.getElementById('selbank').value = bankid;
}
Tag : PHP, MySQL, HTML/CSS, JavaScript, Ajax, jQuery

|
ประวัติการแก้ไข 2014-01-30 14:07:16 2014-01-30 14:09:45
|
 |
 |
 |
 |
Date :
2014-01-30 14:07:19 |
By :
nutzaaclub |
View :
915 |
Reply :
11 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อะไรคือ "ไม่ยอมเลือกค่าเก่า" ครับ
|
 |
 |
 |
 |
Date :
2014-01-30 15:35:53 |
By :
sakuraei |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ต้องไปใส่เงื่อนไขใน dropdown list และ radio ครับ
|
 |
 |
 |
 |
Date :
2014-01-30 16:04:35 |
By :
sakuraei |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
while($data = mysql_fetch_assoc($rs)){
echo "<option value='{$data["...."]}' ";
if( $data["..."] == $_POST["...."] ) echo "selected ";
echo ">"{$data["...."]}</option>\n";
}
<input type='radio' name='payment' value='cash' <?php if($_POST["...."] == "cash") echo "checked"; ?> />เงินสด
<input type='radio' name='payment' value='bank' <?php if($_POST["...."] == "bank") echo "checked"; ?> />ธนาคาร
|
 |
 |
 |
 |
Date :
2014-01-30 16:09:41 |
By :
sakuraei |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คือตรงส่วนที่เป็นการแสดงข้อมูลนะครับ ผมทำเป็น function ไว้
เหมือนกับกระทู้นี้ >>>> https://www.thaicreate.com/tutorial/ajax-edit-update-record.html นะครับ
แต่มันนี้แค่ Textbox เลยอยากรู้วิธี ในส่วนของ listbox กับ radio นะครับ
Code (JavaScript)
function ShowEdit(exID,listname,amount,type_ex,type_pay,bankid)
{
//exID,listname,amount,type_ex,type_pay,bankid
//alert(exID + "," + listname + "," + amount + "," + type_ex + "," + type_pay + "," + bankid);
document.getElementById("editexpen").style.display = '';
document.getElementById("addexpen").style.display = 'none';
/////////////////////////////////////////////////////////////////////////////////////
document.getElementById('edit_listname').value = listname;
document.getElementById('edit_amount').value = amount;
if(type_pay == "Cash")//// Radio box
{
document.getElementById('edit_typepay1').checked;
}
else
{
document.getElementById('edit_typepay2').checked;
}
document.getElementById('edit_type').select(type_ex);////// listbox
document.getElementById('hdtypepay_edit').value = type_pay;
document.getElementById('hdexID').value = exID;
document.getElementById('selbank').value = bankid;
}
|
ประวัติการแก้ไข 2014-01-30 16:21:14
 |
 |
 |
 |
Date :
2014-01-30 16:18:49 |
By :
nutzaaclub |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
function ShowEdit(exID,listname,amount,type_ex,type_pay,bankid)
{
//exID,listname,amount,type_ex,type_pay,bankid
//alert(exID + "," + listname + "," + amount + "," + type_ex + "," + type_pay + "," + bankid);
document.getElementById("editexpen").style.display = '';
document.getElementById("addexpen").style.display = 'none';
/////////////////////////////////////////////////////////////////////////////////////
document.getElementById('edit_listname').value = listname;
document.getElementById('edit_amount').value = amount;
if(type_pay == "Cash")//// Radio box
{
document.getElementById('edit_typepay1').checked;
}
else
{
document.getElementById('edit_typepay2').checked;
}
document.getElementById('edit_type').options[type_ex].checked;////// listbox
document.getElementById('hdtypepay_edit').value = type_pay;
document.getElementById('hdexID').value = exID;
document.getElementById('selbank').value = bankid;
}
document.getElementById('edit_type').options[type_ex].selected;////// listbox
ส่วนตัวเรดิโอ ดูๆแล้วก็ไม่น่าผิดนี่นา ลองเติม true ดูครับ
if(type_pay == "Cash")//// Radio box
{
document.getElementById('edit_typepay1').checked=true;
}
else
{
document.getElementById('edit_typepay2').checked=true;
}
|
 |
 |
 |
 |
Date :
2014-01-30 16:26:40 |
By :
sakuraei |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้แล้วครับ คือผมลองใช้แบบนี้ดู มันก็ได้เลย
แล้วก็ขอบคุณสำหรับคำแนะนำของ radio นะครับ
Code (JavaScript)
$('#edit_type').select().val(type_ex)
|
 |
 |
 |
 |
Date :
2014-01-30 16:42:25 |
By :
nutzaaclub |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองเติมเข้าไปครับ
document.getElementById('edit_type').options[type_ex].selected = true;
|
 |
 |
 |
 |
Date :
2014-01-30 16:43:26 |
By :
sakuraei |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ใฃ้ลูกผสมระหว่าง DOM กับ Jqueryเลยน่ะครับ
ผมว่ามันจะทำให้ระบบช้าไปเปล่าๆ
|
ประวัติการแก้ไข 2014-01-30 16:46:06
 |
 |
 |
 |
Date :
2014-01-30 16:46:02 |
By :
sakuraei |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|