HTML, JavaScript And CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingHTML, JavaScript And CSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old November 4th, 2004, 01:04 PM
Boops2000 Boops2000 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 1 Boops2000 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
HTML/JavaScript Cookie Help - Redirect to Another Page

I am having a problem trying to get my program to work. The cookie is supposed to read what the user inputs and the redirect the input to another Page. The user's input is separated by semicolons for each field; however, once the user hits SUBMIT, all of the user input plus the word Submit comes back to the screen with the semicolons.

I have 4 fields and when the user clicks on SUBMIT, I need the input to read separately to another page. This is what I have so far:

<html>
<head>
<title>Purchaser Information</title>
<script language="javascript">
// Use the string methods below to split up the long text string
function CreateCookie()
{ var cookiestring = "";
for(i = 0; i < document.OurForm.elements.length;i++)
{
cookiestring=cookiestring + document.OurForm.elements[i].value + ";"
}
alert (cookiestring)
var todaysdate = new Date();
todaysdate.setFullYear(todaysdate.getFullYear() +1);//set to expire next year
alert(todaysdate)
document.cookie = "FNAME="+escape(cookiestring) + " ; expires= " + todaysdate.toGMTString();
}
function ReadString()
{
with (document.OurForm)
{
var count = 0;
var elementStr = '';
while (count < elements.length)
{
elementStr = elementStr + ";" + elements[count].value;
count = count + 1;
}//end while
alert(elementStr);
IndexOfEx(elementStr);
}//end with
}//end function
function IndexOfEx(textString)
{
var stringLength = textString.length
/*
indexOf finds the position of a character(s) within a string
and returns that characters position number in the string
*/
var colonPosition = textString.indexOf(';',1)
alert(colonPosition)
/*
substring() returns a new string based on the starting and
ending points specified
*/

var splitText = textString.substring(1,colonPosition)
alert(splitText)
}//end function
</script>
</head>
<body>
<form action="" method="post" name="OurForm">
<table width="600" border=0>
<tr>
<td colspan="2">Purchaser Information</td>
</tr>
<tr>
<td>First Name:</td>
<td><input type="text" name="FName" size="15"></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type="text" name="LName" size="18"></td>
</tr>
<td>Street Address:</td>
<td><input type="text" name="Address" size="40"></td>
</tr>
<tr>
<td>City:</td>
<td><input type="text" name="City" size="20"></td>
</tr>
<tr>
<td><input type="submit" value="Submit" onClick="ReadString()"> </td>
</tr>
</table>
</form>
<br>
<hr>
<a href="wk1hw.html">Main Page</a>
<hr>
</body>
</html>

Reply With Quote
  #2  
Old November 12th, 2004, 10:02 PM
dcarva's Avatar
dcarva dcarva is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 633 dcarva User rank is Lance Corporal (50 - 100 Reputation Level)dcarva User rank is Lance Corporal (50 - 100 Reputation Level)dcarva User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 9 h 18 m 20 sec
Reputation Power: 6
You have to fill in the action field in your form to the name of the page you want to post to. Change:

<form action="" method="post" name="OurForm">

To:

<form action="pagetogoto.asp" method="post" name="OurForm">

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingHTML, JavaScript And CSS Help > HTML/JavaScript Cookie Help - Redirect to Another Page


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway