We help IT Professionals succeed at work.

Blur a check box?

Rougie asked
I have a form that is pre-populated from a database that I do not want the user to thik he/she has the ability to edit. For all of the text boxes and scrolling text boxes I use something like the following:

<input type="text" name="Value100s" size="21" tabindex="1" maxlength="20" onfocus="this.blur()" value="<%=objRS("Value100s")%>" style="color: #0000FF">

This works fine for most of the form, but the onfocus="this.blur()" does not work for check boxes. Is there a way to prevent the user from being able to check and uncheck check boxes?

Watch Question

<input .... disabled=true>

... but i think this is IE only..
Yes, that's IE only. Hence, you could use:
<input type=checkbox onclick="this.checked = false" disabled=true>

This works best in both browsers:

Use <img> in place of the checkboxes when you know you are in view mode. The image is a simulation of a checked and unchecked checkbox.

It's just display. And the image won't be big enough to slow down loading your page to the client's browser.

And as for your textboxes, If you know and you can flag that you are in view mode, don't use textboxes. Display them in plain HTML. Makes life a lot easier.

Now you don't have to worry about browser support. And you can easily explain: "Hey, it is in view mode, you know..."

I agree with etmendz that if the view is known to be read only, then why use text boxes at all. SImply populate the data in a <table> structure.



That works for me. I appreciate all the help and ideas, but this option work best for what I want to do.


Explore More ContentExplore courses, solutions, and other research materials related to this topic.