<tr> <td width=50% nowrap><b><font size=-1>IP Address Mode</font></td>
<td width=50%>
<select name=Ip_Addr_Mode >
<option value="2" selected name="C" onchange="checkmethod()">DHCP
<option value="1" name="C" onchange="checkmethod()"> Manually Set
</select>
</td>
</tr>
<div align="center">
<table border="0" cellspacing="0" width="570" height="125">
.......
</table>
</div> 以上代码:希望选择DHCP时,div中对应的内容变灰,不可设置。选择Manuaaly Set时,可以设置,应该怎么做?
本人自己写的checkmethod有点问题,希望得到正解,谢谢了
<select name=Ip_Addr_Mode onchange="checkmethod(this)">
<option value="2" selected name="C" >DHCP
<option value="1" name="C" > Manually Set
</select>
<div id='ss' align="center" style="height:auto; width:500px; margin:40px;">
<table width="500" border="1" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</table></div><script>
var $ =function(id){return document.getElementById(id)};
function create(elm,parent,fn){var element = document.createElement(elm);fn&&fn(element); parent&&parent.appendChild(element)};
function checkmethod(obj){
if(obj.selectedIndex)
{
create('div',document.body,function(elm){
with(elm){
style.position="absolute";
style.left = Getobjpos($('ss'),1)+'px';
style.top = Getobjpos($('ss'),0)+'px';
style.width = $('ss').offsetWidth;
style.height = $('ss').offsetHeight;
style.backgroundColor="#666666";
id='sss'
document.all?(style.filter = "alpha(opacity:10)"):(style.opacity = 0.1)
}
})
}
else
{
$('sss')&&document.body.removeChild($('sss'))
}
}
function Getobjpos(el,left){
var val = 0;
while (el !=null) {
val += el["offset" + (left? "Left": "Top")];
el = el.offsetParent;
}
return val;
}
</script>
</body>
http://www.cnblogs.com/guodaxia/archive/2009/06/11/1501424.html