js 对象不支持此属性或方法
js运行到这一步 opener.selectCust(selectText,selectValue);报错,但是我已经定义了function selectCust() {}为什么啊,始终找不出原因
[最优解释]
也可以的好不好
[其他解释]
恩,是可以。
为啥不直接调用,而用opener.呢,这个好像不行。
[其他解释]
把所有js都贴出来看看。
[其他解释]
function selectCustOk(){
var selectedcust = document.getElementById('selectedcust');
var selectText = "";
var selectValue = "";
for(var i=0; i<selectedcust.options.length; i++){
var temp = selectedcust.options[i].text.split('
[其他解释]
');
if(selectText == ""){
selectText = temp[1];//selectedcust.options[i].text;
} else {
selectText = selectText + "," + temp[1];//selectedcust.options[i].text;
}
if(selectValue == ""){
selectValue = selectedcust.options[i].value;
} else {
selectValue = selectValue + "," + selectedcust.options[i].value;
}
}
opener.selectCust(selectText,selectValue);
window.close();
}
function unSelectCust(){
var unselectedcust = document.getElementById('unselectedcust');
if(!unselectedcust){
var htmlStr = '<select name="unselectedcust" multiple="multiple" style="width: 100%" size="20" ondblclick="dbClick(this);"></select>';
var norecd = document.getElementById("norecd");
norecd.innerHTML = htmlStr;
unselectedcust = document.getElementById('unselectedcust');
}
var selectedcust = document.getElementById('selectedcust');
if(selectedcust.selectedIndex == -1){
return;
}
for(var i=0; i<selectedcust.options.length; i++){
var selectText = selectedcust.options[i].text;
var selectValue = selectedcust.options[i].value;
if(selectValue==""){
selectedcust.options[i].selected = false;
continue;
}
if(selectedcust.options[i].selected){
var length = unselectedcust.options.length;
unselectedcust.options.add(new Option(selectText,selectValue));
unselectedcust.options[length].selected = true;
selectedcust.options.remove(i--);
}
}
}
[其他解释]
function selectCust() {
var unselectedcust = document.getElementById('unselectedcust');
var selectedcust = document.getElementById('selectedcust');
if(unselectedcust.selectedIndex == -1){
return;
}
for(var i=0; i<unselectedcust.options.length; i++){
var selectText = unselectedcust.options[i].text;
var selectValue = unselectedcust.options[i].value;
if(selectValue==""){
unselectedcust.options[i].selected = false;
continue;
}
if(unselectedcust.options[i].selected){
//判断是否存在
for(var j=0; j<selectedcust.options.length;j++){
var exsitValue = selectedcust.options[j].value;
if(selectValue == exsitValue) {
return false;
}
}
var length = selectedcust.options.length;
selectedcust.options.add(new Option(selectText,selectValue));
selectedcust.options[length].selected = true;
unselectedcust.options.remove(i--);
}
}
}
[其他解释]
你那个方法有形参么,好像没有把。