'I have read a json file & have output it as checkbox in Javascript.if i click on 5 checkboxes alert message should come as 5 checkboxes are clicked

function loadajax() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var response=JSON.parse(this.responseText);
var output="";
for(var i=0;i<response.length;i++){
if(response[i].completed==true){
output+= '<input type="checkbox" id="check" checked name="title" value=" <br>+  response[i].title  ; +" >' + response[i].title + '<br></input>';}
else{
output+= '<input type="checkbox" id="check"  name="checkbox" value=" <br>+  response[i].title  ; +" >' + response[i].title + '<br></input>';   }}
document.getElementById("demo").innerHTML=output;
xhttp.open("GET", "https://jsonplaceholder.typicode.com/todos", true);
xhttp.send();   }

The function loadajax is called in another html file in body onload..if i click on 5 checkboxes alert should come as 5 boxes are checked using the concept of promise.. Please help.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source