JSFiddle - React, Tailwind, and code Playground

by praveen_jegan

HTML

<form name="myForm">
    <tr>
        <td>
            <input type='checkbox' name='check1' value='80'>Q- 80. Statute of Liberty is in ?</td>
    </tr>
    <tr>
        <td>
            <input type='checkbox' name='check1' value='64'>Q- 64. National Animal ?</td>
    </tr>
    <tr>
        <td>
            <input type='checkbox' name='check1' value='65'>Q- 65. Popular language</td>
    </tr>
    <tr>
        <td>
            <input type='checkbox' name='check1' value='63'>Q- 63. Largest Ocean ?</td>
    </tr>
    <input type="submit" name="delete" formmethod='post' formaction='/~xyz/cgi-bin/Project/CheckDelete.py' value="Delete" onclick="alert(Checked())">
    <form>

JavaScript

function Checked() {
    var d = document.myForm.check1;
    var arr = 0;
    for (var i = 0; i < d.length; i++) {
        console.log(d[i].checked);
        if (d[i].checked) {
            arr++;
        }
    }
    if (arr != 0) return true;
    else {
        alert("Please select Checkbox");
        return false;
    }
}