I'm still new to JavaScript and I'm having trouble with an assignment. I can't seem to get my functions to work right for the alert to check for missing information when you submit the page and when you select the checkbox for the same as billing address? Thanks for the help!!

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>U-Built-It Hardware Company</title>

<script type="text/javascript">

<!-- Hide from incompatible browsers

function validate( form )
{ var nameField = form.firstname;  
if ( nameField.value == "" ) { alert('\nMissing Information!'); 
nameField.focus(); return false; }
else { alert('\nDo the next stuff!'); 
return true; }}

function Setshippinging(checked) {
	if (checked) {
		document.getElementById('ShippingAddress').value = document.getElementById('BillingAddress').value; 
		document.getElementById('ShippingCity').value = document.getElementById('BillingCity').value; 
		document.getElementById('ShippingState').value = document.getElementById('BillingState').value; 
		document.getElementById('ShippingZip').value = document.getElementById('BillingZip').value; 
		document.getElementById('ShippingCountry').value = document.getElementById('BillingCountry').value; 
	} else {
		document.getElementById('ShippingAddress').value = ''; 
		document.getElementById('ShippingCity').value = ''; 
		document.getElementById('ShippingState').value = ''; 
		document.getElementById('ShippingZip').value = ''; 
		document.getElementById('ShippingCountry').value = ''; 
	}
}





// Stop hiding from incompatible browsers -->

</script>
<style type="text/css">
hr.c2 {color: rgb(133,0,0); background-color: rgb(133,0,0); height: 1}
td.c1 {font-family: sans-serif; font-size: large; font-weight: bold}
</style>
</head>
<body>
<form>
<table>
<tr>
<td class="c1" colspan="2" width="100%">
<h1>U-Built-It Hardware Company</h1>
</td>
</tr>
<tr>
<td colspan="2">
<hr class="c2" /></td>
</tr>
<tr>
<td class="c1" colspan="2" width="100%">Billing Information</td>
</tr>
<!-- Billing Information -->

<tr>
<td valign="top" colspan="2">
<table>
<tr>
<td>
<form onreset="alert('The form will be reset')">Firstname: 
</td>
<td><input type="text" name="fname" id="fname" size="30" /> <label for="lname">Last Name</label> <input type="text" 

name="lname" id="lname" size="30" /></td>
</tr>
<tr>
<td><label for="address1">Address #1</label></td>
<td><input type="text" name="address1" id="address1" size="60" /></td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td><label for="addess2">Address #2</label></td>
<td><input type="text" name="address2" id="address2" size="60" /></td>
</tr>
<tr>
<td><label for="city">City</label></td>
<td><input type="text" name="city" id="city" size="40" /> <label for="state">State</label> <input type="text" name="state" 

id="state" size="3" /> <label for="zip">Zip</label> <input type="text" name="zip" id="zip" size="10" maxlength="10" /></td>
</tr>
<tr>
<td><label for="country">Country</label></td>
<td><input type="text" name="country" id="country" size="40" value="United States" />
<br /><br />
<input type="reset" value="Reset">

</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2">
<hr class="c2" /></td>
</tr>
<tr>
<td class="c1" colspan="2" width="100%">Shipping Information</td>
</tr>
<!-- Shipping Information -->
<tr>
<td colspan="2&quot;"></td>
</tr>
<tr>
<td valign="top" colspan="2">

 


<input type="checkbox" onclick="SetShipping(this.checked);"
/>Same as Billing Address<br />

<table>
<tr>
<td>
<form onreset="alert('The form will be reset')">Firstname: 
</td>
<td><input type="text" name="fname1" id="fname1" size="30" /> <label for="lname1">Last Name</label> <input type="text" 

name="lname1" id="lname1" size="30" /></td>
</tr>
<tr>
<td><label for="address">Address</label></td>
<td><input type="text" name="address" id="address" size="60" /></td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td><label for="addess">Address</label></td>
<td><input type="text" name="address" id="address" size="60" /></td>
</tr>
<tr>
<td><label for="city2">City</label></td>
<td><input type="text" name="city2" id="city2" size="40" /> <label for="state2">State</label> <input type="text" 

name="state2" id="state" size="3" /> <label for="zip2">Zip</label> <input type="text" name="zip2" id="zip2" size="10" 

maxlength="10" /></td>
</tr>
<tr>
<td><label for="country2">Country</label></td>
<td><input type="text" name="country2" id="country2" size="40" value="United States" />
<br /><br />
<input type="reset" value="Reset">
</form> 
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2">
<hr class="c2" /></td>
</tr>




<!-- Product Information -->
<tr>
<td class="c1" colspan="2" width="100%">Hand Tools</td>
</tr>
<tr>
<td valign="top" colspan="2">
<table>
<tr>
<td width="100" valign="top" rowspan="2"><label for="item">Item Purchased</label></td>
<td valign="top" rowspan="2"><select name="item" id="item">
<option>Planes</option>
<option>Gouges</option>
<option>Hammers</option>
<option>Chisels</option>
<option>Saws</option>
<option>Screwdrivers</option>
</select></td>
</tr>

<!-- Buttons -->
<tr>
<td valign="top colspan="2" align="center">



<form action="submitpage.htm" name="form1" onsubmit="return validate( this );" method="post">
<input type="submit" value="Submit" />




</form>

</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
This article has been dead for over six months. Start a new discussion instead.