skip to Main Content

I just want to improve the workflow in my business.
So I tried to make a small App for my employees, where they can add ordered Tires to a Table.

i want them to click the Checkbox when the tires are delivered and when they are mounted.

So for now they can add ordered tires.
But the Checkboxes are always shown as on.

Here is my Code:

function fillTable() {
  var table = document.getElementById("Tabelle");
  var row = table.insertRow(0);
  var cell1 = row.insertCell(0);
  var cell2 = row.insertCell(1);
  var cell3 = row.insertCell(2);
  var cell4 = row.insertCell(3);
  var cell5 = row.insertCell(4);
  var cell6 = row.insertCell(5);
  var cell7 = row.insertCell(6);
  var cell8 = row.insertCell(7);
  var cell9 = row.insertCell(8);
    cell1.innerHTML = document.getElementById("name").value;
  cell2.innerHTML = document.getElementById("size").value;
  cell3.innerHTML = document.getElementById("Art").value;
  cell4.innerHTML = document.getElementById("hersteller").value;
  cell5.innerHTML = document.getElementById("lieferant").value;
  cell6.innerHTML = document.getElementById("termin").value;
  cell7.innerHTML = document.getElementById("radDa").value;
  cell8.innerHTML = document.getElementById("reifenDa").value;
  cell9.innerHTML= document.getElementById("montiert").value;
tbody id="Tabelle" contenteditable>
    
    
</tbody>

    </table>
    <form action="">
        <input type="text" id ="name" />
        <input type="text" id ="size" />
        <input type="text" id ="Art" />
        <input type="text" id ="hersteller" />
        <input type="text" id ="lieferant" />
        <input type="date" id ="termin" />
        <input type="checkbox" id ="radDa" />
        <input type="checkbox" id ="reifenDa" />
        <input type="checkbox" id ="montiert" />
        <input type="submit" onclick="return fillTable();" />
    </form>

</div>
</body>

i don’t know if the

 cell7.innerHTML = document.getElementById("radDa").value;
  cell8.innerHTML = document.getElementById("reifenDa").value;
  cell9.innerHTML= document.getElementById("montiert").value;

is correct. I tried to replace .innerHTML with .value but it won’t work

2

Answers


  1. I’m not 100% sure what you are trying to do but:

    • To change whether the checkbox is checked or not, you can change the document.getElementById("checkbox").checked property.
    • To get the value of a checkbox, use the document.getElementById("checkbox").value property.

    I think this should cover what you need. If not, comment on this answer with a clarification and I’ll update my answer 🙂

    Login or Signup to reply.
  2. Another way to get value of checkbox using jQuery is

    $("input[type='checkbox']").val();
    

    This will give you the checkbox value. If you want to get or set other attributes, same can be done using jQuery.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search