JavaScript
  Home arrow JavaScript arrow Page 3 - JavaScript Events
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVASCRIPT

JavaScript Events
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 8
    2007-11-26

    Table of Contents:
  • JavaScript Events
  • OnBlur
  • OnChange
  • OnClick
  • OnDblClick

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    JavaScript Events - OnChange


    (Page 3 of 5 )

    If a user changes the value of a field, you may wish to punish them. Or alert them, whatever you think is appropriate. Heck maybe you want them to change it; you can throw them a party for all I care. Whatever it is you want to have happen when a value is changed, here is some code to demonstrate how to do it.


    <html>


    <head>

    <script type="text/javascript">

    function popup(x)

    {

    alert('No don't do that.')

    }

    </script>

    </head>


    <body>


    Place Your Order: <input type="text" id="food" value="hamburger" onchange="popup(this.id)">


    </body>

    </html>

    This code creates a function and a text box with the default value of hamburger. The caption reads: Place Your Order. If you change the text in the text box, it triggers the function, which causes a pop-up button to appear saying: No don’t do that.

    You will note that in the pop-up button text I used ’ to insert an apostrophe. If you forget to do so, the code will not work.


    Supporting HTML Tags: <input type="text">, <select>, <textarea>

    Supporting Javascript Objects: fileUpload, select, text, textarea

    More JavaScript Articles
    More By James Payne


       · Hey, welcome to my article on Javascript Events, where we discuss some of the Events...
     

    JAVASCRIPT ARTICLES

    - Using Click Interceptions with a Database-Dr...
    - Using JavaScript Click Interceptions in an I...
    - Using Click Interceptions with JavaScript
    - QuickSort in Action
    - Quicksort
    - Using Mod_Security to Protect Your Server
    - Detecting and Countering Server Intrusions
    - Securing Your Web Server
    - Building a Secure Web Server
    - Protecting the Server
    - Book Review: Learning the Yahoo! User Interf...
    - Dynamically Generate a Selection List in a R...
    - Intergrate DWR into Your Java Web Application
    - Detect Browser Compatibility with the Reques...
    - Using the EXT JS Date Picker Widget






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT