Click to See Complete Forum and Search --> : help with cookies and arrays


poohbear16
12-04-2003, 09:08 PM
Hi everyone. I hope that you all can help me as I'm stuck and really desperate now to get my program working.

These are my codes for Overhead Program.html:

<HTML>
<HEAD>
<TITLE> Overhead Program </TITLE>
<SCRIPT TYPE="text/javascript" SRC="cookie.js">
</SCRIPT>

<SCRIPT Language="JavaScript">

function xfer(form) {

// validations
if (form.songTitle.value == "") {
alert('Please enter a song title');
return false;
}

var expdate = new Date();
expdate.setTime(expdate.getTime() + 604800000);
set_cookie('pass', form.songTitle.value, expdate);
if (form.serviceSession.value == "firstService") {
top.location= 'FirstService.html';
} else if (form.serviceSession.value == "secondService") {
top.location = 'SecondService.html';
}
}

</SCRIPT>
</HEAD>

<BODY>
<B><U>Worship Songs Overhead Prgram</U></B><P>

<FORM NAME="overheadForm">

<U>Please choose the service session:</U><P>

<INPUT TYPE="radio" NAME="serviceSession" VALUE="firstService">
First Service<P>

<INPUT TYPE="radio" NAME="serviceSession" VALUE="secondService">
Second Service<P>

<U>Please type in the song titles</U><P>
Song Number 1:
<INPUT TYPE="text" NAME="songTitle" VALUE="" SIZE="50"><P>

<INPUT TYPE="button" NAME="nextPage" VALUE="Create" ONCLICK="xfer(this.form)" ONKEYUP="xfer(this.form)">
<INPUT TYPE="reset" NAME="reset" VALUE="Clear">

</FORM>
</BODY>
</HTML>

There are the codes for FirstService.html and SecondService.html (they're the same):

<HTML>
<HEAD>
<TITLE> Second Service </TITLE>
<SCRIPT TYPE="text/javascript" SRC="cookie.js">
</SCRIPT>
</HEAD>

<BODY>
<SCRIPT Language="JavaScript">
document.write('<A HREF="');
var firstname = get_cookie('pass');
document.write(firstname);
document.write('.html">');
var firstname = get_cookie('pass');
document.write(firstname);
document.write('</A>');
</SCRIPT>
</BODY>
</HTML>

However, I've been experiencing some problems like when I click the "Create" button, it will not go to the page that is created. how do i fix that? Also, how do I save the cookies if I need to save a few fields such as the form below:

<HTML>
<HEAD>
<TITLE> Overhead Program </TITLE>
</HEAD>

<BODY>
<B><U>Worship Songs Overhead Prgram</U></B><P>

<FORM>

<U>Please choose the service session:</U><P>
<INPUT TYPE="radio" NAME="service session" VALUE="first service">
First Service<P>
<INPUT TYPE="radio" NAME="service session" VALUE="second service">
Second Service<P>
<U>Please type in the song titles</U><P>
Song Number 1:
<INPUT TYPE="text" NAME="song title" SIZE="50"><P>
Song Number 2:
<INPUT TYPE="text" NAME="song title" SIZE="50"><P>
Song Number 3:
<INPUT TYPE="text" NAME="song title" SIZE="50"><P>
Song Number 4:
<INPUT TYPE="text" NAME="song title" SIZE="50"><P>
Song Number 5:
<INPUT TYPE="text" NAME="song title" SIZE="50"><P>
Song Number 6:
<INPUT TYPE="text" NAME="song title" SIZE="50"><P>
Song Number 7:
<INPUT TYPE="text" NAME="song title" SIZE="50"><P>
Song Number 8:
<INPUT TYPE="text" NAME="song title" SIZE="50"><P>
Song Number 9:
<INPUT TYPE="text" NAME="song title" SIZE="50"><P>
Song Number 10:
<INPUT TYPE="text" NAME="song title" SIZE="50"><P>

<INPUT TYPE="submit" VALUE="Create">
<INPUT TYPE="reset">

</FORM>
</BODY>
</HTML>

I really hope that you all will be able to help me soon. Coz I'm really desperate for help now. Thanks for you help.