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

一个struts的问题,请大家帮忙
今天遇到了一个问题,用一个例子描述一下
<script   type= "text/javascript ">
function   setMail()     {
var   flag   =   document.forms(0).check.checked;
if(flag)   {
document.forms(0).mail.disabled   =   false;
document.forms(0).re_mail.disabled   =   false;
}   else   {
document.forms(0).mail.disabled   =   true;
document.forms(0).re_mail.disabled   =   true;
document.forms(0).mail.value   =   " ";
document.forms(0).re_mail.value   =   " ";
}

}
</script>

<html:form   action= "/test?action=test "   >
<html:multibox   property= "check "   value= "0 "   onclick= "setMail(); "> PC </html:multibox>
<br> Mail   <html:text   property= "mail "/>
<br> Confirm   <html:text   property= "re_mail "/>
<br> No   <html:text   property= "no "/>

<input   type= "image ">
</html:form>
如果先将mail和re_mail赋值为a,提交,struts默认将form的mail,remail   no设置为 "a "   "a "   " "
因为我对no字段有校验所以,退回到test页面

此时test页面的text域值分别为 "a "   "a "   " "
此时我将no添为a,并点击check,用javascript将mail,和re_mail的值赋为 " ".当我再次提交的时候,struts并不执行setMail(),setRe_mail()方法,所以这个时候session中form的值为   "a "   "a "   "a "而不是我期望的 " "   " "   "a "。

请问为什么?另外如何实现我要的效果,比较郁闷啊

------解决方案--------------------
不好意思,自己找到了,是disabled的问题,不好意思