Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to find out if a field is readonly or not?

Status
Not open for further replies.

vthv

Technical User
Sep 14, 2007
2
US
Hi,

On a web application, I need to detect if a field is readonly or not, but I can't find any VBScript code to accomplish this task. If the field is not readonly, I then need to populate some data into it. Do you have any suggestions for me?

Thank you in advance, and Happy Holidays!

Tim.
 
Typed, not tested. But, it should point you in the right direction. The error handling is in there because I don't know if all <input> tags have a readOnly property. Also, I'm pretty sure the .name property will throw an error if the <input> doesn't have one set.

Code:
Dim colInputs, oInput
Set colInputs = document.getElementsByTagName("input")
For Each oInput In colInputs
  On Error Resume Next
  If oInput.readOnly Then
    Alert oInput.name & ".readOnly=True"
  Else
    Alert oInput.name & ".readOnly=False"
  End If
  On Error Goto 0
Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top