<html>
<HEAD>
<title>例子</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"><SCRIPT LANGUAGE="JavaScript">
var meng1Array =  new Array("('选择A栏目内容','',true,true)",
"('学习 XML')",
"('学习 Javascript')",
"('学习 PHP')");
var mengArray =  new Array("('选择B栏目内容','',true,true)",
"('学习 Flash')",
"('学习 Dreamweaver Ultradev')",
"('学习 Java')");
var meng2Array =  new Array("('选择C栏目内容','',true,true)",
"('查找歌词')",
"('其他')");function populatemxhweb(inForm,selected) {
var selectedArray = eval(selected + "Array");
while (selectedArray.length < inForm.mxhweb.options.length) {
inForm.mxhweb.options[(inForm.mxhweb.options.length - 1)] = null;
}
for (var i=0; i < selectedArray.length; i++) {
eval("inForm.mxhweb.options[i]=" + "new Option" + selectedArray[i]);
}if ( navigator.appName == 'Netscape') {
if (parseInt(navigator.appVersion) < 4) {
window.history.go(0);
}}}</script></head><body><p>&nbsp;</p>
<font color="#000066">说明:适用于IE4,IE5.5,IE5,NS4+,NS6。早期版本的IE5.0可能无法工作。</font> 
<center>
<form name="globe">
<table width="80%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<select  onChange="populatemxhweb(document.globe,this.options[selectedIndex].value)">
<option>请选择
<option value="meng">http://lucky.myrice.com
<option value="meng1">http://go.163.com/colorweb
<option value="meng2">http://egirl.51.net
</select>
</td>
<td>
<select name="mxhweb" onChange="window.open('http://egirl.51.net')">
<option value=''>☆ 请选择上面的选项 ☆</option>
</select>
</td>
</tr>
</table>
</form>
</center>
</body>
</html>

解决方案 »

  1.   

    大致思路这样:怎样添加或删除下拉列表框的选项??
    可以通过下面的办法产生一个新的option:var opt = new Option('text', 'value');并通过下面的办法插入到列表框的最后位置上:var sel = document.formName.selectName;
    sel.options[sel.options.length] = opt;
      要删除一个列表框的某个OPTION,可以用下面的方法:  var sel = document.formName.selectName;
      sel.options[optionIndex] = null;这里值得注意的一点是:WINDOWS和MAC平台上的NN2/3/4可以插入到相应的位置,但浏览器里并不更新,要解决此问题,必须对浏览器进行刷新: 
      

  2.   

    关于读值:
    <form name="globe">
    <select name=mxh1  onChange='alert("option.value = "+ document.globe.mxh1.options[selectedIndex].value);alert("option.txt = "+ document.globe.mxh1.options[selectedIndex].text);alert("option.innerHTML = "+ document.globe.mxh1.options[selectedIndex].innerHTML);alert("option.outerHTML = "+ document.globe.mxh1.options[selectedIndex].value);
    '>
    <option>请选择
    <option value="meng">http://lucky.myrice.com
    <option value="meng1">http://go.163.com/colorweb
    <option value="meng2">http://egirl.51.net
    </select>
    </form>你可以把代码发过来!
    [email protected]