Connecting Tech Pros Worldwide Help | Site Map

Grey out or disable form?

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 23rd, 2005, 05:34 PM
J Belly
Guest
 
Posts: n/a
Default 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 :)



  #2  
Old July 23rd, 2005, 05:36 PM
Joakim Braun
Guest
 
Posts: n/a
Default Re: Grey out or disable form?

"J Belly" <me@privacy.net> skrev i meddelandet
news:0v9601l37l92ufe3l4tv7j67fo9jjh4cvm@4ax.com...[color=blue]
> 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 :)[/color]

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



 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.