PDA

View Full Version : linking a js file causes major problems


JaeSun
11-25-2004, 03:42 AM
ok. i got this javascript file.

SAME EXACT as used here:

http://webcs.cs.unlv.edu/j_rider/assignments/assgn6/form.html
http://webcs.cs.unlv.edu/j_rider/assignments/assgn6/a6js.js

i just copy and paste word for word to this page:

http://www.whiteazn.com/satworld/contact/

all of a sudden, causes 2 things:

1. page doesnt show up in IE (view source shows its there). just a blank screen

2. in firefox, it doesnt work at all.


any reason why it may cause this?

i just copied and pasted everything over?

code of the contact page that not working:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Satellite World - contact us</title>
<script type="text/javascript" src="../html/satworld.js">
<?php include("../html/head.inc") ?>
</head>
<body>
<div id="mainCenter">
<div id="topHeader"><?php include("../html/topMenu.inc") ?>
<div class="crumbs"><a href="../">home</a> &gt; <a href="../about/">about satellite world</a> : contact us </div>
</div>

<div id="bodyContent">

<?php include("../html/menuContact.inc") ?>

<div id="contentBody">
<h1 class="titleh1">Contact Us</h1>
<p><span class="bold">Sales and Support </span></p>
<blockquote>
<p><span class="bold">Telephone:</span><br />
(866) 564-0790 (toll-free)</p>
<p><span class="bold">E-mail:</span><br />
sales [at] satworld.biz
</p>
<form id="contact" method="post" action="thankyou.php" onsubmit="return validate(this)">
<fieldset><legend>Contact Form:</legend><br />
<label for="name">Name:</label><input class="form" type="text" name="name" id="name" size="25" />
<br />
<br />
<label for="email">Email Address:</label><input class="form" type="text" name="email" id="email" size="25" />
<br />
<br />
<label for="phone_num">Phone Number:</label><input class="form" type="text" name="phone_num" id="phone_num" size="25" />
<br />
<br />
<label for="contact_method">How would you like to be contacted?:</label>
<input type="checkbox" name="contact_method" id="contact_method" value="contactby_email" />
Email <input type="checkbox" name="contact_method" id="contact_method" value="contactby_phone" />
Phone <br />
<br />
<br />
<label for="interest">Inquiring about:</label>
<select class="form" name="interest" id="interest">
<option selected="selected"></option>
<option class="fhighlight">PRODUCTS INFORMATION:</option>
<option>datastorm</option>
<option>globalstar</option>
<option>direcway</option>
<option>tachyon</option>
<option>rv satellite tv</option>
<option>computer and networking</option>
<option></option>
<option class="fhighlight">INSTALL:</option>
<option>schedule an installation</option>
<option></option>
<option class="fhighlight">SUPPORT:</option>
<option>support</option>
<option></option>
<option class="fhighlight">OTHER:</option>
<option>other</option>
</select><br />
<br />
<label for="comments">Comments:</label>
<textarea name="comments" cols="35" rows="6" class="form" id="comments"></textarea>
<br />
<br />
<label for="submit"> </label>
<input type="hidden" name="ftype" value="contact" />
<input type="submit" class="form" id="submit" value="submit" />
<br />
<br />
<span class="bold">Your information remains private, and is never sold, rented, or given out to anyone.</span>
</fieldset>
</form>
</blockquote>

</div>
</div>

<?php include("../html/footer.inc") ?>

</div>
<p>&nbsp;</p>
</body>
</html>


javascript file:

function validate(theForm)
{

x=theForm

//this will check the name for only alpha characters

var charpos = x.fName.value.search("[^A-Za-z]");

if (charpos >= 0)
{
alert("You have not entered a valid name: Only Characters allowed (A-Z, a-z)")
return false
}


//this will check for the email address

at=x.email.value.indexOf("@")
dot=x.email.value.lastIndexOf(".")

//checks for @
if (at == -1)
{
alert("You have not entered a valid email address: It must be in the following format - email@domain.com")
return false
}

/*
checks to see if the "." is after the @ symbol
(to check just in case format is: myemail@whatever )
*/

if (at != -1 && dot < at)
{
alert("you have not entered a valid email address: It must be in the following format - email@domain.com")
return false
}

//this will check the format of the student ID in xxx-xx-xxxx

fdash=x.studentID.value.indexOf("-")
ldash=x.studentID.value.lastIndexOf("-")

if (fdash != 3 || ldash != 6)
{
alert("you have not entered a valid student ID: It must be in the following format - xxx-xx-xxxx")
return false
}

}

i dont get why it works on one page and not the other

JaeSun
11-25-2004, 04:05 AM
nevermind, found the problem ....