Changing a checkbox's state programmatically in dashcode

前端 未结 8 1596
长发绾君心
长发绾君心 2021-02-15 01:28

Okay, so I\'m trying to change a checkbox\'s state programmatically in dashcode. I\'ve tried:

var checkbox = document.getElementById(\"checkbox\");

// I have tr         


        
相关标签:
8条回答
  • 2021-02-15 02:20
    cell = row.insertCell(-1);
    sel = document.createElement('input');
    sel.setAttribute("type", "checkbox")
    sel.setAttribute("name", "myCheckBox")
    cell.appendChild(sel);
    cell.getElementsByTagName('input')[0].checked = true;
    

    I create a table, row then cell and create a checkbox within it. I can the grab hold of the first input object and set the checked status to true.

    0 讨论(0)
  • 2021-02-15 02:22

    This question is one month old as I write this answer. It was probably already solved, but in any case I would like to add that if you are using Dashcode, the Checkbox part is a div which contains one label and one input, this one being the "real" checkbox.

    If you inspect the html as it is loaded in Safari you will notice that "checkbox" is the type of the element.

    Therefore the proper way to change the state of the checkbox would be, assuming "input" is its id (it could have a default number attached though):

    document.getElementById("input").checked="true";
    

    or whichever method you want to use.

    The main point here is that you were trying to change the state of another div.

    Hope it helps!

    0 讨论(0)
提交回复
热议问题