R N REDDY .Net Community - ASP
Wednesday, 2016-12-07, 6:02 PM
Welcome Guest | RSS
Site menu
Tag Board
500
Our poll
How do you rate .Net classes ?
Total of answers: 194
Statistics

Total online: 1
Guests: 1
Users: 0
24-12-2010

Eg: for Comparinig dates:

    <html>
        <body>
             <script type = "text/javascript">
             var mydate = new Date()
             var mydate1 = new Date()
             mydate1.SetFullYear(2015,11,25)

             if(mydate > mydate1)
            {
                alert("Today is after 2015, DEC 25th")
             }

             Else
            {
                alert("Today is before 2015, DEC 25th")
             }
             </script>
        </body>
    </html>
Output: Today is before 2015 DEC 25th

Eg: To display week day number:

getday(): Using tihs method we can return the week number. Every week is representing with one index value Sunday is representing with '0' and monday is representing with '1' and so on..

    <html>
        <body>
            <script type = "text/javascript">
            var mydate = new Date()
            document.write("Today week day number is " +mydate.getday())
            </script>
         </body>
    </html>

Array Object: An array is ajava script object. It can contain collection of elements with a single variable.

Eg: To create a array:
    var courses = new Array("dotnet", "Java", "Php")

Eg: To print the array content:
    <html>
        <body>
             <script type = "text/javascript">
             var courses = new Array("dotnet", "Java", "Php")
             document.write("Array elements are" +courses)
             </script>
        </body>
    <html>
Output: Array elements are dotnet, Java, Php.

Eg: To print the array elements by using index values:
    <html>
        <body>
             <script type = "text/javascript">
             var courses = new Array("dotnet", "Java", "Php")
             for(var i=0; i < courses.length; i++)
            {
               document.write(courses[i] +"<br>")
             }
            </script>
        </body>
    </html>
Output: dotnet
              Java
              Php

Within the java script array we can have different data type elements like below.

Eg: var courses = new Array("dotnet", 111, "java", 222)


concat(): Concat is a predefined method, using this method we can concatinate two arrays.

Syntax: <first array>.concat(<second array>)

Eg for concat:
     <html>
        <body>
             <script type = "text/javascript">
             var course1 = new Array("dotnet", "java", "php")
             var course2 = new Array("sap", "as400", "testing")
             document.write(course1.concat(course2))
             </script>
          </body>
      <html>
Output: dotnet, java, php, sap, as400, testing

sort(): Using this method we can sort the elements of given array

Syntax: <Array name>.sort()

Eg for sorting:
    <html>
       <body>
             <script type = "text/javascript">
             var course = new array("dotnet", "java", "sap", "as400", "testing") +"<br>"
             document.write("Course elements are " +course)
             document.write("Sorted course elements are " +course.sort())
             </script>
        </body>
    </html>
Output: Course elements are dotnet, java, php, sap, as400, testing
              Sorted elements are as400, dotnet, java, php, sap, testing

Eg: To display today week name:

    <html>
        <body>
             <script type = "text/javascript">
             var weekdays = new Array("Sunday", "MOnday", "Tuesday",
                                      "Wednesday", "Thursday", "Friday", "Saturaday")
             var mydate = new Date()
             document.write("Today is " +weekdays(mydate.getday()))
             </script>
        </body>
    </html>
Output: Today is Friday

Search

Time
 

 

Calendar
 
«  December 2016  »
SuMoTuWeThFrSa
    123
45678910
11121314151617
18192021222324
25262728293031

Twitter
 

Entries archive

Copyright R N Reddy © 2016Developed by Nagendra, Venkat, Vijaya and Yaswanth
Get free updates as SMS to your mobile. Just register by clicking here