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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

read only checkbox

Status
Not open for further replies.

lucyc

Programmer
Mar 1, 2002
62
0
0
US
Hi,

I want to create a checkbox which is read only. I tried readonly=true, but it doesn't work on checkbox. Can someone help????
 
Try DISABLED instead of READONLY=TRUE:
ex. [tt]<input type=checkbox disabled value=whatever checked>[/tt] Paul Ellis
[hammer] I've been programming since you had to punch holes in cards to code. (Always remember, number your cards!)
 
I can't use request.form to get the value of the checkbox, once I used Disabled. Is there anyway to get the value of the checkbox and also disabled it??????
 
[tt]<input type=hidden name=fauxCheckbox value=&quot;SomeValueHere&quot;>[/tt] Paul Ellis
[hammer] I've been programming since you had to punch holes in cards to code. (Always remember, number your cards!)
 
Hello Paul,

I have the following in my page but it doesn't work . The problem is the value in cbEX is always equal to ON, even the checkbox is not checked. Seems to me that if the input type is hidden, it treats as a text box and the value=ON becomes the default value for cdEX.

<input type=&quot;hidden&quot; name=&quot;cbEX&quot; value=&quot;ON&quot; checked>
After I posted the data, I use request.form(&quot;cbEX&quot;) to get the value, it always equal to &quot;ON&quot; even the checkbox is not checked.

Any idea what did I do wrong????
 
OK, we've got two things going on here.
[ol][li][tt]DISABLED[/tt] for the checkbox. This is just for the user to see (apparently).[/li]
[li][tt]INPUT TYPE=HIDDEN[/tt]. This is for your coding purposes.[/li][/ol]
Now, whatever code sets the checked property of the checkbox (either CHECKED or not) should then set the value of the hidden field to the value of the checkbox, if the checked property is set to true.

OR

[ol][li]HTML
[tt]
<form name=&quot;blahblahblah&quot;[/tt] ... [tt]onsubmit=&quot;return cbChk(this);&quot;>
[/tt] ... [tt]
<input name=cb type=checkbox disabled value=&quot;whatever&quot; checked>
[/tt] ... [tt]
<input name=cbEX type=hidden value=&quot;&quot;>
[/tt]
...[/li]
[li]JavaScript
[tt]
function cbChk(oform){
oform.cb.disabled=false;
if(oform.cb.checked){
oform.cbEX.value=oform.cb.value;
}
oform.cb.disabled=true;
return(true);
}
[/tt][/li][/ol]

Either way should work. Paul Ellis
[hammer] I've been programming since you had to punch holes in cards to code. (Always remember, number your cards!)
 
Or, you could do it that way, it would be easier [wink] ! Paul Ellis
[hammer] I've been programming since you had to punch holes in cards to code. (Always remember, number your cards!)
 
Hello FengShui;

I don't get it. Where do you put that???
 
Hello Paul and FengShui,

Here is what I want to do: On my form I have 10 combo box that users can select their option and on each option, I have 3 checkbox and a text box to key in a date. Once a date is filled on the text box(DateResolvedO), checkbox will be disabled. If user already selection the option from previous time, I want to display the combo box with the option that they selected as well as the all 3 checkbox with the check that they checked. Those combo boxes are visible to the user only if they click on a button to open it or if a option is selected previously.

For nOTH=0 to 9
If Not objRecData.EOF Then
If objRecData(&quot;EXO&quot;) <> 0 Then valEXO = &quot;CHECKED&quot;
If objRecData(&quot;RNO&quot;) <> 0 Then valRNO = &quot;CHECKED&quot;
If objRecData(&quot;SNO&quot;) <> 0 Then valSNO = &quot;CHECKED&quot;
If objRecData(&quot;DateResolvedO&quot;)<>&quot;&quot; then DisOthcheckbox = &quot;Disabled&quot;
If objRecData(&quot;DateResolvedO&quot;)<>&quot;&quot; then DisResolvedDateO= &quot;ReadOnly=True&quot;
valDateResolvedO = objRecData(&quot;DateResolvedO&quot;) & &quot;&quot;
valCommentsO = objRecData(&quot;CommentsO&quot;) & &quot;&quot;

if valEXO=&quot;CHECKED&quot; then
EXvalueO=&quot;ON&quot;
else
EXvalueO=&quot;&quot;
end if

if valRNO=&quot;CHECKED&quot; then
RNvalueO=&quot;ON&quot;
else
RNvalueO=&quot;&quot;
end if

if valSNO=&quot;CHECKED&quot; then
SNvalueO=&quot;ON&quot;
else
SNvalueO=&quot;&quot;
end if

else
'***** this is where I don't know how to do, I try many many way, either I am not
'***** the value set or getting error message. I want to do this--
'***** If record doesn't exist then check the checkbox value to see if it is checked.
'***** 'If checked set hidden field value to ON

'
End If

response.write &quot;<td width='0%'><input type='checkbox' name='cbOTHEX&quot; & nOTH & &quot;' value='ON' &quot; & valEXO & &quot; &quot; & DisOthcheckbox & &quot; onClick='checkEXO(&quot; & nOTH & &quot;)'></td>&quot;
response.write &quot;<input type='hidden' name='cbOTHEXh&quot; & nOTH & &quot;' value='&quot; & EXvalueO & &quot;'></td>&quot; & vbCrLf

response.write &quot;<td width='0%'><input type='checkbox' name='cbOTHRN&quot; & nOTH & &quot;' value='ON' &quot; & valRNO & &quot; &quot; & DisOthcheckbox & &quot; onClick='checkRNO(&quot; & nOTH & &quot;)'></td>&quot;
response.write &quot;<input type='hidden' name='cbOTHRNh&quot; & nOTH & &quot;' value='&quot; & RNvalueO & &quot;'></td>&quot; & vbCrLf

response.write &quot;<td width='0%'><input type='checkbox' name='cbOTHSN&quot; & nOTH & &quot;' value='ON' &quot; & valSNO & &quot; &quot; & DisOthcheckbox & &quot; onClick='checkSNO(&quot; & nOTH & &quot;)'></td>&quot;
response.write &quot;<input type='hidden' name='cbOTHSNh&quot; & nOTH & &quot;' value='&quot; & SNvalueO & &quot;'></td>&quot; & vbCrLf

response.write &quot;<td width='141'><center><input type='text' name='txtOTHDateResolved&quot; & nOTH & &quot;' size='13' Value='&quot; & valDateResolvedO & &quot;'&quot; & &quot; &quot; & DisResolvedDateO & &quot;>&quot;

response.write &quot;<td width='0%'><input type='button' value='Desc/Steps' name='btnOTHDesc' onClick='ViewDetails2(&quot; & nOTH & &quot;)'></td>&quot; & vbCrLf
response.write &quot;</tr></table></div>&quot; & vbCrLf

this is driving me nut. I have been trying and trying all day yesterday and today. If there is a better way to do this, please let me know. Thanks in advance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top