1. Computing

Discuss in my forum

Use JavaScript to Make an HTML Form Do Something

What HTML Can't Do

By , About.com Guide

HTML forms are one of the most frustrating parts of HTML. Why? Well, you can make a form on your Web page, but you can't use HTML to make the form do anything.

To make a form do something, you need to use some type of activation script. The most common form activation is CGI. You can use a CGI script to do just about anything you can think up. You can also use JavaScript to make a form do something.

A Simple JavaScript Form

One form that is fun to use on a Web site is also easy to make work using JavaScript. The "jump" drop-down list:

Try out the form

Here's the source to the form (make sure to put the onchange information all on one line):

<form action="" method="post">
<select name="URL" onchange="javascript:window.location.href=this.form.URL.options [this.form.URL.selectedIndex].value">
    <option>Choose One</option>
    <option value="http://webdesign.about.com/">Web Design Home Page</option>
    <option value="http://webdesign.about.com/library/weekly/mpreviss.htm">Previous Articles</option>
    <option value="http://webdesign.about.com/library/beginning/bl_begin.htm">Beginning HTML</option>
</select>
</form>

Other Things HTML Can't Do

Previous Features

  1. About.com
  2. Computing
  3. Web Design / HTML
  4. HTML and XHTML
  5. XHTML
  6. Forms
  7. Making HTML Forms Work - Use JavaScript to Make HTML Forms Work

©2013 About.com. All rights reserved.