Readonly Checkboxes

Results 1 to 6 of 6

Thread: Readonly Checkboxes

  1. #1
    Joseph Hatcher Guest

    Default Readonly Checkboxes

    Anyone now how to make a true readonly checkbox where people cant click on it and change the contents. I know I can make it disabled but then it is gray and hard to read. This seems like a trivial problem but it has me stumped. Things I have tried.<BR><BR>&#060;input type=checkbox onfocus="this.blur()"><BR>This did not work.<BR><BR>&#060;input type=checkbox onclick="this.blur()"><BR>This did not work<BR><BR>&#060;input type=checkbox readonly><BR>This does not work (readonly works in IE for other fields but not for checkboxs and does not work for Netscape)<BR><BR>I am thinking about making 2 pictures a checked picture and a non-checked picture and using these. This is a crappy work around and I am looking for a better solution and ideas would be great.

  2. #2
    Bryan Murphy Guest

    Default RE: Readonly Checkboxes

    How about setting OnClick to Click it again - uncheck it whenever<BR>the user checks it? Haven&#039t tried it, but it sounds amusing.<BR><BR>Good luck.

  3. #3
    Joseph Hatcher Guest

    Default RE: Readonly Checkboxes

    From what I can determine you can set the checked value when the page loads.<BR>For example:<BR>&#060;input type="checkbox" name="checkbox_name" &#060;%if (need_checked) then&#037;&#062; checked &#060;%end if&#037;&#062;><BR><BR>But after this you can only determine if the checkbox is checked or not.<BR>For example<BR>document.form_name.checkbox_name.checke d <BR>either returns TRUE or FALSE<BR><BR>I can not figure out how to set the checkbox once the page is loaded.<BR><BR>By the way, I did try <BR>if (document.form_name.checkbox_name.checked){<BR>dou cment.form_name.checkbox_name=False<BR>}<BR><BR>Th is did not work.<BR><BR>I am willing to try any other suggestions :)<BR><BR>Joseph Hatcher

  4. #4
    Join Date
    Dec 1969
    Posts
    119

    Default RE: Readonly Checkboxes

    &nbsp;<BR>document.frmTest.checkbox1.checked = true <BR>sets the checkbox on <BR><BR>This is working in Netscape, I havent tried it in IE


  5. #5
    Join Date
    Dec 1969
    Posts
    119

    Default RE: Readonly Checkboxes

    Hi, I used the following code to test. Its <BR>working in Netscape<BR>===============<BR><BR>&#060;html><BR> &#060;head><BR> &#060;SCRIPT LANGUAGE=javascript><BR> &#060;!--<BR> function dothis(){<BR> document.frmTest.checkbox1.checked = true <BR> }<BR> <BR> function dothis2(){<BR> document.frmTest.checkbox1.checked = false<BR> }<BR> <BR> function Hello(){<BR> x = document.frmTest.checkbox1.checked<BR> <BR> if(x==true){<BR> document.frmTest.checkbox1.checked = false<BR> }<BR> else<BR> {<BR> document.frmTest.checkbox1.checked = true<BR> } <BR> }<BR> <BR> //--><BR> &#060;/SCRIPT><BR>&#060;/head><BR>&#060;body><BR> &#060;form name=frmTest><BR> &#060;INPUT type="checkbox" id=checkbox1 name=checkbox1 onClick="Hello();"><BR> &#060;INPUT type="button" value="Button" id=button1 name=button1 onClick="javascript:dothis();"><BR> &#060;INPUT type="button" value="Button" id=button1 name=button1 onClick="javascript:dothis2();"><BR> &#060;INPUT type="text" id=text1 name=text1><BR> &#060;/form><BR>&#060;/body><BR>&#060;/html><BR><BR>

  6. #6
    Joseph Hatcher Guest

    Default RE: Readonly Checkboxes

    Manish,<BR><BR>Thanks a bunch for the help. One of the problems was I was using TRUE instead of true. Javascript does not recognize a capital boolean. I have modified your code to make a more generic form.<BR><BR>&#060;html><BR>&#060;body><BR>&#060;f orm><BR>&#060;INPUT type="checkbox" id=checkbox1 name=checkbox1 onclick="if (this.checked){this.checked=false;}else{this.check ed=true;}"><BR>&#060;/form><BR>&#060;/body><BR>&#060;/html>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •