I am facing a problem with a JavaScript readonly field. I have a textboxes which I am making readonly.
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);
}
It is working fine. Now to deactivate this readonly property I used
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';
}
But it is not working at all. Can any one please help me out of this problem or any suggestion or tips that can help me a lot regarding this (and why this is not working?).