Select Checkbox List on page load event using Javascript
Introduction : This Example used to select checkbox list values when the user can edit the page datawhen user can click on edit button it is also need to display selected checkbox value here i am explain using jquery with simple Example.
Step 1: Html Page
<html>
<body>
<input id="aaa" type="checkbox" name="aaa" value="aaa" /> aaa<br />
<input id="bbb" type="checkbox" name="bbb" value="bbb" /> bbb <br />
<input id="ccc" type="checkbox" name="ccc" value="ccc" /> ccc
</body>
</html>
Step 2: Java script code
<script src="~/Scripts/jquery-1.7.1.js"></script>
<script src="/Scripts/jquery-1.7.1.min.js"></script>
<script>
$(document).ready(function () {
var str = "aaa,bbb,ccc";
var array = str.split(",");
for (var i = 0; i < array.length; i++) {
alert(array[i]);
$("input[name='" + array[i] + "']").prop('checked',true);
}
});
</script>
See Other Tutorial :
* AngularJS CRUD Operation : Select Insert Edit Update and Delete using AngularJS in ASP.Net MVC
* AngularJS With ASP.NET MVC
* Convert Rows to columns using 'Pivot' in SQL Server
* Mvc Registration page With user exist using Ajax method
* MVC 4 How to Perform Insert Update Delete Edit Select Operation
* MVC4 Edit,update,Delete,cancel inside gridview using sql database
* MVC 4 Gridview To Display Data Using SQL Server Database With Simple code
* Login page in asp.net Mvc4 Web application
* Mvc4 How to bind Dropdown List using Sql Database
* Gridview find control in asp.net
Sign up here with your email
ConversionConversion EmoticonEmoticon