62,268
社区成员
发帖
与我相关
我的任务
分享
function CreateRootID(targForm) {
var targ = targForm.selName;
for (i = 0; i < ThirdComponent.length; i++) {
targ.options[i] = new Option(ThirdComponent[i][1], ThirdComponent[i][0]);
}
}
function CreateClassID(targForm) {//生成二级分类 targForm为目标表单
var parent = targForm.selName;
var subfield = targForm.selCompany;
var classid;
classid = parent.options[parent.selectedIndex].value;
subfield.length = 0;
subfield.options[subfield.length] = new Option('二级分类', '-1');
for (i = 0; i < ThirdCompany.length; i++) {
if (ThirdCompany[i][2] == classid) {
subfield.options[subfield.length] = new Option(ThirdCompany[i][1], ThirdCompany[i][0])
}
}
}
var choose = o.parentNode.getElementsByTagName("select");
alert(choose[0].options[choose[0].selectedIndex].value);
<html>
<head><title></title>
<script language="javascript">
function $(s)
{
return document.getElementById(s);
}
function InitSel(id)
{
var i;
for(i=0;i<$("selone").options.length;i++)
{
if($('selone').options[i].value == id)
{
$('selone').options[i].selected = true;
}
}
}
</script>
</head>
<body onload="InitSel('b');">
<select id="selone">
<option value="a">a</option>
<option value="b">b</option>
<option value="c">c</option>
</select>
</body>
</html>