Tuesday, 2024-03-19, 3:48 PM
Welcome Guest | RSS
Site menu
Tag Board
500
Our poll
Which .Net class is more interset for you ?
Total of answers: 225
Statistics

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

Eg: For converting the given string into upper case & Lower case:

    <html>
        <body>
              <script type = "text/javascript">
              <var name = "Microsoft">
               document.write("Number of characters are " +name.length +"<br>")
               document.write(name.toUpperCase() +"<br>")
               document.write(name.toLowerCase() +"<br>")
              </script>
        </body>
    </html>
Output: Number of characters are 9
            MICROSOFT
            microsoft

Eg: For searching string within the given string:
    <html>
        <body>
             <script type = "text/javascript">
             var city = "Hyera bad"
             document.write(city.match("bad") +"<br>")
             document.write(city.match("badh") +"<br>")
             document.write(city.match("Bad") +"<br>")
             document.write(city.match(" bad") +"<br>")
             </script>
         </body>
    </html>
Output: bad
            null
            null
            bad

Eg:For indexOf():
    <html>
        <body>
              <script type = "text/javascript">
              var city = "Hyera bad"
              document.write(city.indexOf("bad") +"<br>")
              document.write(city.indexOf("Hydera ") +"<br>")
              document.write(city.match("Bad") +"<br>")
              document.write(city.match(" bad") +"<br>")
              </script>
         </body>
    </html>
Output: 7
              0

Eg: For styles of strings:
    1.big()
    2.small()
    3.bold()
    4.Italic()
    5.blink()
    6.strike()
    7.fontcolor("red")
    8.fontsze(16)
    9.sup()
  10.sub()
  11.link("http://www.microsoft.com")

    <html>
        <body>
              <script type = "text/javascript">
              var txt = "Microsoft Windows"
              document.write(txt.big() +"<br>")
              document.write(txt.small() +"<br>")
              document.write(txt.bold() +"<br>")
              document.write(txt.Italic() +"<br>")
              document.write(txt.blink() +"<br>")
              document.write(txt.strike() +"<br>")
              document.write(txt.fontcolor("red") +"<br>")
              document.write(txt.fontsize(16) +"<br>")
              document.write(txt.sup() +"<br>")
              document.write(txt.sub() +"<br>")
              var mylink = "Visit Microsoft"
              document.write(mylink.link("http://www.microsoft.com") +"<br>")
              </script>
        </body>
    </html>

Date Object: Date is pre-defined java script object, it holds the current date & time information.

Eg: To display the current date & time by using date pre-defined object:
    <html>
        <body>
              <script type = "text/javascript">
              document.write(Date())
              </script>
        </body>
    </html>
Output: THU DEC 22 19:35 2010

Synatax:to create a user defined date object:

          var mydate = new Date()
(Here, "mydate" is a user defined date object and "Date()" is a pre-defined date object)

Eg: To display the current date & time by using user defined date object:
    <html>
        <body>
              <script type = "text/javascript">
              var mydate = new Date()
              document.write(mydate)
              </script>
        </body>
    </html>
Output: THU DEC 22 19:35 2010

Eg: To assign a particular date to user defined date object:
        <html>
        <body>
             <script type = "text/javascript">
              var mydate = new Date()
              mydate.SetFullYear(2014,0,26)
              document.write(mydate)
              </script>
        </body>
    </html>
Output: SUN JAN 26 19:35 2010

SetFullYear: Using this pre-defined method we can assign some date to user define date object.

Syntax for SetFullYear:
    <dateobeject>.SetFullYear(YYYY,MM,DD)

Eg: To add 15 days to current date:
    <html>
        <body>
               <script type = "text/javascript">
               var mydate = new Date()
               mydate.setDate(mydate.getDate()+15)
               document.write(mydate)
               </script>
         </body>
    </html>
Output: FRI JAN 7 19:35:14 UTC+ 2011

setDate: Using this method we can add or set some date to date object.

getDate: This method will pick the only date from user defined date object.

Eg: To add 7 days to 2014, DEC 25
    <html>
        <body>
             <script type = "text/javascript">
             var mydate = new Date()
             mydate.SetFullYear(2014,11,25)
             mydate.setDate(mydate.getDate()+7)
             document.write(mydate)
             </script>
        </body>
    </html>
Output: mydate 2014, 11, 25
            2015,  0,  1

Search

Time
 

 

Calendar
 
«  March 2024  »
SuMoTuWeThFrSa
     12
3456789
10111213141516
17181920212223
24252627282930
31

Twitter
 

Entries archive

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