There are many reasons why you might not want to use CGI forms on your Web site. For example your web site may be on a free host that does not allow custom CGI scripts. You may want to conserve bandwidth on your Web server. Or maybe you just don’t want the hassle of CGI programming.
Welcome to Bucaro TecHelp!

Welcome to Bucaro TecHelp!
Maintain Your Computer and Use it More Effectively
to Design a Web Site and Make Money on the Web

[About BTH]  [User Agreement]  [Privacy Policy]  [Site Map]  [Contact Form]  [Advertise on BTH]  [News Feed]

Google
Web
This Site

Submit Forms Without CGI

There are many reasons why you might not want to use CGI forms on your Web site. For example your web site may be on a free host that does not allow custom CGI scripts. You may want to conserve bandwidth on your Web server. Or maybe you just don’t want the hassle of CGI programming.

An alternative method to let visitors to your Web site submit forms is through email. If you know how to code a form in html and you know a little JavaScript, then designing a form for email submission is not difficult. If you don’t know either of those things, you can still design your own email submission form if you can follow the pattern of the code provided with this article.

The code provides an example of using checkboxes, a select list, and a text area with an email submission form. If you can follow the pattern, you can edit the code to your requirements, remove some elements, and add more of a different element.

The code comes in two basic parts, the html form, and a JavaScript function that applies a bit of processing to the form’s data before submitting it to the users email program.

The first problem I found with submitting a form by email is that the form’s action property captures only the first input element of the form. So I added a hidden input as the first element of the form. When the user clicks on the "Submit" button, the form is passed to a JavaScript function that collects the data from all the input elements of the form and places them in that first hidden element.

The second problem I found with submitting a form by email is that the form’s data is submitted in URL encoded format. It's possible to type any character into a text box on a form, including slashes and other characters that have meaning in a URL. Also, a URL can’t have spaces. When you submit the form, the browser replaces dangerous characters with other characters, and spaces are replaced with "+" signs. The JavaScript function uses URL escape characters to reformat the data so it creates a more understandable email message.

To a non-programmer, the escape characters make the JavaScript code look way more complicated than it is. You might want to make a second copy of the code, and in that copy, remove all the escape characters to make the program more readable. The escape characters used are listed below.

%0a = Line Feed
%0d = Carriage Return
%20 = Space

Web Design Sections

RSS Feed RSS Feed

Easy Java Script Code
Easy Java Script Windows
Easy Rollovers
Easy Picture Transition Effects
Easy Moving Popup Code
Easy Slide Show Code
Easy Slide Show Code With Linked Slides
Slide Show with Different Size Images
Easy Picture Zoom Code
Easy Picture Panning Code
Easy Java Script Animation
Easy JavaScript Picture Selector Code
Easy Animated Banners with Java Script
Easy Java Script Form Validation
Easy Drag n Drop Code
Easy Graph Generating Code
Easy Code to Sort a Table by Column
Easy Fading Text Banner Code
Easy Expanding Banner Code
Calendars for Your Website
Date Picker For Your Web Site
Calculators For Your Web Site
Loan Payment Calculator
Length Units Converter
Body Mass Index
Fahrenheit to Celsius Converter
Decimal to Hexidecimal Converter
Easy Code for Screen Tape Adding Machine
Code for Java Script Circle⁄Sphere Calculator
Round a Float to 4 Digits to the Right of the Decimal Point
Make Your Own Graphical Digital Clock
Let Your Web site Visitors Set Font Size
How to Disable the Browser Back Button
Add More Bang to Your Content With Keyword Popup Menus
Put a Music Off Switch on Your Webpage
Java Script Random Password Generator
Password Protection Using Java Script
Replace Drop-down with Drag-and-drop
Submit Forms Without CGI
Code for a Less annoying Popup Window
Using the Java Script Array Object
Using the Java Script Date Object
Java Script Message Boxes
How to Shuffle the Deck With Java Script
Web Site Menus : Which Section Am I In?
How Far Did the User Scroll?
Where Did the User Click?
Four Ways to Use Java Script Event Handlers
Create Your Own Database Using Only Notepad : CDV

[Site User Agreement]  [Advertise on This site]  [Search This Site]  [Contact Form]
Copyright©2001-2007 Bucaro TecHelp P.O.Box 18952 Fountain Hills, AZ 85269