jeudi 29 avril 2021

How to put Dynamic id in checkbox in javascript?

I am attaching my html code to a variable(ctableData) which I am again appending to the main container. Now I want to have dynamic id for the checkbox, So I am running a loop and incrementing the value of k in every iteration and then assigning the k as checkbox id. But this doesnt seem to be working?

for(let k =1; k< x.length; k++){
ctableData += '<div class="table_container"><table id="table1" class="checkboxdiv"><tbody><tr><th>'+plan[0].medicalPlans[i].brokerName+' <input type="checkbox" id= k name="table1" value="table1" onchange="myFunction(event)"> </th></tr>
}



Aucun commentaire:

Enregistrer un commentaire