日期:2014-05-18  浏览次数:20802 次

struts下checkbox的疑惑.
當我提交的時候判斷是否被選中.如果選中就讓它的值欸 "Y ",否則為 "N "

基本代碼如下:
<script>
...
if(thisForm.nowThesisDomain.checked){
thisForm.nowThesisDomain.value= "Y ";
alert(thisForm.nowThesisDomain.value);
}else{
thisForm.nowThesisDomain.value= "N ";
alert(thisForm.nowThesisDomain.value);

}
</script>


<html:checkbox   property= "nowThesisDomain "/>


當我選中的時候checkbox的值確實為 "Y ",但是我不選的時候就是 " "但執行上面的else時alert的是 "N ",不太明白..

------解决方案--------------------
?????
else{
thisForm.nowThesisDomain.value= "N ";
alert(thisForm.nowThesisDomain.value);

}

这个 "N "不是你自己设的吗?

------解决方案--------------------
thisForm.nowThesisDomain.value= "N ";
肯定
------解决方案--------------------
不明白
------解决方案--------------------
在From中设置
private NowThesisDomain = "N ";