Pages

Sunday, 13 August 2017

Jquery Name Selector


You can select html control by its name. Selecting a single control or group of controls is become important in some special web operation requirement. I am going to demonstrate you to select more than one checkbox for payment which may be useful to design some payment related website.


Roll Name Subject
101 Sona Hindi
102 Mona Art
103 Sita Maths
104 Anita English
105 Babita Hindi


Code : 



<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<title>Tag Select by name : Girfa Student Help</title>
<script>
    function setpayment()
    {
        var checkBoxes = $("[name=payment]");
        checkBoxes.prop("checked", !checkBoxes.prop("checked"));
       
    }
</script>
</head>
<body>
<h1 align="center">Select HTML Tags by Name</h1><hr /><br />
<table border="1" cellspacing="0" cellpadding="5">

<tr bgcolor="gray">
    <th>Roll</th>
    <th>Name</th>
    <th>Subject</th>
    <th><input type="checkbox" onclick="setpayment()"/></th>
</tr>
<tr>
    <td>101</td>
    <td>Sona</td>
    <td>Hindi</td>
    <td><input type="checkbox" name="payment"/></td>
</tr>
<tr>
    <td>102</td>
    <td>Mona</td>
    <td>Art</td>
    <td><input type="checkbox" name="payment"/></td>
</tr>
<tr>
    <td>103</td>
    <td>Sita</td>
    <td>Maths</td>
    <td><input type="checkbox" name="payment"/></td>
</tr>
<tr>
    <td>104</td>
    <td>Anita</td>
    <td>English</td>
    <td><input type="checkbox" name="payment"/></td>
</tr>
<tr>
    <td>105</td>
    <td>Babita</td>
    <td>Hindi</td>
    <td><input type="checkbox" name="payment"/></td>
</tr>
</table>
</body>
</html>

No comments:

Post a Comment