PDA

View Full Version : سوال: چگون به یا یک radio یک text field را می توان غیر فعال یا فعال کرد



samsami
دوشنبه 13 آذر 1391, 20:44 عصر
با سلام خدمت دوستان

من دوتا radio در html دارم مثلا ( a , b ) می خوام وقتی که radio ـ (a) انتخاب شود یک text field فعال شود

و وقتی radio ـ (b) انتخاب شود text field غیر فعال شود

ممنون میشم از پاسختون

pani.khoram
سه شنبه 14 آذر 1391, 08:36 صبح
امیدوارم این تیکه کد به دردت بخوره :

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>barname Nevis : JS Onclick</title>
<script type="text/javascript">
//This is done to make the following JavaScript code compatible to XHTML.
<![CDATA[
function ghazanfar()
{
if(document.Form1.radio1.checked == true)
{
document.getElementById('text1').disabled = false;
}
}
function havij()
{
if(document.Form1.radio2.checked == true)
{
document.getElementById('text1').disabled = true;
}
}
//]]>
</script>
</head>
<body>
<hr />
<form name="Form1" style="color: green ; font-size: 150%" action="#" >
<input type="radio"
name="radio1"
onclick = "ghazanfar()" />Ghazanfar
<br />

<input type="radio"
name="radio2"
onclick = "havij()" />Havij
</form>
</body>
</html>