当前位置: 代码迷 >> Java Web开发 >> struts下checkbox的疑惑.解决方法
  详细解决方案

struts下checkbox的疑惑.解决方法

热度:50   发布时间:2016-04-17 13:49:24.0
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 ";
  相关解决方案