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

Making checkboxes and radio buttons readonly

Status
Not open for further replies.

charlesb

IS-IT--Management
Dec 14, 2001
26
GB
I have a page I have generated to allow inserts, amendments and to display record details from a table.

I can conditionally control whether all fields on the page are read only or not except for the checkboxes and radio buttons.

Obviously as there is no submit button for display purposes the users cannot actually change database information. However, I would like to stop them being able to click on and seemingly change these box values.

Any ideas how I do this. All help greatly appreciated.

 
two ways I can think of.
1) DISABLED in the input tag should handle that.
ex:
<input type=checkbox name=blah disabled checked>

2) use an image of a checkbox/radio instead
 
do u mean to just display the fields in checkbox and radio buttons BUT not allow modifications? Try this:

<input type=&quot;radio&quot; name=&quot;field1&quot; value=&quot;xx&quot; disabled>

the same should apply to checkbox :p
It might only for IE, not Netscape!
 
Thanks for the suggestions, I can use disabled, however, it obscures the value. PRefer if can to make readonly. Also need to make the readonly conditional. I presume I could make the disabled conidtional ,but would still have the 'gray' problem.

 
You could always add a little onClick function that will negate their clicking:

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
function changeBox(checkBox) {

if (checkBox.checked) checkBox.checked = false;
else checkBox.checked = true

}
</SCRIPT>
.
.
.
<input type=checkbox name=blah checked onClick=&quot;changeBox(this)&quot;>
Mise Le Meas,

Mighty :)
 
Let me explain the code from bellow:
You have 3 option coming from the database:
Approved, Reeject, Nothing
And you have 2 radiobuttons with the same name:
if the value it's approved the first one is checked
if the value it's rejected the second one is checked
if the value it's nothing none is checked

And everything is readonly, so that the user can not modify anything. Hope it will help you

Durug

<%if rsInfoOrderItem(&quot;Approved&quot;) = &quot;YES&quot; then%>
Approve: <input name=Approve type=radio value=1 checked>&nbsp;
Reject: <input name=Approve type=radio value=2 onClick=&quot;document.forms[0].Approve[0].checked = 'true'&quot;>
<%elseif trim(rsInfoOrderItem(&quot;Approved&quot;)) = &quot;NO&quot; then%>
Approve: <input name=Approve type=radio value=1 onClick=&quot;document.forms[0].Approve[1].checked = 'true'&quot;>&nbsp;
Reject: <input name=Approve type=radio value=2 checked>
<%else%>
Approve: <input name=Approve type=radio value=1 onClick=&quot;return false;&quot;>&nbsp;
Reject: <input name=Approve type=radio value=2 onClick=&quot;return false;&quot;>
<%end if%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top