日期:2014-05-16  浏览次数:20404 次

有没有办法选了下拉菜单的值之后,文本框就显示值。
我有两个关联菜单。
我想选了后在文本框显示它们的值。
同时在window.open( "info.php?aid=下拉菜单一的值&bid=下拉菜单2的值 ", " ", " ", " ");也有它们的值。
清问怎么做?


------解决方案--------------------
onchange的时候将option的value(或text)保存到全局变量中,然后在需要的地方引用该全局变量的值。


<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script language= "Javascript ">
function fnSetSubItem_Combo(objCombo,objSubCombo,arrSubItems,strDefValue){
var i;
var bFound;

fnClearCombo(objSubCombo);

bFound=false;
for(i=0;i <arrSubItems.length;i++){
if(arrSubItems[i][1] + " " == objCombo.value + " "){
var oOption = document.createElement( "OPTION ");
objSubCombo.options.add(oOption);
oOption.text = arrSubItems[i][2];
oOption.value = arrSubItems[i][0];
if(strDefValue + " " == oOption.value + " "){
oOption.selected=true;
}
bFound=true;
}
}

if(!bFound && objSubCombo.options.length == 0)
objSubCombo.disabled=true;
else
objSubCombo.disabled=false;
//alert(objSubCombo.onchange());

if(objSubCombo.onchange)
objSubCombo.onchange();
}

function fnClearCombo(objCombo){
var i,intLen;
//objCombo.selectedIndex=-1;
if(objCombo.Proced ==1){
intLen=objCombo.options.length;
for(i=0;i <intLen-objCombo.FirstIdx;i++){
objCombo.options[objCombo.FirstIdx]=null;
//objCombo.options.remove(0);
}
}
else{
objCombo.FirstIdx=objCombo.options.length;
objCombo.Proced =1;
}
}

function fnSetCityProv(objParObj,objSubObj,arrCPC){
objSubObj.options.length=0;
//取得当前选中的ID,递归取得所有子ID
for(i=0;i <arrCPC.length;i++){
if(arrCPC[i][0] == objParObj.value){
objSubObj.options[objSubObj.options.length]=new Option(arrCPC[i][2],arrCPC[i][0]);
}
}

fnGetCPCSubItems(objParObj,objSubObj,arrCPC,objParObj.value,0);
}

function fnGetCPCSubItems(objParObj,objSubObj,arrCPC,intParID,intLV){
var i;
var strCaption;

for(i=0;i <arrCPC.length;i++){
if(arrCPC[i][1] == intParID){
switch(intLV){
case 0:strCaption= " -- " + arrCPC[i][2];break;
case 1:strCaption= " -- " +arrCPC[i][2];break;
}

objSubObj.options[objSubObj.options.length]=new Option(strCaption,arrCPC[i][0]);
if(intLV <= 1)
fnGetCPCSubItems(objParObj,objSubObj,arrCPC,arrCPC[i][0],intLV+1)
}
}
}
</script>
<script language= "Javascript ">
//生成数组
function fnCreateArray(intHeight,intWidth){
var i,arrRet;
arrRet=new Array(intHeight);

for(i=0;i <intHeight;i++){
arrRet[i] = new Array(intWidth);
}
return arrRet;
}

</script>
<script language= "Javascript ">
<!--
/****Book Array(图书数组)******/
var arrBook;
arrBook=fnCreateArray(9,3);
arrBook[0][0]= "1 ";//子项value
arrBook[0][1]= "001 ";//父项value
arrBook[0][2]= "少儿科普读物 ";//子项text
arrBook[1][0]= "2 ";
arrBook[1][1]= "001 ";
arrBook[1][2]= "儿童简笔画 ";
arrBook[2][0]= "3 ";
arrBook[2][1]= "001 ";
arrBook[2][2]= "格林童话 ";
arrBook[3][0]= "