How we can Set Form Element Readonly with Javascript ..
a piece of the code is here
opener.document.getElementById('jml_aset').setAttribute('readOnly','readOnly');
or the complete forum can be found here
Im affraid any lost.. Maybe copy any source code to this post is good idea...
<script type="text/javascript">
function blah(bool) {
if(bool) {
document.getElementById("ta").readOnly = true;
}
else {
document.getElementById("ta").readOnly = false;
}
}
</script>
<textarea id="ta"></textarea>
<input type="checkbox" onclick="blah(this.checked)" />
or this solution
[1] use setAttribute and removeAttribute
if(document.formOne.fieldInfo.checked)
{
document.forms['myFormId'].myTextArea.setAttribute('readOnly','readonly'); //2nd readonly more freedom
}
else //if(!document.formOne.fieldInfo.checked)
{
document.forms['myFormId'].myTextArea.removeAttribute('readOnly');
// also tried document.formOne.fieldtextarea.focus();
}
[2] property assignment
if(document.formOne.fieldInfo.checked)
{
document.forms['myFormId'].myTextArea.readOnly=true; //true has some freedom
}
else //if(!document.formOne.fieldInfo.checked)
{
document.forms['myFormId'].myTextArea.readOnly=false; //false has some freedom
// also tried document.formOne.fieldtextarea.focus();
}
Tidak ada komentar:
Posting Komentar