Power Stuff
Apart from the validation methods, everything described on this site can be done with simple editing and straightforward HTML.
The methods described for the tips below all require some javascript to run when the form is processed (as soon as the 'submit' button is pressed).
If you are uncomfortable at the thought of working with simple javascripts, then this page is not for you.
Each of the next three tips below uses a few javascript lines to change the value of one of the hidden inputs in your form.
The last Power Tip describes how to use images instead of buttons for the form submit and reset functions.
A copy for the sender
Sometimes, you would like the person sending the form to get a copy of what they sent. This is a lot easier than you think.
The 'trick' is to get the e-mail address the visitor entered and make the 'carboncopy' value the same as the visitor's replyemail address.
The form ACTION line is modified to cause a script to execute when the SUBMIT button is clicked. Here's how a partial version of your form will look:
<form name="myform" onSubmit="fixData()" action= .... etc.
<input type="hidden" name="carboncopy" value="">
Enter your e-mail address:
<input type="text" name="replyemail" value="" size="20">
In the example below, the javascript function fixData() is called and finds the value of replyemail [sender's e-address], and sets the carboncopy value equal to it:
<script type="text/javascript">
<!--
function fixData() {
ccTo = document.myform.replyemail.value
document.myform.carboncopy.value = ccTo
return
}
//-->
</script>
click here for a sample page containing all the code you need.
A copy for the sender & someone else
This can be used when you already have an e-mail address in the carboncopy field. It uses exactly the same technique as sending a copy to the sender, except that the carboncopy hidden field value is added to when the form is submitted.
The relevant changes to the scripting described above is quite simple:
<script type="text/javascript">
<!--
function fixData() {
ccTo = document.myform.carboncopy.value
document.myform.carboncopy.value = ccTo + "," + document.myform.replyemail.value
return
}
//-->
</script>
click here for a sample page containing all the code you need.
Choose a subject from a list
This uses exactly the same technique as sending a copy to someone chosen from a list - except that the subject hidden field value is changed when the form is submitted.
The javascript needed simply replaces the subject value with the value of the selected item from your drop down list.
click here for a sample page containing all the code you need.
Images instead of buttons
No matter how much you pretty up the form submit and clear buttons .... they are still pretty ugly. Images can be used instead of the form buttons.
The only 'trick' is that clickable images in forms normally submit the form, so that the 'reset' function cannot be handled by a simple clickable image.
The solution is to use the javascript reset() function to accomplish the form reset, by using the code below with your 'reset' image:.
<a href="javascript:document.formname.reset()"><img src=....></a>
Here's a full example, that will send a message to me.
click here for a sample page containing all the code you need.
|