读书人

一个下拉框与与文本框的有关问题,求解

发布时间: 2012-02-29 16:44:10 作者: rapoo

一个下拉框与与文本框的问题,急求解决**********
具体是这样:
假如我有一个下拉框,里面有几个值供选择:
例如:有值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>

读书人网 >ASP

热点推荐