|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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> |
|
#2
|
||||
|
||||
|
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"> |
![]() |
| Viewing: ASP Free Forums > Programming > HTML, JavaScript And CSS Help > HTML/JavaScript Cookie Help - Redirect to Another Page |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|