Forum Moderators: open

Message Too Old, No Replies

disabled vs readonly attributes

         

umbluegray

7:36 pm on Mar 29, 2005 (gmt 0)



Using JSP and Javascript in IE 6.0.

My form contains address information displayed in text fields. By default the fields are disabled.

example:
<input type="Text" name="custAddress" size="25" maxlength="50" value="<%= businessObject.getAddress() %>" disabled>

The user can override the pre-populated address information by changing the 'Drop Ship' value from N to Y.

example:
<input type="Text" name="custDropShip" size="1" maxlength="1" value="N" onBlur="YesNoDS(this.value.toUpperCase())">

The YesNoDS(string) function clears the address field and enables it for data entry.

example:
function YesNoDS(answer)
{
try
{
if (answer == "Y")
{
document.form.custAddress.value = "";
document.form.custAddress.disabled=false;
}
}
catch (err)
{
alert("Debug: err = " + err);
}
}

The script works fine as it is.

I made the following changes:

<input type="Text" name="custAddress" size="25" maxlength="50" value="<%= businessObject.getAddress() %>" readonly>

document.form.custAddress.readonly=false;

Now I get the debug message in the catch block:
Debug: err = Object Error

I need the address value when I submit the form. That's why I changed it from disabled to readonly.

Isn't readonly a boolean attribute like disabled is? I assume I can set it to false at run time.

Bernard Marx

7:25 am on Mar 30, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just a guess: readOnly