Set radio buttons to readonly?

J

Jens Lenge

How can I display a group of radio buttons *without* making the displayed
selection changeable?
The 'readonly' attribute that does the job for text fields does not work for
radio buttons or checkboxes, at least this does not work:

<input type="radio" name="group1" value="Option 1" checked
readonly>&nbsp;Option 1<br>
<input type="radio" name="group1" value="Option 2" readonly>&nbsp;Option
2<br>

(The 'readonly's are ignored by Firefox and IE6, I can still change the
selection.)
I need this to display a submitted form after all data is processed, so I
don't want the user to be able to change it again.

Jens
 
P

Philip Ronan

Jens said:
How can I display a group of radio buttons *without* making the displayed
selection changeable?

I need this to display a submitted form after all data is processed, so I
don't want the user to be able to change it again.

Sounds like you're generating a confirmation page inside the server, so why
don't you just do something like this instead:

<img src="checked.gif" alt="[x]>&nbsp;Option 1<br>
<img src="unchecked.gif" alt="[ ]">&nbsp;Option 2<br>
 
J

Jens Lenge

Philip Ronan said:
Sounds like you're generating a confirmation page inside the server,

Yes, exactly.
so why don't you just do something like this instead:

<img src="checked.gif" alt="[x]>&nbsp;Option 1<br>
<img src="unchecked.gif" alt="[ ]">&nbsp;Option 2<br>

I thought about it, but as I'd like to use the same code for entry and
confirmation as far as possible, it would be truly nice to get along with
"true" radio buttons instead of images.
 
J

JDS

Philip Ronan said:
Sounds like you're generating a confirmation page inside the server,

Yes, exactly.
so why don't you just do something like this instead:

<img src="checked.gif" alt="[x]>&nbsp;Option 1<br> <img
src="unchecked.gif" alt="[ ]">&nbsp;Option 2<br>

I thought about it, but as I'd like to use the same code for entry and
confirmation as far as possible, it would be truly nice to get along with
"true" radio buttons instead of images.

look into the "disabled" attribute. Might require JavaScript to set it,
not sure. Also, not sure if it is valid in all browsers.

example:
document.the_form[0].disabled = true;

later...
 
I

ikke

JDS said:
Sounds like you're generating a confirmation page inside the server,

Yes, exactly.

so why don't you just do something like this instead:

<img src="checked.gif" alt="[x]>&nbsp;Option 1<br> <img
src="unchecked.gif" alt="[ ]">&nbsp;Option 2<br>

I thought about it, but as I'd like to use the same code for entry and
confirmation as far as possible, it would be truly nice to get along with
"true" radio buttons instead of images.


look into the "disabled" attribute. Might require JavaScript to set it,
not sure. Also, not sure if it is valid in all browsers.

example:
document.the_form[0].disabled = true;

later...
this works on mozila "it only makes the checkbox gray"

<html>
<body>
<form action=url-goes-here method=get>

<P><input type=checkbox name=checkbox checked disabled></P>

<P><input type=reset name=myReset value="reset me"> " "
<input type=submit name=submit value=submit>
</form>
</body>
</html>

greetings
 
J

Jens Lenge

ikke said:
this works on mozila "it only makes the checkbox gray"
[...]
<P><input type=checkbox name=checkbox checked disabled></P>

Also works in IE6 - great!
Thank you all for your help!
 
A

Adrienne

ikke said:
this works on mozila "it only makes the checkbox gray"
[...]
<P><input type=checkbox name=checkbox checked disabled></P>

Also works in IE6 - great!
Thank you all for your help!

But does it still work in your script? Are you still able to get the
value? AFAIK, once the control is disabled, it does not pass its value.
You would have to put the value into a hidden control.
 
J

Jukka K. Korpela

Jens Lenge said:
as I'd like to use the same code for entry and
confirmation as far as possible,

But not farther, I hope. They have different functions, hence they
should be suitably different.
it would be truly nice to get
along with "true" radio buttons instead of images.

No, it wouldn't. A radio button is something you can select. It's a
control to be used, not a symbol of a choice that has been made.
How you indicate the choice made depends on the context and even on
matters of taste, but quite often the best approach is to present just
the chosen alternative. There's no need for any particular symbol for
indicating selection then.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top