รบกวนครับ ต้องการเลือก Radio Button แล้ว Disable ปุ่มอื่น

ตอบกระทู้

รูปแสดงอารมณ์
:icon_plusone: :like: :plusone: :gfb: :-D :) :( :-o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: :angry: :baa: :biggrin:
รูปแสดงอารมณ์อื่นๆ

BBCode เปิด
[img] เปิด
[url] เปิด
[Smile icon] เปิด

กระทู้แนะนำ
   

มุมมองที่ขยายได้ กระทู้แนะนำ: รบกวนครับ ต้องการเลือก Radio Button แล้ว Disable ปุ่มอื่น

Re: รบกวนครับ ต้องการเลือก Radio Button แล้ว Disable ปุ่มอื่น

โดย touleg » 02/08/2011 8:19 pm

น่าจะประมาณนี้หรือป่าว

โค้ด: เลือกทั้งหมด

<!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=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
function enabletype()
{
	var e1 = document.getElementsByName("accounttype").item(0);
	var e2 = document.getElementsByName("accounttype").item(1);
	e1.checked = "checked";
	e1.disabled = false;
	e2.disabled = false;
}

function disabletype()
{
	var e1 = document.getElementsByName("accounttype").item(0);
	var e2 = document.getElementsByName("accounttype").item(1);
	e1.checked = false;
	e1.disabled = true;
	e2.checked = false;
	e2.disabled = true;
}
</script>
</head>

<body>
<table width="400" border="0" cellpadding="0" cellspacing="4">
<tr>
	<td>
        <input type="radio"  name="bank" id="bank1" onclick="enabletype();" checked="checked"/>กสิกรไทย
        <input type="radio"  name="bank" id="bank2" onclick="disabletype();"   />กรุงเทพ
        <input type="radio"  name="bank" id="bank3" />กรุงไทย
     </td>
</tr>
<tr>
	<td>
        <input type="radio"  name="accounttype" id="save" checked="checked" />ออมทรัพย์
        <input type="radio"  name="accounttype" id="daily" />รายวัน
     </td>
</tr>
</table>
</body>
</html>

รบกวนครับ ต้องการเลือก Radio Button แล้ว Disable ปุ่มอื่น

โดย demonxiii » 11/07/2011 11:11 am

คือ ผมมี radio button 2 รายการ คือ
ชื่อธนาคาร และประเภทบัญชี
โดยธนาคารมี 3 ชื่อ หากผมเลือกธนาคารที่ 1
Radio button อีกส่วน คือ ประเภทบัญชี ให้เลือกประเภทบัญชี มี 2 รายการ

แต่หากผมเลือกธนาคารที่ 2
Radio button ที่เป็นเภทบัญชีต้องเป็น Disable ครับ

มีวิธีไหนบ้างครับ ถ้าพอจะแก้โจทย์นี้ได้ (หน้าเพจเป็น .php)

ขอบคุณล่วงหน้าครับ

ข้างบน