Quick References
      ADO
      ASP
      CSS2
      HTML
      JavaScript
      Jet SQL
      VBScript
      WML
      WMLScript
      WSH
      XHTML
      XML DOM
      XSLT

Features
      Knowledge Base
      Tutorials

Partners
     ZVON.ORG
     XML
     Planet Source Code
     VisualBuilder
     Web Design
     Your HTML Source
     XML/XSLT Forums
     ASPAlliance
     Scripts
     
     Programmers Heaven
     Tek-Tips Forums
     Developer Fusion
     Code Project









EVENT:  onselect

onselect="action"
 
The onselect event occurs when a single character in a text is highlighted by using the mouse to drag over the character. This is called a select. Whenever the select occurs, the script code associated with the onselect event is executed. This script can call JavaScript functions that contain code that you want to run when the select occurs.
 
These six events are useful when dealing with forms and form elements:
 
  • onblur - runs a script when the element loses focus.
  • onchange - runs a script when the element changes.
  • onfocus - runs a script when the element gets the focus.
  • onreset - runs a script when the form is reset.
  • onselect - runs a script when the element is selected.
  • onsubmit- runs a script when the form is submitted.

  •  
    In this example, every time you use the mouse to highlight the text in the input window, an alert appears.
     
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <title>DevGuru XHTML onselect Example</title>
    </head>
    <body>
    <form>
    Please use the mouse to highlight the text in the input window
    <br />
    Note that as soon as you highlight one character, the alert appears
    <br />
    <input type="text" value="DevGuru" id="text1" name="text1"
    onselect="JavaScript:alert('Thank you for choosing DevGuru!')" />
    </form>
    </body>
    </html>

     
    Output:
    Click to view and test in separate window


     


    Copyright 1999-2005 by Infinite Software Solutions, Inc. All rights reserved.
    Trademark Information