B/S下,用javascript取checkbox或radiobox的值居然是乱码????????
灰大师 2005-07-04 09:26:09 var e=0
var c = document.getElementsByName("yumen"); yumen是checkbox,或radiobox
for( i = 0 ; i < c.length; i++)
{
if (c[i].checked) {
e++;
//alert(c[i].value); //只要是汉字就出来乱码
}
}
我搜索了一下,有人说把c[i].value换成c[i].text,alert出来是undefined
哈哈,于是乎我把yumen换成listbox
var e=0
var c=window.document.forms[0].yumen.length;
with (window.document.forms[0].yumen) {
for (n=0; n<c; n++) {
if (options[n].selected) {
alert(options[n].text);
e++;
}
}
}
c=4,可为什么不停的alert了??????应该只循环四次啊