...

View Full Version : Make a form element read only only when. . .



Basscyst
12-31-2003, 07:46 PM
Hello -


I know I can make a field permenently read only with -

onfocus='this.blur();'

but how can I make a form element read only when a certain condition is met? ie. if one field is checked or filled out make the other field read only?

TIA,
Basscyst

Basscyst
12-31-2003, 08:27 PM
Ha! Staring blankley at your post really does help.



function readOnly(obj)
{
if(x!=y)
{
document.getElementById(obj).blur()
}

<input type="text" id="txt1" onfocus="readOnly('txt1')">


This will work - but is there not a way that I could set this up and just call the function like this: readOnly(this); So that It knows I am refering to the focused object? As I have it now by passing "this" - "this" would refer to the function not the object correct?

I think I need to create an object or somthing but I'm just not there yet.

Thanks Again,
Basscyst



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum