We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

readonly checkbox

lina000
lina000 asked
on
Medium Priority
1,341 Views
Last Modified: 2012-05-05
Hi all
I'm just wondering if there is away to display a "readonly" checkbox??

Thanks in advance.
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2006

Commented:
You can try using disabled="disabled", don't think readonly="readonly" will do the trick.

With disabled-property however, the checkboxs value will also not be submitted along with the form, so when using that one, you should add a hidden textfield if you need a value to be submitted.

-r-
Pravin AsarPrincipal Systems Engineer
CERTIFIED EXPERT
Top Expert 2005

Commented:
If you want user not to be able to uncheck the checkbox, you do always do following.

I am assuming, you want to inform user that her has selected certain option.


<p><input type="checkbox" value="1" onClick="this.checked=true;" checked >Check Box

This one set the box as checked always.

enabled = false
IT Expert
CERTIFIED EXPERT
Top Expert 2009
Commented:
In what browser world do you have an attribute called enabled?

How about this, assuming you checked in on the server:

<input type="checkbox" onClick="this.checked=this.defaultChecked" <%= (isChecked)? " checked":"" %>>

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Commented:
Here you go...

<html>
<head>
<title>mvan - Q_21772120 solution</title>

<script language="JavaScript">

function lockBox() {
  document.forms(0).name1.disabled=true;
  document.forms(0).name2.disabled=true;
}

</script>

</head>
<body onLoad="lockBox();">
<form>
<input type="checkbox" name=name1 value="1" checked >Static Check Box<br>
<input type="checkbox" name=name2 value="2" >Static Check Box<br>
<input type="checkbox" name=name3 value="3" >Active Check Box<br>
</form>
</body>
</html>

mvan
Michel PlungjanIT Expert
CERTIFIED EXPERT
Top Expert 2009

Commented:
document.forms is an array, not a collection

 document.forms[0]

Commented:
mplungjan,

Thank you.  

In IE, either worked: .forms(0) or .forms[0] .  MS let me get away with sloppy code, I guess.  : 0

I don't have FF on this computer, so I can't test it at this time.

mvan

Author

Commented:
Thanks all for replying!
The thing is that I need to display the checkbox not disabling it! because sometimes the user needs to print the form and in the same time I don't want him to check or uncheck the box so basically it will be used to displaying and later printing!!

Commented:
... so you needed the image of a checkbox (probably unchecked) that the user could not check on-line, so they could print it out (unchecked) and fill in the paper copy.  I guess the disabled checkbox did not do that for you, because it became greyed out?  Oh well...

mvan
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.