jeudi 7 mai 2015

how to uncheck the checkbox in clone() method while calling clone method on previous row of table?

I have one table and the javascript function to add and delete row but the problem if i checked the checkbox then try add the row the checkbox is checked for next row.But i want unchecked checkbox for the how many row i will add to the table wheather it may one or more .

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
        <title>Web site</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" href="CSS/custom_style.css">
    <link rel="stylesheet" type="text/css" href="CSS/tableStyle.css">
    <link rel="stylesheet" type="text/css" href="CSS/tableStyleResponsive.css">
    <script src="http://ift.tt/INsMIw"></script> 
    <script src="http://ift.tt/1mcJXw6"></script>   
  <script>
        $(document).ready(function() {
        $("input.add").live('click', function() {
                var $tr = $(this).closest('tr');
                var $clone = $tr.clone();
                $clone.find(':text').val('');
                $tr.after($clone);
                });
        $("input.delete").live('click',function(){              
                var $tr = $(this).closest('tr');                
                        $tr.remove();   
                        return false;                           
                });
        });
        </script> 
</head>
        <!-- Body Started-->
    <body>
    <form name="Basicinfo" id="Basicinfo" method="post" action="Basic.html" >
        <table  id="phone" width="100%" name="phone">
                        <tr>
                                <td colspan="5" bgcolor="#5C85B3">Phone</td>
                        </tr>
                        <tr>
                                <th>Type</td>
                                <th>Country Code</th>
                                <th>*Phone</th>
                                <th>Preferred</th>
                                <th>Add/Delete</th>
                        </tr>
                        <tr>
                                <td>
                                <select name="phntype" id="phntype" style="width:50%">
                                <!-- Phone Types -->
                                %bind(:6);
                                </select>
                                </td>
                                <td>
                                <input type="text" name="cntrycde" id="cntrycde" value="">
                                </td>
                                <td>
                                <input type="text" name="phone_no" id="phone_no" value="">
                                </td>
                                <td>
                                <input type="hidden" name="prefferd" value="NO">
                                <input type="checkbox" name="preferred" id="preferred" value="N">
                                </td>
                                <td>
                                <input type="button" value="+" class="add">
                                <input type="button" value="-" class="delete">
                        </td>
                        </tr>
                </table>
        </form>
        </body>
</html>



Aucun commentaire:

Enregistrer un commentaire