Grey out or disable form?

Discussion in 'Javascript' started by J Belly, Feb 4, 2005.

  1. J Belly

    J Belly Guest

    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 :)
     
    J Belly, Feb 4, 2005
    #1
    1. Advertising

  2. J Belly

    Joakim Braun Guest

    "J Belly" <> skrev i meddelandet
    news:...
    > 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.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
     
    Joakim Braun, Feb 6, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. AAA
    Replies:
    0
    Views:
    524
  2. Anony!

    How to "grey out" a JButton?

    Anony!, Aug 15, 2004, in forum: Java
    Replies:
    3
    Views:
    826
    zoopy
    Aug 16, 2004
  3. RC
    Replies:
    2
    Views:
    14,439
    Roedy Green
    Apr 11, 2006
  4. Karl

    Javascript grey out

    Karl, Feb 15, 2009, in forum: HTML
    Replies:
    2
    Views:
    1,143
    Harlan Messinger
    Feb 15, 2009
  5. acord

    grey-out/disabled item in listbox

    acord, Mar 11, 2006, in forum: Javascript
    Replies:
    3
    Views:
    265
    acord
    Mar 11, 2006
Loading...

Share This Page