Hi Friends, in this article I will explain about Detecting sequence of at least 3 sequential numbers from a given List in ASP.NET using JavaScript.
I will explain in the next articles about MVC4 Razor :Routing or Set StartUp page in MVC4 with example,How to use sessions using C# ,How to Compare Start Date and End Date and Validate in YYYY-MM-DD Format in ASP.NET and How to hide the page name in ASP.NET using frameset.
In ASP.NET:
<html xmlns="http://www.w3.org/1999/xhtml">
<head >
<title>Detecting
sequence of at least 3 sequential numbers from a given List in ASP.NET using
JavaScript</title>
<script type ="text/javascript" language="javascript"
>
function
Cmethod() {
var
arr = [1, 2, 3, 5, 10, 7, 8, 9];
arr.sort(function(a,b){return a-b});
var
results = [];
for
(var i = 0; i < arr.length; i++) {
if
((arr[i] - arr[i - 1] != 1) && (arr[i] - arr[i + 1] != 1)) {
results.push(arr[i]);
}
}
alert(results);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button"
OnClientClick="Cmethod();"/>
</div>
</form>
</body>
</html>
|
The Output of the above code as shown in the below figure.
"If you like my blog or articles, you can appreciate by leaving your comments or Liking my Facebook page Aspdotnet-kishore, following on Google+ Aspdotnet-Kishore, Twitter on AspdotnetKishore, Linked in Aspdotnet-Kishore, stumbling my posts on stumble upon and subscribing on RSS feed Aspdotnet-Kishore for free updates directly to your Email inbox . Watch my blog for more articles."
No comments:
Post a Comment