<Script language="JavaScript">
function ok() {
alert("ok");
var brandNoObj=document.getElementById("brandNo");
// brandNoObj.disabled = true;
brandNoObj.setAttribute("readOnly",'true');
alert(document.getElementById("brandNo").value);
document.all.loginForm.submit();
return false;
}
</script>
<body >
<s:form action="pptestList" id="form1" method="post"
namespace="/tranc/pptest">
<s:token />
<div>
<s:property value="#session.dblog.getBrchNo()" />ab
</div>
<div>
<s:textfield size="40" name="brandNo" id="brandNo" maxlength="30" value="%{#request.carinfo.brandNO}"/>
</div>
<div><s:submit
value="提交" method="execute" οnclick="ok();return false;" />
</div>
</s:form>
</body>
设置方法
brandNoObj.setAttribute("readOnly",'true');//还是可以进入控件,可以触发事件,可以在前后获得数据
brandNoObj.disabled = true; //不可以进入控件,事件也不会触发,但是,只能在前台获得数据,后台action得到的数据为null
如果非要用disabled,那就在提交前的瞬间,把它brandNoObj.disabled = false; ,就可以传到后台了