Results 1 to 9 of 9

Thread: Different JavaScript examples:

  1. #1
    PerryCollins is offline Senior Member
    Join Date
    Dec 2009
    Posts
    380
    Rep Power
    3

    Default Different JavaScript examples:

    Mouse-over effects

    Use this code to display a message in the status area of the web browser when a mouse hovers over a hypertext link.

    Code:
    <a href="mypage.html"
    onMouseOver="window.status='The message'; return true" 
    onMouseOut="window.status=''; return true" >
    the text of the link</a>

  2. #2
    SmithJohnson is offline Senior Member
    Join Date
    Dec 2009
    Posts
    364
    Rep Power
    3

    Default

    Popup Window

    Code:
    <script type="text/JavaScript">
    // Popup window code
    function newPopup(url) {
    	popupWindow = window. open(
    		url,'popUpWindow','height=700,width=800,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes')
    }
    </script>

  3. #3
    Williamsjones is offline Senior Member
    Join Date
    Dec 2009
    Posts
    352
    Rep Power
    3

    Default

    Display the date and time.

    Code:
    <script type="text/JavaScript">
    <!--
    document. write(Date())
    //-->
    </script>

  4. #4
    Brownchris is offline Senior Member
    Join Date
    Dec 2009
    Posts
    331
    Rep Power
    3

    Default

    JavaScript Frame Escape

    This code makes a page jump out of a frame. It helps stop other sites framing a page.

    Code:
    <script language="JavaScript" for="window" event="onLoad()">
    if (top.location != location) {
    top.location = "index.html";
    }
    </script>

  5. #5
    SmithJohnson is offline Senior Member
    Join Date
    Dec 2009
    Posts
    364
    Rep Power
    3

    Default

    Confirmation Boxes

    Code:
    <script language="javascript">
      var result = confirm("Would you like to go at Home Page");
      if(result){
      	alert ("You Pressed Ok.. ");
      	window. open("http://www.techfuels.com","_blank");
      }else{
      	alert ("You Pressed Cancel.. ");  
      }
    </script>

  6. #6
    TorresScott is offline Senior Member
    Join Date
    Dec 2009
    Posts
    239
    Rep Power
    3

    Default

    For special character

    Code:
    var iChars = "!@#$%^&*()+=-[]\\';,./{}|":<>?";
    
      for (var i = 0; i < document.formname.fieldname.value.length; i++) {
      	if (iChars.indexOf(document.formname.fieldname.value.charAt(i)) != -1) {
      	alert ("Special character not allowed.");
      	return false;
      	}
      }

  7. #7
    BrooksGray is offline Senior Member
    Join Date
    Dec 2009
    Posts
    231
    Rep Power
    3

    Default

    JavaScript for alert box:

    Code:
    <html>
    <head>
    <script type="text/javascript">
    function show_alert()
    {
    alert("welcome to techfuels.com!");
    }
    </script>
    </head>
    <body>
    <input type="button" onclick="show_alert()" value="Show alert box" />
    </body>
    </html>

  8. #8
    CollinsBrown is offline Senior Member
    Join Date
    Dec 2009
    Posts
    213
    Rep Power
    3

    Default

    JavaScript for radio button checked

    Code:
    function valbutton(thisform) {
    // place any other field validations that you require here
    // validate myradiobuttons
    myOption = -1;
    for (i=thisform.myradiobutton.length-1; i > -1; i--) {
    if (thisform.myradiobutton[i].checked) {
    myOption = i; i = -1;
    }
    }
    if (myOption == -1) {
    alert("You must select a radio button");
    return false;
    }
    
    alert("You selected button number " + myOption
    + " which has a value of "
    + thisform.myradiobutton[myOption].value);
    
    // place any other field validations that you require here
    thisform.submit(); // this line submits the form after validation
    }

  9. #9
    DavisNelson is offline Senior Member
    Join Date
    Dec 2009
    Posts
    202
    Rep Power
    3

    Default

    javascript for dropdownlist in asp.net

    Code:
    <Script>
    function FilterStatus()
    {
    var drpFilterType = document.getElementById("drpFilterType");
    var selectedFilterType = drpFilterType
    ..options[drpFilterType.selectedIndex].value;
    if (selectedFilterType == "MonthFilter")
    {
    document.getElementById("drpMonthFilter").style.vi sibility="visible";
    document.getElementById("drpYearFilter").style.vis ibility="visible";
    }
    else if (selectedFilterType == "YearFilter")
    {
    document.getElementById("drpMonthFilter").style.vi sibility="hidden";
    document.getElementById("drpYearFilter").style.vis ibility="visible";
    }
    else if (selectedFilterType == "All")
    {
    document.getElementById("drpMonthFilter").style.vi sibility="hidden";
    document.getElementById("drpYearFilter").style.vis ibility="hidden";
    }
    }
    </script>

Similar Threads

  1. JavaScript Error Handling Examples
    By Davisricky in forum Programming
    Replies: 1
    Last Post: 04-28-2010, 01:08 PM
  2. What is Javascript?
    By Brownchris in forum Programming
    Replies: 1
    Last Post: 04-22-2010, 03:56 PM
  3. Examples of Hardware Firewalls
    By BarnesHarris in forum Networking Jargons
    Replies: 0
    Last Post: 12-28-2009, 07:54 PM
  4. Javascript
    By techno23 in forum Programming
    Replies: 0
    Last Post: 03-26-2008, 11:56 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
SEO by SubmitEdge

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48