Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Attribute for <SELECT ...>
onChange = "script command(s)"

Looking for information on dropdown menues? See our Dropdown Menu Tutorial.
onChange designates a JavaScript to run when the user chooses one of the options. This means that an action is initiated immediately when the user chooses an item, not when a "submit" button is pressed. A popular use for onChange is to make the <SELECT ...> list a set of hyperlinks. This allows you to display many links in a very compact space:

<FORM>
<SELECT ONCHANGE="location = this.options[this.selectedIndex].value;">
<OPTION VALUE="myhome.html">My Home Page
<OPTION VALUE="myresume.html">Resume
<OPTION VALUE="myhobbies.html">Hobbies
<OPTION VALUE="mydog.html">My Dog
</SELECT>
</FORM>

which gives us

It's usually better to use a submit button instead of onChange. The interface is cleaner if you separate the actions of selecting a destination and of saying "now go". See Drop Down Menu Tutorial for complete code and examples.

 
 
  Copyright 1997-2002 Idocs inc. Published under the terms of the Open Content License Design by Interspire