Frames & Websites
 How to fix pages that open without their accompanying frameset! Fix for when a user finds you're website via a search engine but the pages open without the frameset.

Website: About Us ◄    ► Portfolio ◄    ► Contact Us

 







Website Hosting
Website Design
CDROM Productions
SEO
Database Design
Business ISP Services
Residential ISP Services

 

 





SEO Tips
Search Engines
Forms
Frames
ASP
 




About Us
Portfolio
Contact Us
Articles


Home

 
 

This is a basic introduction to using forms.
PLEASE be aware that I am not an IT Coding GURU rather I am self taught. Most of this code will not be exactly as an actual IT Guru would possibly have used, but it is functional, and hopefully written in such a way as to be used by you as a learning tool. These pages are how I would have liked to have code explained to me when I was learning!

Please Note: The following code snippets are Copy written to Vortex Media. You can use this code free of charge as long as the commented sections containing the copyright information (if used) remains intact. Please include a link back to www.vortexmedia.com.au if you use this code. By using the code below you agree that Vortex Media are not liable to you for any loss or damage ---- you know the drill, if you don't then read our disclaimer.

 
 

Let me know if this code was at all helpful!

Forms


Basic Anatomy of a Form:
<form name="myForm" action="process.asp" method="post" target="_blank">
<input type="text" name="text1" value="My Text" size="20">
<input type="hidden" name="my_hidden_field" value="It's A Secret">
<input type="submit" value="Submit"  name="submit">
</form>

How forms are submitted:
When a form is submitted the values are sent to the requesting page via the URL. To explain this, say you have a form that gets the users first name and last name with the field names as first_name and last_name and the requesting page resides at www.vortexmedia.com.au/user-details.asp when the form is submitted then the URL becomes www.vortexmedia.com.au/user-details.asp?first_name=John&last_name=Smith.
All form fields are sent in the URL as shown above or in the URL Header (hidden).

Processing Page:
The processing page is the file or page of where the contents of the form will be sent. The processing page can be the page that holds the form (submit the form to it's self) but normally the processing page will perform some sort of action on the forms data like: write the data to a database, email the data, send the user to another page etc.  Processing pages can be written in JavaScript, Perl, CGI, ASP, Flash or just about any language can process a forms data. In these tutorials we will be using ASP.

The Name Parameter ( <form name="myForm"> </form> )
The name of a form is important and should reflect what information collection the form is being used for. Validation of a form requires that a name for the form be used. Do not duplicate form names on your page if using more than one form as this can have unexpected results.

The Action Parameter ( action="new_page.htm" ):
The action area of the form tag holds the information of where the form is to be submitted. You can specify the processing page or use the “existing file name” to make the form submit back to itself.

Target ( target="_blank" ):
Target is used to specify where you would like the processing page to open I.e.
- In a new window: _blank
- In the same window or frame: _self
- Frameset name: name_of_frame
- parent window: _parent

Using Get or Post method ( method="POST" ):
The method area of the form tag can have two options, either GET or POST. Both methods get the job done but slight variances in code are used to retrieve the form values and will be explained later. If using GET then be aware that most Hosting Providers limit the amount of data that can be carried by the URL with GET so if you require a large amount of form information then the use of POST is preferred.

There may be issues of which method to use with other languages such as CGI or Perl but with ASP any method goes and I can see no advantage using one or the other except with the data limitations of GET.

Field Names ( input type="text" name="text1" ):
A field is each separate part of the form. Input types, hidden fields, buttons etc are all form fields or form elements. Each field should have it's own unique name which is then used to reference it's field value. Duplicate field names can be used and there are distinct advantages when doing so but on most occasions duplicate field names are not required.

Hidden Fields ( input type="hidden" ):
Hidden fields in forms are gods send to web developers. Although the hidden fields are not displayed on the actual form all values of hidden fields are sent in the URL. They are an easy way of passing parameters to other pages or for hard coding values that are required by the processing page. Although not covered here, hidden fields are great for utilising SQL queries to databases.

Form Validation:
If using a separate processing page other than that of which the form resides I prefer to use JavaScript to perform form validation before the form is submitted rather than use the processing page to validate. To do this you use a button that the user thinks is the submit button but actually the button conducts validation before submitting.

Below is a basic form that includes validation with JavaScript. If the validation is ok, it then submits the form.
In the example the forms name is "notify".

<html>
<head>
<title>
My FORM Trial </title>

<script Language="JavaScript">

// This function is triggered by the forms “send form” button
function checkFields() {
// document.notify.name.value == "") means in the current document, in the form named notify, the field named [name] check if it is null.
if (document.notify.name.value == "") {
// in the field called 'name' if the value is null (blank) do the following
alert("I'm sorry. Please include you name.");
document.notify.name.focus(); return;
// sets the cursor to the name field

}

if (document.notify.email.value.indexOf("@")<3){ // checks for at least 3 characters before the @

alert("I'm sorry. This email address seems wrong. Please  check the username or include the '@' sign.");
document.notify.email.focus(); return;

}

else {  // if none of the fields have any errors then submit the form

document.notify.submit(); // In this document,  submit the form called notify

}

}

</script>

</head>
<body>
<form method="GET" name="notify" action="form.asp" target="_blank">
<font color="#800000" size="2">
<input type="text" value="" name="name" size="20">
Name<br>
<input type="text" value="" name="email" size="20">
Email<br>
<input type="text" value="" name="acode" size="4">
Ph Area Code <br>
<input type="text" value="" name="phone" size="20">
Phone<br>
<textarea rows="4" name="comments" cols="30">
Leave your message here.
</textarea><br>
I prefer to be contacted by
<select size="1" name="contact_by">
<option selected value="Email">
Email</option>
<option value="Phone">
Phone</option>
</select>
<input type="button" value="Send Form" onClick="return checkFields();" name="B1">
</font>
</form>
</body>
</html>

 

 
   

More


ASP
  Introduction to ASP (Active Server Pages)
      Variables
      Arrays
      Naming Conventions
  QueryString's and Form Data 

Framesets: How to ensure a page opens in it's frameset

SEO (Search Engine Optimisation) Tips

Which Search Engine Is Right For You?

 
   

Need Help With This Code


If you do find yourself having problems getting this code to work then please contact me at support@vortexmedia.com.au explaining the problems or errors you are having. I will try to get back to you quickly but please be aware that at times I am unable to reply to all requests in a speedy manner.

 

  Client Login
 

Disclaimer \ Privacy

© Vortex Media 2004
All Rights Reserved