Announcement

Collapse
No announcement yet.

Javascript help! got the code, need to reverse effects.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Javascript help! got the code, need to reverse effects.

    This is the code:

    At the moment, it disables checkboxes via a master checkbox.

    But what I want it to do is ENABLE the checkboxes via the master checkbox.

    Also, the master checkbox has to be a radio, or at least function like a radio.

    Any help?

    (and yes, I have tried coding forums and sites, I'm desperate to get this sorted out today!)

    edit: code tags aren't working

    =======================================
    // The check box group is definded by the check boxes with a parent of the same title
    // A check box with a parent node of the group title suffixed with 'f7_Master'
    // is used to set the disable status of the other check boxes
    // Example HTML Code for one group
    //
    //

    //

    //

    //


    //
    // Master

    //


    // or to force the disabled group into a checked state of checked use
    //
    // Master

    //


    // or to force the disabled group into a checked state of unchecked use
    //
    // Master

    //




    // Each group is initialised from a onload event
    //
    // where

    // All variable, function etc. names are prefixed with 'f7_' to minimise conflicts with other javascripts


    var f7_cks;

    function f7_DisableCBGroup(){
    f7_cks=document.getElementsByTagName('INPUT');
    for (f7_0=0;f7_0 if (f7_cks[f7_0].type=='checkbox'){
    if (f7_cks[f7_0].parentNode.title.match('f7_Master')){
    f7_cks[f7_0].parentNode.state=f7_cks[f7_0].parentNode.title.split('f7_Master')[1];
    f7_cks[f7_0].parentNode.title=f7_cks[f7_0].parentNode.title.replace(f7_cks[f7_0].parentNode.state,'')
    f7_Disable(f7_cks[f7_0])
    f7_cks[f7_0].onclick=function(){ f7_Disable(this); }
    }
    }
    }
    }

    function f7_Disable(f7_obj){
    for (f7_1=0;f7_1 if (f7_cks[f7_1].parentNode.title==f7_obj.parentNode.title.replace ('f7_Master','')){
    if (f7_obj.checked){
    f7_cks[f7_1].setAttribute('disabled',true)
    if (f7_obj.parentNode.state=='CHECK'){
    f7_cks[f7_1].checked=true;
    }
    if (f7_obj.parentNode.state=='UNCHECK'){
    f7_cks[f7_1].checked=false;
    }
    }
    else {
    f7_cks[f7_1].removeAttribute('disabled')
    }
    }
    }
    }


    //-->
    =======================================
    be free

  • #2
    Set the checkboxes' initially to disabled. Set a script associated on the master checkbox's onclick handler. It checks the state of the master checkbox - if checked, enables other checkboxes, if unchecked, disables other checkboxes.
    (\__/) 07/07/1937 - Never forget
    (='.'=) "Claims demand evidence; extraordinary claims demand extraordinary evidence." -- Carl Sagan
    (")_(") "Starting the fire from within."

    Comment


    • #3
      Yes, that's the simple way of doing it.

      But then multiply this by 4 and you will face problems.

      This form has 4 sections, and in each section are 2 checkboxes.

      A section has to be enabled before the 2 checkboxes in the corresponding section are enabled for use.
      be free

      Comment


      • #4
        Yeah, I can see it getting tedious, though still pretty simple. Copying and pasting sections of code plus some minor changes (names of elements) should do the trick.
        (\__/) 07/07/1937 - Never forget
        (='.'=) "Claims demand evidence; extraordinary claims demand extraordinary evidence." -- Carl Sagan
        (")_(") "Starting the fire from within."

        Comment


        • #5
          I said stuff it, and did some experimenting.

          And lo and behold, it worked.

          WOO!!

          And I know about .05% of javascript.

          edit: ok, code won't display, and I can't be arsed to work out why.

          Now I just have to set it for the other 3 Options!

          YEAH! Now I see where programmers get their kicks!
          Code:
           
          be free

          Comment

          Working...
          X