![]() |
![]() |
|||||||||||||
|
||||||||||||||
Don't have CGI? Here's a feedback form for you. First, I'll give you the code to copy and paste. (You change only one thing.) Then, for those of you who like to tinker, I'll talk a little about how to customize it. The following is real code, both JavaScript and HTML. If your email program tries to run the code (like some HTML enabled email programs will, even when the header specifically states the contents are ASCII/plain text), some of the JavaScript or HTML code might not be printed; or your background color may be unusual. If such applies to you, go to http://willmaster.com/possibilities/archives and read the online version. As an alternative, you can copy the code from the demo page at http://willmaster.com/demo/jsfeedback.html The copy and paste JavaScript Feedback Form code comes in two pieces. The first piece is the JavaScript email formatting function and belongs somewhere between the <head> and </head> tags of your HTML page. Here is the first piece:
That first piece needs one change. Currently line 5 reads:
var toaddy = 'name@domain.com'; On that line, replace name@domain.com with your email address. The second piece is the code for the form itself. It belongs on your HTML page wherever you want to put the form. Here is the second piece:
That's all you need for a JavaScript Feedback Form. Something you probably want to do Most browsers are JavaScript enabled. This feedback form works with those. If you want to warn people using JavaScript disabled browsers so they don't get frustrated trying to use your form, put the following three lines somewhere on your page (right above your form will probably be a good place to put it):
With the above three lines, JavaScript disabled browsers will see the message but JavaScript enabled browsers will not. For those who want to tinker If you want to edit the form, you'll need to edit both the first and second pieces. For practice, let's suppose you want people to give you the URL of their business site for a links page. So we edit the feedback form (the second piece) making it ask for the URL. Find where the name and email form fields are located. Insert the url form field between the two. Just as the name and email fields have names (name="____"), so the url field must have a name. Call it "url". (By the way, don't call the name field name="name" because at least one popular browser version gets confused.) Okay, now it's time to tell the JavaScript function (the first piece) how to handle the new field. Let's get oriented a bit first. (When you know what some of the symbols mean you'll feel more at home.)
The stuff between the apostrophes (single quotes) is treated literally. The rest is determined to be the name of something. For example, document.jsform.email.value is the name of the form's name="email" field. Wherever the name document.jsform.email.value is found, the form's value (what the user types in) is substituted instead. The plus signs attach stuff together, end to end. So where you see:
'Email%20is\n\t' + document.jsform.email.value it translates as:
Email is name@domain.com You notice that most of the lines end with a plus sign. That tells the function to attach the next line, too.
Armed with the above, go ahead and insert the code to print the URL that people will type into the form. Your code will look something like this:
The form can accept any standard form input such as checkboxes and list selections. When you're ready to print what the user types or selects, use the document.jsform.NAME.value (replacing NAME with the form field's name) to represent where you want it printed. You can make surveys, questionaires, and even subscription forms by customizing the JavaScript Feedback Form. Happy communicating. Copyright 2000 by William Bontrager
William Bontrager, Programmer and Publisher
| ||||||||||||||