我正在尝试将函数中的变量分配给strSel
函数中outputSelected
的变量。实现这一目标的最佳方法是什么?TestVar
testResults
function getSelected(opt) {
var selected = new Array();
var index = 0;
for (var intLoop = 0; intLoop < opt.length; intLoop++) {
if ((opt[intLoop].selected) || (opt[intLoop].checked)) {
index = selected.length;
selected[index] = new Object;
selected[index].value = opt[intLoop].value;
selected[index].index = intLoop;
}
}
return selected;
}
function outputSelected(opt) {
var sel = getSelected(opt);
var strSel = "";
for (var item in sel)
strSel += sel[item].value + ",";
window.document.title = strSel;
}
function testResults (form) {
var TestVar = // Want to pass strSel here.
window.document.title=(TestVar);
}