html xmlns="
http://www.w3.org/1999/xhtml" >
<head>
<title>标题页</title>
<style type="text/css">
#divlight
{float:left;width:100px
}
</style>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>所属区域</td>
<td>
<input type="text" id="txtRegion" /><!---background-color: #ccffff;----->
<div id="divList" style="display: none; border: 1px solid #0000aa; overflow: hidden; height: 200px; position: absolute; ">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr ><!--background-color:lightgreen;----background-color:lightgreen;----->
<td align="left" id="tdtitle" style="cursor: hand;border-bottom:#cccccc solid 1px;" >线路选择</td>
<td align="right" id="tdClose" style="cursor: hand;border-bottom:#cccccc solid 1px;" >X </td>
</tr>
<tr>
<td>
<div style="overflow: auto; width: 100%; height: 132px; background-color: ##ffffcc;">
<div style="float:left;width:100px">
<input type="radio" name="linelight" value="总路开关" checked>总路开关
</div>
<div style="float:left;width:100px">
<input type="radio" name="linelight" value="招牌灯">招牌灯
</div>
<div style="float:left;width:100px">
<input type="radio" name="linelight" value="展示厅">展示厅
</div>
<br>
<div style="float:left;width:100px">
<input type="radio" name="linelight" value="电视" checked>电视
</div>
<div style="float:left;width:100px">
<input type="radio" name="linelight" value="办公照明2">办公照明2
</div>
<div style="float:left;width:100px">
<input type="radio" name="linelight" value="办公照明">办公照明
</div>
<br>
<div style="float:left;width:100px">
<input type="radio" name="linelight" value="电视" checked>走道
</div>
<div style="float:left;width:100px">
<input type="radio" name="linelight" value="射灯">射灯
</div>
<div style="float:left;width:100px">
<input type="radio" name="linelight" value="备用2">备用2
</div>
<br>
<div style="float:left;width:100px">
<input type="radio" name="linelight" value="墙面射灯" checked>墙面射灯
</div>
<div style="float:left;width:100px">
<input type="radio" name="linelight" value="冰箱">冰箱
</div>
<div style="float:left;width:100px">
<input type="radio" name="linelight" value="备用8">备用8
</div>
<br>
<div style="float:left;width:100px">
<input type="radio" name="linelight" value="空调" checked>空调
</div>
<div style="float:left;width:100px">
<input type="radio" name="linelight" value="备用3">备用3
</div>
<div style="float:left;width:100px">
<input type="radio" name="linelight" value="备用11">备用11
</div>
</div>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
<script LANGUAGE="JavaScript">
var oRegion = document.getElementById("txtRegion"); //需要弹出下拉列表的文本框
var oDivList = document.getElementById("divList"); //要弹出的下拉列表
var oClose = document.getElementById("tdClose"); //关闭div的单元格,也可使用按钮实现
var colOptions = document.getElementsByTagName("input"); //所有列表元素
var bNoAdjusted = true;
oClose.onclick = function()
{
oDivList.style.display = "none"; //隐藏div,实现关闭下拉框的效果
};
//设置下列选择项的一些事件
for (var i=0; i<colOptions.length; i++)
{
if(colOptions[i].name == "linelight")
{
colOptions[i].style.cursor = "hand";
colOptions[i].onclick = function() //为列表项添加单击事件
{
oRegion.value = this.value; //显示选择的文本;
};
}
}
//文本获得焦点时的事件
oRegion.onfocus = function()
{
oDivList.style.display = "block";
if (bNoAdjusted) //控制div是否已经显示的变量
{
bNoAdjusted = false;
//设置下拉列表的宽度和位置
oDivList.style.width = 350;//this.offsetWidth+150;
oDivList.style.posTop = oDivList.offsetTop;// + this.offsetHeight;
oDivList.style.posLeft = oDivList.offsetLeft;// - this.offsetWidth - 8 + 200;
}
};
</script>
</body>
</html>