我面臨JavaScript只讀字段的問題。我有一個只讀的文本框。JavaScript只讀問題
if(val == true)
{
ddlCnt.value=objRec.iCntId;
tAdd1.value=objRec.sAddress1;
tAdd2.value=objRec.sAddress2;
tCity.value=objRec.sCity;
tState.value=objRec.sState;
tZip.value=objRec.sZip;
//tAdd1.disabled = tAdd2.disabled = tCity.disabled = tState.disabled = tZip.disabled = ddlCnt.disabled = true;
//tAdd1.disabled = tAdd2.disabled = tCity.disabled = tState.disabled = tZip.disabled = ddlCnt.disabled = true;
tAdd1.setAttribute("readonly", true);
tAdd2.setAttribute("readonly", true);
tCity.setAttribute("readonly", true);
tState.setAttribute("readonly", true);
tZip.setAttribute("readonly", true);
}
它工作正常。 現在停用此只讀屬性我用
else
{
tAdd1.value = tAdd2.value = tCity.value = tState.value = tZip.value = "";
//tAdd1.disabled = tAdd2.disabled = tCity.disabled = tState.disabled = tZip.disabled = ddlCnt.disabled = false;
ddlCnt.value="-1";
vsRec.innerHTML='';
tAdd1.setAttribute("readonly", false);
tAdd2.setAttribute("readonly", false);
tCity.setAttribute("readonly", false);
tState.setAttribute("readonly", false);
tZip.setAttribute("readonly", false);
//vsRec.style.visibility='hidden';
}
但它不工作。任何人都可以幫助我擺脫這個問題或任何建議或提示,可以幫助我很多關於此(以及爲什麼這是行不通的?)。
非常感謝,它工作正常。非常感謝你的幫助。 – 2011-05-20 06:48:22
我會接受你的答案。 3分鐘前沒有給你答覆的許可。 – 2011-05-20 06:50:43