Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1292
  • Last Modified:

readonly checkbox

Hi all
I'm just wondering if there is away to display a "readonly" checkbox??

Thanks in advance.
0
lina000
Asked:
lina000
1 Solution
 
RoonaanCommented:
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-
0
 
Pravin AsarPrincipal Systems EngineerCommented:
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.

0
 
RainMan82Commented:
enabled = false
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
Michel PlungjanIT ExpertCommented:
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":"" %>>
0
 
mvan01Commented:
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
0
 
Michel PlungjanIT ExpertCommented:
document.forms is an array, not a collection

 document.forms[0]
0
 
mvan01Commented:
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
0
 
lina000Author 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!!
0
 
mvan01Commented:
... 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
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now