What we need…
- An HTML Form with Input Elements for data we would like to collect
- Name
- Email Address
- Subject
- Comments
- An ASP Script to collect, format, and send the information to an email recipient
- A page informing the user their message has been sent
Creating the HTML Form
- Open Dreamweaver and create a new HTML Page
- Select from the Insert Menu – Insert Form
- Select from the Insert Menu – Insert Fieldset
- Select from the Insert Menu – Insert Label
- Place your cursor inside the Filedset and select Insert>Form>Text Field
- Create a Label
- Select Attach label using “for” Element
- This will place the label and the input box into the same table cell. You’ll need to drag or cut and past the input field to the right column. (see screen shot below for the desired result)
- Repeat Step 5 creating a field for the email address and subject
- Place your cursor in the Forth row of the table and select Insert > Form> Text Area
- Create a Label
- Select Attach label using “for” Element
- Place your cursor in the third row of the table and select Insert>Form>Button
- Paste the following two elements into the code somewhere between the <form> Tags. These are hidden elements that tell the script where to send the visitor after they have submitted the form.
[crayon]
[/crayon]
Naming the Form Elements
- Select the Name Input Field
- In the Properties Inspector name the field txtName
- the txt prefix tells the ASP script to harvest the information from the field
- Repeat steps 1 and 2 for the Email, Subject, and Comments Field
- txtSendToEmailAddress – Email Field Name
- txtEmailSubject – Subject Field Name
- txtComments
Trimming the Form Elements
In order to properly submit the information in the form we need a JavaScript to make sure the content is appropriate for submission.
- Copy the following Script and paste it in the head of your document.
Customizing the Script
- Download the ASP script
- Save the file into the root directory of your web site as mail.asp
- Open the mail.asp file in Dreamweaver and switch to code view
- Set the Parameters for the following Elements
[crayon]
Const strHeader = “Email Header ”
Const strFooter = “Email Footer”
Const strTo = “youremail@domain.com”
[/crayon]
- Save the mail.asp file
Integrating the Script with the Form
- On the HTML page with the form add the following to the <form> tag
[crayon]