468,758 Members | 2,104 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,758 developers. It's quick & easy.

Grey out or disable form?

Hi,

I have a table of questions (with radio buttons) that I want to appear
greyed out so that users can feel they can skip it and go on to the
next page. But if they should choose to answer the questions, I'd
want them to uncheck a checkbox so that the table would appear white.
How do I do this? (If I can also disable the radio buttons at the
same time, that would even be better.)

Also, I'd need it to work in both IE and Netscape/Mozilla.

Thanks for the help!

(And step-by-step coding would be GREATLY appreciated, as I'm a total
javascript newbie :)
Jul 23 '05 #1
1 16268
"J Belly" <me@privacy.net> skrev i meddelandet
news:0v********************************@4ax.com...
Hi,

I have a table of questions (with radio buttons) that I want to appear
greyed out so that users can feel they can skip it and go on to the
next page. But if they should choose to answer the questions, I'd
want them to uncheck a checkbox so that the table would appear white.
How do I do this? (If I can also disable the radio buttons at the
same time, that would even be better.)

Also, I'd need it to work in both IE and Netscape/Mozilla.

Thanks for the help!

(And step-by-step coding would be GREATLY appreciated, as I'm a total
javascript newbie :)


You can use the "disabled" attribute in HTML:
<input type="radio" name="somename" disabled>

....and set it in Javascript (looping a radio button array):
var radios = document.forms["someform"].elements["somename"];
for(var i = 0, max = radios.length; i < max; i++){
radios[i].disabled=1; //Or 0 for enabling it
}

For the table background and the text, you could create different CSS
classes and then do:

var thing = document.getElementById("someid");

if(thing)
thing.className="myGrayedOutCSSname";

Add an onclick handler to the checkbox that calls a function that takes
care of enabling/disabling:

<input type="checkbox" name="somename"
onclick="toggleTableState(this.checked);">

then in the <head>:

function toggleTableState(inEnable){

// Enable/disable radio buttons
// Set className of whatever it is that should look different
}
--
Joakim Braun

Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by tottigang | last post: by
4 posts views Thread by Chris | last post: by
5 posts views Thread by acord | last post: by
4 posts views Thread by Patrick Flaherty | last post: by
reply views Thread by Ahmad Jalil Qarshi | last post: by
3 posts views Thread by BrendanMcPherson | last post: by
reply views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.