checkboxes in dashcode.

Discussion in 'Web Design and Development' started by MDMstudios, Mar 21, 2010.

  1. MDMstudios macrumors member

    Joined:
    Mar 18, 2008
    #1
    Okay, so I got this project, in which I am trying to just set a checkbox to true or false depending on the button they click. My code is essentially this

    Code:
    
    var checkbox;
    
    function load()
    {
        dashcode.setupParts();
        checkbox = document.getElementById("checkbox");
    }
    
    function deselectGroup1(event)
    { // this function is correctly hooked up to the on click event for a button.
        checkbox.checked = false;
    }
    
    function selectGroup1(event)
    { // this function is correctly hooked up to the on click event for another button.
        checkbox.checked = true;
    }
    
    However, the checkbox doesn't ever change its appearance. I did some tests, and it says the value of checked is undefined before I call one of these functions. I am attaching checkbox to the correct element, and I have tried setting checked in the load function, however nothing works.

    I have also tried starting a new project to see if one project was just acting weird, however in the new project nothing changed either.

    Any help?
     
  2. Cerebrus' Maw macrumors 6502

    Joined:
    Mar 9, 2008
    Location:
    Brisbane, Australia
  3. MDMstudios thread starter macrumors member

    Joined:
    Mar 18, 2008
    #3
    It gets called by an HTML file Dashcode produces ( it works fully as well )
     
  4. Cerebrus' Maw macrumors 6502

    Joined:
    Mar 9, 2008
    Location:
    Brisbane, Australia
    #4
    The only reason I ask is that you could be calling the load function before the 'checkbox' element loads into the DOM, meaning that the element id 'checkbox' would not be loaded, and this usually assigns 'undefined' to the variable you try to assign it to in the javascript.

    I have never used dashcode, but if not, can you call the function using the body onload call?
    Code:
    <body onload="load();">
    
    html.....
    
    </body
    
     
  5. MDMstudios thread starter macrumors member

    Joined:
    Mar 18, 2008
    #5
    I have wondered that, however, I don't believe thats the problem, since even if I assign the variable on a button click it doesn't quite work. I know the load function is being called on the start as well (did some tests).
     
  6. dbourne macrumors newbie

    Joined:
    Jun 3, 2008
    #6
    Using the latest Dashcode v3.0.3

    Try
    checkboxValue.firstElementChild.checked
    instead of
    checkboxValue.checked
     

Share This Page