mardi 24 novembre 2015

Check and Uncheck Checkbox

Why when I check the checkbox it works fine when I uncheck it nothing happen enter image description here enter image description here

 <form method="get">
                        <table id="row">
                            <tr><th colspan="2" >Location</th></tr>
                            <tr><td>Country:</td><td><select id="country" name ="country"  style="width:200px"></select></td></tr>
                            <tr><td>City:</td><td><select name ="city" id ="state"></select></td></tr>
                            <script language="javascript">
                                populateCountries("country", "state");
                            </script>
                            <tr><td></td><td><input onclick="myFunction()" type="checkbox" name="manualentry" value="manualentry" >Manual Entry</td></tr>
                            <script>
                                var table = document.getElementById("row");
                                function  myFunction() {
                                    if (document.getElementsByTagName('manualentry').checked = true) {
                                        document.getElementById("row").deleteRow(2);
                                        var row = table.insertRow(2);
                                        var cell1 = row.insertCell(0);
                                        var cell2 = row.insertCell(-1);
                                        cell1.innerHTML = "City:";
                                        cell2.innerHTML = '<input  type="text" >';
                                    } else {
                                        document.getElementById("row").deleteRow(2);
                                        var row = table.insertRow(2);
                                        var cell1 = row.insertCell(0);
                                        var cell2 = row.insertCell(1);
                                        cell1.innerHTML = "City:";
                                        cell2.innerHTML = '<select name ="city" id ="state"></select>';
                                    }
                                }
                            </script>
                            <tr ><td  colspan="2" align="right" > <input type="submit" value="Submit"></td></tr>
                        </table>

                    </form>




Aucun commentaire:

Enregistrer un commentaire