Click to See Complete Forum and Search --> : Need simple tweak for free script


nellgavin
01-23-2003, 10:46 AM
I downloaded a javascript for an email form. It appears to work except for one irritating little thing: I can't edit the default text in the name field to say "Name". It only displays as "Null" no matter what I do.

I'm working on the web page within Front Page. I copy/pasted the code without altering it, and shot it over to the server. The word "Null" displayed in the Name field.

So I made a change to that field to set the default text, and displayed it in Preview mode within Front Page. It looks fine: the field says "Name". Then I sent it over to the server, where you can view it at www.bookandquill.com/testcontrol.htm. The word "Null" is back.

I would be satisified if NOTHING displayed in that field - my objective is really just to remove the word "Null".

I am not a programmer, so I'm reluctant to alter the code. I identified several places where the word "Null' appears within the code, but I don't know which one is the culprit in this instance. Could someone please help?

gil davis
01-23-2003, 01:54 PM
Originally posted by nellgavin
www.bookandquill.com/testcontrol.htm.
Dead link...

Jona
01-23-2003, 02:02 PM
Yea, the link doesn't work. I think it would make it easier if you at least posted the code :)

nellgavin
01-23-2003, 02:09 PM
The message board included the period at the end of the sentence in the link, and since I couldn't see the link as "active" while I was typing, I didn't catch it. The actual URL is www.bookandquill.com/testcontrol htm WITHOUT a period. (If you see this sort of thing again on the board, you can copy the link, paste it into the address field, then delete the text that is obviously screwing it up.)

Since you asked for the code, I'm pasting it below. It's a script you can download from this site.

Thanks!


<html>

<head><script LANGUAGE="JavaScript">

<!-- This script and many more are available online from -->
<!-- The JavaScript Source!! http://javascriptsource.com -->

<!-- Begin
function getCookie(name){
var cname = name + "=";
var dc = document.cookie;
if (dc.length > 0) {
begin = dc.indexOf(cname);
if (begin != -1) {
begin += cname.length;
end = dc.indexOf(";", begin);
if (end == -1) end = dc.length;
return unescape(dc.substring(begin, end));
}
}
return null;
}
function setCookie(name, value, expires) {
document.cookie = name + "=" + escape(value) +
((expires != null) ? "; expires=" + expires.toGMTString() : "")
+ "; path=/";
}
function setName() {
var expdate = new Date ();
expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000 * 365));
var prompt=i = document.Mail.name.value;
setCookie("name", i, expdate);
}
function getName() {
if(getCookie("name") != null) {
document.Mail.Name.value = getCookie("emailname");
}
}
function getInfo() {
var now= new Date();
document.Mail.Info.value = "Browser: " + navigator.userAgent;
document.Mail.Info.value += "Date:" + now;
}
function checkMultiple() {
if (getCookie("emailsent") == 'true') return true;
else return false;
}
function process() {
setCookie("emailsent", "true");
with (document.Mail) {
if (Subject.selectedIndex == 1) action = "mailto:antispammer@earthling.net?subject=TJS - Comment";
else if (Subject.selectedIndex == 2) action = "mailto:antispammer@earthling.net?subject=TJS - Question";
else if (Subject.selectedIndex == 3) action = "mailto:antispammer@earthling.net?subject=TJS - Suggestion";
else if (Subject.selectedIndex == 4) action = "mailto:antispammer@earthling.net?subject=TJS - Broken Link";
else action = "mailto:antispammer@earthling.net?subject=TJS - Other";
}
}
function formCheck() {
var passed = false;
with (document.Mail) {
if (Subject.selectedIndex == 0) {
alert("Please pick a subject.");
Subject.focus();
}
else if (Name.value == "") {
alert("Please inlcude your name.");
Name.focus();
}
else if (checkMultiple()) {
if (confirm("You just sent an e-mail from this form, are you sure you want to send another?")) {
process();
passed = true;
}
}
else {
process();
passed = true;
}
}
return passed;
}
// End -->
</script>

<title>JavaFILE</title>
<base target="leftframe">
</head>

<body BGCOLOR="#ffffff" link="#CC0033" vlink="#333399" alink="#FF0000" <!--content start-->

<p align="center"><img src="http://www.javafile.com/images/banner.GIF"
alt="banner.GIF (2826 bytes)"></p>

<table WIDTH="96%" BORDER="0" CELLSPACING="5" CELLPADDING="5">
<tr>
<td WIDTH="100%">Without question, this is the best javascript email form I have ever
seen. It sets cookies, checks form completion of all fields, and even knows if someone has
already sent a message with the form...JavaFILE gives this one 4936.7 stars! :)<font
FACE="ARIEL,HELVETICA" SIZE="-1"><p align="center"></font>Author: <a
href="http://javascriptsource.com">TheJavaScriptSource</a>&nbsp;&nbsp; <a
href="http://www.javafile.com/javascripts/forms/emailform5.zip">Download the Script</a><font
FACE="ARIEL,HELVETICA" SIZE="-1"></p>
<p align="center"><font FACE="Times" SIZE="3">Any thing you would like to tell us? Any
comments, suggestions, or questions? If you are using Internet Explorer or would rather
mail directly, then click <a HREF="mailto:antispammer@earthling.net?subject=TJS - Mail">here</a>.
<br>
</p>
<form NAME="Mail" ACTION="mailto:antispammer@earthling.net?subject=TJS - Form"
METHOD="POST" ENCTYPE="text/plain" onSubmit="return formCheck();">
<input type="hidden" name="Info" value><table BORDER="0" CELLPADDING="10" CELLSPACING="0">
<tr>
<td>Name: <input TYPE="text" NAME="Name" onChange="setName()" size="20"> </td>
<td ALIGN="RIGHT">Subject: <select NAME="Subject" size="1">
<option SELECT>Please Select A Subject</option>
<option>1. Comment</option>
<option>2. Question</option>
<option>3. Suggestion</option>
<option>4. Broken Link</option>
<option>5. None of the above</option>
</select> </td>
</tr>
<tr>
<td COLSPAN="2">Comments, questions, suggestions, broken links, anything!! : <br>
<br>
<textarea NAME="Comments, Suggestions" COLS="50" ROWS="6">
</textarea> </td>
</tr>
</table>
<div align="center"><center><table>
<tr>
<td align="center"><input TYPE="submit" VALUE="Send"> <script LANGUAGE="JavaScript">
<!-- Begin
getInfo();
getName();
// End -->
</script></font></font></td>
</tr>
</table>
</center></div>
</form>
</td>
</tr>
</table>
<!--content stop-->
</body>
</html>

nellgavin
01-23-2003, 02:11 PM
That time it didn't include the period BEFORE the HTM. (Sorry. typing too fast...)

Here is the link: www.bookandquill.com/testcontrol.htm

Jona
01-23-2003, 02:14 PM
It works on IE6. That is what I use. It says, "Name."

nellgavin
01-23-2003, 02:26 PM
I'm using IE5.50, and it still says Null. I guess this calls for an upgrade.

But now that I know it doesn't display correctly on IE5.50, is there any way to write the code to address this?

Thanks!

Jona
01-23-2003, 02:29 PM
Eh, there's definitely a way. I just have to think a while.. I have to go now, but if someone else doens't answer your question, I'll be back on tonight. Cya, sorry :(