Click here to Skip to main content
15,903,388 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:

Hi All,

Could you help me how to create checkbox on html using Javascript .

I have Array Table as ElmArray ="H2O,SIO2,Ni,Fe,MGO,Al,CaO"



Updated 31-Oct-17 18:10pm

var myDiv = document.getElementById("myDiv");
var checkbox = document.createElement("input"); 
checkbox.setAttribute("type", "checkbox");
checkbox.setAttribute("name", "dd");
checkbox.setAttribute("value", "ff");
checkbox.checked = true; 
//do this after you append it
checkbox.checked = true; 

Share this answer

I hope you want to create the checkbox dynamically using javascript and HTML. you can refer the below link

html - Creating the checkbox dynamically using JavaScript? - Stack Overflow[^]
Share this answer
Afzaal Ahmad Zeeshan 1-Nov-17 1:58am    
It is better to avoid answering older threads, and try sharing your expertise on the latest threads here.
san2debug 1-Nov-17 4:00am    
ok sure Afzaal

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900