iLTC Home
Bookmark iLTC!

Categories

Perl
  • Perl Tutorials Beginners

  • Javascript
  • Javascript Tutorials
  • Javascript Tutorials Beginners

  • HTML
  • HTML Tutorials

  • Command Line
  • Command Line Tutorials

  • How Tos
  • Other Tips and Tricks



  • for($i;$i < 1000;$i++) { }
    1726020

    iLoveTheCode.com

    onClick Javascript

    onClick is an easy to use Javascript event handler. Event handlers are used to tell the browser what to do when an event occurs. In this case, onClick is the event. Fairly simple.

    Here's one way to use onClick in a link tag.

    <a href="#" onClick="alert('Hello!');return false">Say Hi</a>

    -After the onClick Javascript event handler, we enclose our entire javascript code in double quotation marks.
    -We use the built-in javascript alert method to open an alert box. Since we are inside double quotes, we use single quotes around our 'Hello!' message.
    -We return false so the browser won't use the href tag. If we return true the browser window would go to the url in the href tag.

    The onClick Javascript event handler is incredibly useful in that it can be used in more than just link tags. It can used in submit buttons, radio buttons, reset buttons as well as checkboxes.

    There are examples of these below and links to even more information about onClick.

    Say Hi


    Free Copy and Paste Javascript Code:

    <a href="#" onClick="alert('Hello!');return false">Say Hi</a>

    <input type="submit" onClick="alert('Submit Me!');return false">

    <input type="radio" name="radset" onClick="alert('Radio Selected!')">

    <input type="checkbox" onClick="alert('Checkbox Selected!')">



    Resources:
    Javascript Documentation at Sun microsystems
    Use onClick in Javascript to Call a Function




    Previous Article:
    Next Article: Javascript Alert






    Search iLTC w/ Google




    Recent Articles

  • HTML Font Code
  • Javascript and CSS - Easy Pop Up Help Balloons
  • Use OnMouseOver in Javascript
  • Use onMouseOut in Javascript
  • Use innerHTML to Change Text on a Page
  • Renaming a File with Perl's RENAME Function
  • PRINT to Browser with document.write Command in Javascript
  • Passing an Argument or Variable to a Javascript
  • Opening an Alert Box in Javascript
  • Opening a REMOTE WINDOW in Javascript
  • OPEN and WRITE a Data File in Perl
  • OPEN and READ a Data File in Perl
  • Mimic Typing from a Textfield in a Textarea with Javascript
  • Javascript Reset Form








  • Perl Programming - Javascript Programming - HTML Code - Mac Unix Command Line - Maybe Some PHP - Free Scripts - ILoveTheCode
    All Content © 2006-2009 iLoveTheCode.com


    Contact Chris | About this Site


    1725745
    Counter by iLoveTheCode.com


    Last Modified: Thursday, 05-Feb-2009 05:19:22 EST



    Hosted as well :)
    Home-brewed logo - 1997