Run the snippet and click on Click here!, there will be an error saying:
{ "message": "Uncaught TypeError: ll_ctq is not a function",
"filename": "https://stacksnippets.net/js", "lineno": 15, "colno": 93 }
But I have a function ll_ctq() in my code.
var web = 'http://localhost/prjct/';
var ll_50_50 = 'll_50_50=';
var ll_ctq = 'll_ctq=';
var ll_dd = 'll_dd=';
var and = '&';
var play = 'play.php?';
function ll_ctq() {
var check_ll_ctq = document.getElementById("ll_ctq"),
classes = ['red_cross'];
if (check_ll_ctq.classList.contains("red_cross")) {
// alert("Yes");
} else {
// alert("No");
document.getElementById("ll_ctq").classList.add("red_cross");
document.getElementById("A1").setAttribute('class', 'timeout');
document.getElementById("B1").setAttribute('class', 'timeout');
document.getElementById("C1").setAttribute('class', 'timeout');
document.getElementById("D1").setAttribute('class', 'timeout');
var check_ll_ctq = document.getElementById("ll_ctq"),
classes = ['red_cross'];
var check_ll_50_50 = document.getElementById("ll_50_50"),
classes = ['red_cross'];
var check_ll_dd = document.getElementById("ll_dd"),
classes = ['red_cross'];
if (check_ll_ctq.classList.contains("red_cross")) {
var ll_ctq_status = "yes";
} else {
var ll_ctq_status = "no"
}
if (check_ll_50_50.classList.contains("red_cross")) {
var ll_50_50_status = "yes";
} else {
var ll_50_50_status = "no";
}
if (check_ll_dd.classList.contains("red_cross")) {
var ll_dd_status = "yes";
} else {
var ll_dd_status = "no";
}
var location = web + play + ll_50_50 + ll_50_50_status + and + ll_ctq + ll_ctq_status + and + ll_dd + ll_dd_status;
setTimeout(function() {
window.location = location;
}, 3000);
}
}
<div id="play_head">
<div>
</div>
<div>
<button id="ll_ctq" class="button_cstm_ll" style="margin-right:45px" onclick="ll_ctq()">Click here!</button>
</div>
<div>
</div>
</div>
<table id="test" class="table table-responsive table_cstm">
<tbody>
<tr>
<td colspan="2">
<div class="question1" style="justify-content: center; width: 100%;">1) Who was First Prime Minister of India?(15304)</div>
</td>
</tr>
<tr>
<td>
<div id="A1">A) M K Gandhi
</div>
</td>
<td>
<div id="B1">B) Jawaharlal Nehru
</div>
</td>
</tr>
<tr>
<td>
<div id="C1">C) Rajendra Prasad
</div>
</td>
<td>
<div id="D1">D) Chandra Shekhar Azad
</div>
</td>
</tr>
</tbody>
</table>
Run the snippet and click on Click here!, there will be an error saying:
{ "message": "Uncaught TypeError: ll_ctq is not a function",
"filename": "https://stacksnippets.net/js", "lineno": 15, "colno": 93 }
But I have a function ll_ctq() in my code.
varevery time you assign a value. One declaration is enough.