-5

I want to create 100 checkboxes, using javascript

I dont want to type one by one the checkboxes. I want javascript to do it for me, with a loop(like for or while)

1

2 Answers 2

1
for(var i=0; i<100; i++) {
    var check = document.createElement("input");
    check.type = "checkbox";
    check.id = i;
    document.body.appendChild(check);
}

now you have 100 checkboxes in your body with ids starting from 0 to 99.

Sign up to request clarification or add additional context in comments.

Comments

1

You can do this by using the below

for (var i = 0; i < 100; i++) {
  var x = document.createElement("INPUT");
  x.setAttribute("type", "checkbox");
  document.body.appendChild(x);
}

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.