页面中的js代码:
function GetListbox() {
var listbox = document.getElementById("<%=listbox.ClientID %>");
var str = "";
//遍历Listbox,取值
if (listbox.options.length > 0) {
for (var i = 0; i < listbox.options.length; i++) {
var j = listbox.options[i].value;
str += j + ","; //把Value值串起来
}
}
alert(str);
var hands = $("#txtvalue");
hands.val(str);
}js文件中的js代码
function GetListbox(listboxid, txtid) {
var listbox = document.getElementById(listboxid);
var str = "";
//遍历Listbox,取值
if (listbox.options.length > 0) {
for (var i = 0; i < listbox.options.length; i++) {
var j = listbox.options[i].value;
str += j + ","; //把Value值串起来
}
}
alert(str);
var hands = $("#" + txtid);
hands.val(str);
}
为什么我把页面中的js代码放到js文件中后 j 的值是object
listbox.options[i].value; 里面有值大家帮下忙呀!!!
function GetListbox() {
var listbox = document.getElementById("<%=listbox.ClientID %>");
var str = "";
//遍历Listbox,取值
if (listbox.options.length > 0) {
for (var i = 0; i < listbox.options.length; i++) {
var j = listbox.options[i].value;
str += j + ","; //把Value值串起来
}
}
alert(str);
var hands = $("#txtvalue");
hands.val(str);
}js文件中的js代码
function GetListbox(listboxid, txtid) {
var listbox = document.getElementById(listboxid);
var str = "";
//遍历Listbox,取值
if (listbox.options.length > 0) {
for (var i = 0; i < listbox.options.length; i++) {
var j = listbox.options[i].value;
str += j + ","; //把Value值串起来
}
}
alert(str);
var hands = $("#" + txtid);
hands.val(str);
}
为什么我把页面中的js代码放到js文件中后 j 的值是object
listbox.options[i].value; 里面有值大家帮下忙呀!!!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货