lundi 28 septembre 2015

javascript not reading all my if condition

what are the possible solution to let the javascript read all my if condition and display all that found is true?

here's my code:

if (document.getElementById('chk_q1').checked == true) {
    if (document.getElementById('chk_c1').checked == false) {
        alert('You forgot to check the Competency.')
        location.href('index.html');
    };
    
      alert('Correct.');
 }
if (document.getElementById('chk_q2').checked == true) {
    if (document.getElementById('chk_c1').checked == false) {
        alert('You forgot to check the Competency.')
        location.href('index.html');
    };
    
      alert('Correct.');
 }
if (document.getElementById('chk_q3').checked == true) {
    if (document.getElementById('chk_c1').checked == false) {
        alert('You forgot to check the Competency.')
        location.href('index.html');
    };
    
      alert('Correct.');
 }

here's my html:

<form>
            <button type="button" class="btn btn-default btn-sm" onclick="javascript:demoPDF()" id="final">Finalized Customized Interview Form</button>
            <button type="button" class="btn btn-success btn-sm" onClick="actions.save()">Save</button>
            <button type="reset" class="btn btn-warning btn-sm" id="uncheckall">Reset Form</button>
            <br>
            <br>
            <br>
            <!-- START OF INTERVIEW INFO -->
            <table style="width:100%" id="tbl_info">
                <tr>
                    <th colspan="4">Interview Information</th>
                </tr>

                <tr>
                    <td>Hiring Manager Name:</td>

                    </td>
                    <td><input type="text" name="name" id="HMname" placeholder="Type manager's name here..." style="width:205px"></td>
                                            </td>
                                            <td>Recruiter Name:</td>
                                            </td>
                                            <td><input type="text" name="HMN" id="Rname" placeholder="Type position title here..." style="width:205px"></td>
                                          
                                          </tr>

                                          <tr>  
                                            <td>Position Title:</td>
                                                
                                                </td>
                                            <td><input type="text" name="HMN" id="Ptitle" placeholder="Type recruiter's name here..." style="width:205px"></td>
                                            </td>
                                            <td>Position Code:</td>
                                            </td>
                                            <td><input type="text" name="HMN" id="Pcode" placeholder="Type position code here..." style="width:205px"></td>
                                          
                                          </tr>


                <tr>
                    <td>Candidate Name:</td>

                    </td>
                    <td>&nbsp</td>
                    </td>
                    <td>Interview Date:</td>
                    </td>
                    <td>&nbsp</td>

                </tr>
            </table>
            <!-- </form> -->
            <!-- END OF INTERVIEW INFO -->

            <!-- STRAT OF COMPETENCY -->

            <!-- <form action="CC.php" name="select_form"> -->
            <!-- <button type="button" class="btn btn-default btn-sm" >Finalized Customized Interview Form</button>
                                <button type="button" class="btn btn-success btn-sm" id="uncheckall" name="uncheckall" alt="save as">Save</button>
                                <button type="button" class="btn btn-warning btn-sm" value="reset" id="uncheckall" name="uncheckall" onclick=>Reset Form</button>
                                <br>
                                <br>
                                <br> -->
            <table style="width:100%;margin-top:10px" id="tbl_selection">
                <tr>
                    <th><b>Competency and Select to use for<br> Interview Series</b>
                    </th>
                    <th><b>Questions</b>
                    </th>
                    <th><b>Use for Interview Series?</b>
                    </th>
                </tr>
                <!-- INNOVATION -->
                <tr style="background-color:#FEE2B8">
                    <td rowspan="4"><b>Balance Focus</b>
                        <br>
                        <!-- <form> -->
                        <input type="checkbox"  id="chk_c1" onselect="javascript:select()" class="select"> Select
                        <br>
                        <input type="checkbox" id="not_use" checked> Do not use
                        <!-- <br>
                                                  <input type="radio" name="not_select" value="not selected"> Do not Select -->
                        <!-- </form>  -->
                    </td>
                    <td id="q1" value="lorem" >Give me an example of a time where you had to make key decisions in the absence of complete information. How did you recognize when a solution is good enough?</td>
                    <td>
                        <!-- <form> -->
                        <input type="checkbox" id="chk_q1"> Select
                        <br>
                        <input type="checkbox" id="not_use1" checked> Do not use
                        <!-- <br>
                                                  <input type="radio" name="not_select" value="not selected"> Do not Select -->
                        <!-- </form> -->

                    </td>
                </tr>
                <tr>
                    <td>Describe a situation where you were involved in creating alternative business scenarios, prioritized them based on your knowledge of the business, and put a plan in place to enable the strategy.</td>
                    <td>
                        <!-- <form> -->
                        <input type="checkbox" id="chk_q2"> Select
                        <br>
                        <input type="checkbox" id="not_use" checked> Do not use
                        <!-- <br>
                                                          <input type="radio" name="not_select" value="not selected"> Do not Select -->
                        <!-- </form> -->
                    </td>

                </tr>
                <tr style="background-color:#FEE2B8">
                    <td>Tell me about a situation in which you were responsible for a project where you had to satisfy multiple stakeholders with different priorities. How did you balance conflicting demands and arrive at a successful outcome?</td>
                    <td>
                        <!-- <form> -->
                        <input type="checkbox" id="chk_q3"> Select
                        <br>
                        <input type="checkbox" id="not_use" checked> Do not use
                        <!-- <br>
                                                          <input type="radio" name="not_select" value="not selected"> Do not Select -->
                        <!-- </form> -->
                    </td>
                </tr>
                <tr>
                    <td>Tell me about a time when your group was assigned multiple priorities by multiple leaders all stressing the importance of their own projects? How did you prioritize the projects? How did you inform the leaders of their project time frames? </td>
                    <td>
                        <!-- <form> -->
                        <input type="checkbox" id="chk_q4"> Select
                        <br>
                        <input type="checkbox" id="not_use" checked> Do not use
                        <!-- <br>
                              <input type="radio" name="not_select" value="not selected"> Do not Select -->
                        <!-- </form> -->
                    </td>
                </tr>
</table>

the problem here is that it only display all the content if i only check the first checkbox.

any solution to the problem?

Aucun commentaire:

Enregistrer un commentaire