i have a table look like this:
--------------
[0] |apple | (readonly)
---------------
[1] | |
---------------
i can put [0].value to [1].value by entering the following script.
<script language="javascript">
document.all[txtField_1].value = document.all[txtField_0].value
</script>
However, the problem is i want to get the [0].readonly to [1] as well, i
failed to do that.
i've tried
if (document.all[txtField_0].readonly=true)
{
document.all[txtField_1].readonly=true;
}
else
{
document.all[txtField_1].readonly=false;
}
Please help
Ric Paton - 29 Aug 2005 16:05 GMT
> if (document.all[txtField_0].readonly=true)
> {
[quoted text clipped - 4 lines]
> document.all[txtField_1].readonly=false;
> }
The main problem there is your use of = instead of ==, the former an
assignment, the latter a comparison.
The second is your use of .readonly rather than .readOnly (remember JS
is case sensitive).
Although I wouldn't use the document.all collection - preferring the
standards compliant w3c method of document.getElementById() - however as
you are using it for your example, I will do the same..
document.all[txtField_1].readOnly = document.all[txtField_1].readOnly;
Hope this helps.
Ric.
A simple change of if (element.readOnly == true)_
Shahab Khan - 30 Aug 2005 00:11 GMT
Use document.all[txtField_1].readOnly=true;
"readonly" is case sensitive