สอบถาม การทำ disable enable ในช่อง input form ครับ

เริ่มโดย JumDaiDee, 03 พฤษภาคม 2014, 17:23:01

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

JumDaiDee

สวัสดีครับ พี่โปรแกรมเมอร์ ช่วยดูโค้ดหน่อยครับว่า
โค้ดที่ผมเขียน ทำไม ช่อง textbox ไม่ยอม
disable enable เหมือน ช่องแรก select ครับ


<html>
<head>
<style type="text/css">
    select:disabled,input:disabled {
    background-color:#c6deff;
}
</style>

<script type="text/javascript">
    function enableButton() {
if(document.getElementById('option').checked){
document.getElementById('edit').disabled='';
} else {
document.getElementById('edit').disabled='true';
}
    }
</script>

</head>
<body onload="enableButton();">

<form method="post" action="test.php">

<input type="checkbox" name="option" id="option" rel="edit" onclick="javascript:enableButton();">Enable

<select name="edit" id="edit" disabled>
    <option>เลือกจำนวน</option>
</select>
<input type="text" name="" id="edit" disabled>
</form>

</body>
</html>
สินค้าออนไลน์ https://www.shoppook.com/product | โปรแกรมออนไลน์ : https://appnon.com

JumDaiDee

ได้แล้วครับ ขอโทษที่รบกวนพี่ๆ นะครับ

เพิ่ม document.getElementById('editxx').disabled=''; ในชื่อ id ใหม่ครับ
สินค้าออนไลน์ https://www.shoppook.com/product | โปรแกรมออนไลน์ : https://appnon.com