日期:2014-05-17  浏览次数:21093 次

一个下拉框与与文本框的问题,急求解决**********
具体是这样:
    假如我有一个下拉框,里面有几个值供选择:
    例如:有值A和值B
    当我选择值B时,下面的文本框变为灰色,即不可用,而选择值A时候,又可用
    这个问题怎么实现,求各位了********
********************************************

------解决方案--------------------
<script language= "javascript ">
function check(a)
{
if (a==1)
{

document.form1.num.disabled= true ;
document.form1.num.style.background= "#999999 ";
}
else
{
document.form1.num.disabled= false;
document.form1.num.style.background= "#ffffff ";

}
}


</script>
<form action= " " method= "post " name= "form1 ">

<select name= "1 " onChange= "check(this.options[this.selectedIndex].value); ">
<option value= "0 "> 00000000000000 </option>
<option value= "1 "> 1111111111 </option>
<option value= "2 "> 222222222 </option>
</select>

<input name= "num " type= "text " >
</form>
------解决方案--------------------
<html>

<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<title> 单元框 </title>
<script language= "javascript ">
function check(a)
{
if (a==1)
{

document.form1.num.disabled= true ;
document.form1.num.style.background= "#999999 ";
}
else
{
document.form1.num.disabled= false;
document.form1.num.style.background= "#ffffff ";

}
}


</script>


</head>

<body>
<form action= " " method= "post " name= "form1 ">

<select name= "1 " onChange= "check(this.options[this.selectedIndex].value); ">
<option value= "0 "> A </option>
<option value= "1 "> B </option>

</select>

<input name= "num " type= "text " >
</form>

</body>

</html>