3 Replies - 580 Views - Last Post: 15 April 2012 - 11:11 AM

#1 WyoWild  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 06-March 11

Submit button won't bring up acknowledgement page

Posted 15 April 2012 - 07:10 AM

The requirement is a submittal form that includes names addresses, etc. to return an acknowledgement when the "submit" button is hit.
<html>
   <head>
      <title>Customer List</title>
	  <p><center><IMG SRC="C:\Users\Owner\Documents\UOP\WEB406\kudlerLogo.jpg" ALT="Kudler Logo" width="650" height="125" /></center></p>
   </head>

<script LANGUAGE="Javascript">

<!--  Begin
	function resetform() {

		doc = document.forms[0];
		doc.Email Address.value = "";
		doc.Last Name.value = "";
		doc.First Name.value = "";
		doc.Address.value = "";
		doc.City.value = "";
		doc.State.value = "";
		doc.Zip.value = "";
		doc.Phone Number.value = "";
				
	}  // end clearData

	function openURL() {
		doc = document.forms[0];

		document.location = "E:\WEB406\acknowledgement.htm";
		} 
 // end openURL
	
// End -->
</SCRIPT>

<style type="text/css"> 

* {
padding: 0;
margin: 0;
}

body {
font-size: 1.1em;
font-family: Arial;
color: #562208;
background-color: #E2DFCC;
} 
</style>
<BODY>

<CENTER>
<br>	</br>
   <form method="post" name="customerlist">
	<h2><center>Customer Enrollment</center></h2>
 
<TABLE border=1 cellspacing=0 cellpadding=1 bgcolor="#DDD9C3">
<tr valign=baseline>
<TD>
<font face="arial">Email Address:</font>
</TD>
<TD>
<input type=text name="Email Address" size=35,1 maxlength=80>
</TD>
</tr>
<tr>
<TD>
<font face="arial">First Name:</font>
</TD>
<TD>
<input type=text name="First Name" size=35,1 maxlength=80>
</TD></tr>
<tr>
<TD>
<font face="arial">Last Name:</font>
</TD>
<TD>
<input type=text name="Last Name" size=35,1 maxlength=80>
</TD></tr>
<tr>
<TD>
<font face="arial">Address:</font>
</TD>
<TD>
<input type=text name="Address" size=35,1 maxlength=80>
</TD></tr>
<tr>
<TD>
<font face="arial">City:</font>
</TD>
<TD>
<input type=text name="City" size=35,1 maxlength=80>
</TD></tr>
<tr>
<TD>
<font face="arial">State:</font>
</TD>
<TD>
<input type=text name="State" size=10,1 maxlength=25>
</TD></tr>
<tr>
<TD>
<font face="arial">Zip Code:</font>
</TD>
<TD>
<input type=text name="Zip" size=20,1 maxlength=35>
</TD></tr>
<tr><TD>
<font face="arial">Phone Number:</font>
</TD>
<TD>
<input type=text name="Phone Number" size=25,1 maxlength=50>
</TD>
</tr>
</TABLE>
<p><br>
<center>
<input name="submit" type="button" value="  Submit  " onclick="openURL()">
<input type="reset" type="button" value="Reset Form" onclick=resetform()>
</p>
</FORM>
</CENTER>

 </html>



Is This A Good Question/Topic? 0
  • +

Replies To: Submit button won't bring up acknowledgement page

#2 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3115
  • View blog
  • Posts: 4,675
  • Joined: 08-June 10

Re: Submit button won't bring up acknowledgement page

Posted 15 April 2012 - 07:50 AM

Hey.

First of all, a few comments on the HTML:

  • You are missing a Doctype. All HTML pages should declare a doctype at the top of the page, so the browsers will know what type of HTML they are dealing with. If you don't do this, the browser will be forced to render the page in Quirks Mode, which basically means your page is rendered like it's being shown in IE5; a total disaster.

  • The <font> tag is really really outdated, and should no longer be used. Instead, style your HTML using CSS. This goes for ANY HTML styling tags or attribute, including <center> and things like bgcolor attributes on tables.

  • The language attribute on the <script> tag is no longer used. Javascript blocks should be declared as <script type="text/javascript">, or in the case of HTML5 documents, just <script>.

  • It's generally not a great idea to use a <table> to set up the layout of your site. Tables are meant to show tabular data. The layout should be defined in your CSS styles. - Although, this is still a much debated topic and what is and is not proper use for tables is not always clear. In your case, however, I would say that you'd be better of using a CSS layout. It would simplify the HTML and make it more flexible.


OK then, on to the Javascript.

You don't actually need the resetform() function. If you add a <input type="reset"> to a form, it will automatically reset the form when clicked. You don't have to manually code it.

However, just to be thorough, I'll point out the problems in it anyways. - Javascript has syntax rules. Variable and property names can not include spaces. Which means that the following lines from your code are invalid, and will cause errors:
doc.Email Address.value = "";
doc.Last Name.value = "";
doc.First Name.value = "";


You'd have to either change the names to something that is a valid Javascript identifier, or use the array-like syntax for accessing the property.
// If you were to shorten the names to valid
// Javascript property names.
doc.email.value = "";
doc.fname.value = "";
doc.lname.value = "";

// Or, if you want to keep the old names:
doc["Email Address"].value = "";
doc["Last Name"].value = "";
doc["First Name"].value = "";



You can also add IDs to the input elements, allowing you to access them directly without having to go through the form.
// In the HTML
<input type="text" name="Email Address" id="email_address">

// In the Javascript
var email = document.getElementById("email_address");
email.value = "";


Many prefer this over the method you are using, as it's more flexible. It also means that there doesn't actually have to be a <form> element, which is not something you really need in more modern AJAX driven code.
Was This Post Helpful? 0
  • +
  • -

#3 WyoWild  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 06-March 11

Re: Submit button won't bring up acknowledgement page

Posted 15 April 2012 - 11:05 AM

I appreciate the input. I got the submit button to work.

This post has been edited by Atli: 15 April 2012 - 11:10 AM
Reason for edit:: Removed the unnecessary quote.

Was This Post Helpful? 0
  • +
  • -

#4 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3115
  • View blog
  • Posts: 4,675
  • Joined: 08-June 10

Re: Submit button won't bring up acknowledgement page

Posted 15 April 2012 - 11:11 AM

No problem. Glad you got it working! :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1