已经定义好了一个控件,其中包含一个TextBox、listBox,现在实现将textBox值添加至listBox中,脚本代码是: function AddListBox() {
if (!document.getElementById) {
return true;
}
var newoption = document.createElement("OPTION");
var txtBox = document.getElementById("tbx1"); newoption.text = txtBox.value;
newoption.value = txtBox.value; var listBox = document.getElementById("listBox1");
listBox.add(newoption);
return false;
}这个代码在一个单独的页面可实现需要的功能,但是在自定义控件中,缺获取不到 var txtBox = document.getElementById("tbx1")的对象,这个控件是直接拖至页面的。之前通过后台代码也实现了这个功能,考虑到性能利用脚本实现。
请高手指点。
if (!document.getElementById) {
return true;
}
var newoption = document.createElement("OPTION");
var txtBox = document.getElementById("tbx1"); newoption.text = txtBox.value;
newoption.value = txtBox.value; var listBox = document.getElementById("listBox1");
listBox.add(newoption);
return false;
}这个代码在一个单独的页面可实现需要的功能,但是在自定义控件中,缺获取不到 var txtBox = document.getElementById("tbx1")的对象,这个控件是直接拖至页面的。之前通过后台代码也实现了这个功能,考虑到性能利用脚本实现。
请高手指点。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货