Attaching custom scripts to HTML form buttons

Attaching custom scripts to HTML form buttons

Some forms use JavaScript or VBScript to perform form processing or some other action on the client as opposed to sending the form data to the server for processing. You can use Dreamweaver to configure a form button to run a specific client-side script when the user clicks the button.

To run a script on the client:

  1. Select a Submit button in a form.
  2. In the Behaviors panel (Window > Behaviors), click the Plus (+) button and select Call JavaScript from the list.

    For more information on this behavior, see Call JavaScript.

  3. In the Call JavaScript text box that appears, enter the name of the JavaScript function you want to run when the user clicks the button, and click OK.

    For example, you can enter the name of a function that doesn’t exist yet, such as processMyForm().

  4. If your JavaScript function doesn’t exist in the head section of the document yet, add it now.

    For example, you could define the following JavaScript function in the head section of the document to display a message when the user clicks the Submit button.

    function processMyForm(){
       alert('Thanks for your order!');
       }
    


Getting Started with Dreamweaver
Dreamweaver Basics
Working with Dreamweaver Sites
Laying Out Pages
Adding Content to Pages
Working with Page Code
Preparing to Build Dynamic Sites
Making Pages Dynamic
Defining Sources of Dynamic Content
Developing Applications Rapidly