Monday, 4 November 2013

Detecting sequence of at least 3 sequential numbers from a given List in ASP.NET using JavaScript

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.

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

© 2012-2018 Aspdotnet-Kishore.blogspot.com. All Rights Reserved.
The content is copyrighted to Kishore and may not be reproduced on other websites without permission from the owner.