HostNode.com :: HostSeeker's Talk
Home Register FAQ Members List Calendar Mark Forums Read
Go Back   HostNode.com :: HostSeeker's Talk > Design Talk > General Web Design > Cookie monster's and javascript
Reply
 
LinkBack Thread Tools Rate Thread Display Modes
(#1 (permalink))
Old
crowds crowds is offline
Registered User
crowds is on a distinguished road
 
Posts: 2
Join Date: May 2005
Question Cookie monster's and javascript - 05-01-2005, 03:03 AM

Hi,
I've spent the past week trying to find a way of setting my site up to use cookies. I don't have any knowledge of any server side script (and my web space I doubt supports it) so I have been looking into javascript as an option and have bought a .....ahem "fun web pages with javascript" book that has taken all thefun out of my life. The tutorials it provides on the set/get cookie function are very basic and simply don't seem to work for me.
Basically what I'm trying to is provide the following options to visitors to my site.
  1. A personalised greeting
  2. The option of email notifications to updates
  3. The ability to load a different set of pages (ones containing Flash sound players and ones not)
I should state that the pages without the Sound players will still contain Flash movies but small ones that are only used to load the actual sound player movies if required, An option I want to include for 56k users. So I don't need the flash elements to be dynamically loaded.
These all sound like fairly easy things to want to accomplish but it feels as if I am falling short of even the first hurdle. To begin with I have just tried the personalised greeting but with no joy. This is what I have got....
Code:
<head>
<script>
var cString = new String(document.cookie)
var cHead = "crowdsname="
var cstartpos = cString.indexOf(cHead)
if (cstartpos!= -1) {
var cName = cString.substring(cstarpos 
+ cHead.length)
document.write("Hi, " + cName + "!")
}
else
{document.write("please enter your name " 
+ "and click ok...")
document.write("<FORM NAME=form1>")
document.write("<INPUT TYPE=text NAME=cName " 
+ "SIZE=40>")
document.write("<INPUT TYPE=button" 
+ " VALUE='OK' onClick='storename()'>")
document.write("</FORM>")
} //EoIF/Else
function storename() {
var cDate = new date()
cDate.setTime(cDate.getTime() + 60*30*1000)
document.cookie = "crowdsname=" 
+ document.form1.cName.value 
+ ";expires=" + cDate.toGMTstring()
} // EoFn storename()
function delcookie(name)
{
document.cookie = name 
+"=; expires=Thu, 01-Jan-70 00:00:01GMT" +
 ";";
 alert("Settings deleted! ");
 } //EoFn delcookie(name)
</script>
</head>

<body>
<h3>Hi</h3>
<FORM NAME=delcook>
<INPUT TYPE=button NAME=delbutton 
VALUE="Remove Settings"
0nClick="delcookie(cHead)">
</form>
</body>
</html>
Can anyone help me out here?

Cheers
Crowds
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
(#2 (permalink))
Old
crowds crowds is offline
Registered User
crowds is on a distinguished road
 
Posts: 2
Join Date: May 2005
05-01-2005, 08:43 PM

Well it would seem i have got it sorted..... :)
However when i test the email function, the mail i recieve is as follows
Quote:
textfield=Jim&textfield=Jim.ven%40virgin.net&texta rea=looking+forward+to+this+working%0D%0A&Submit=S ubmit
I know there is a way to stop the space function appearing as & and the @ as %40 but im not sure how. this is what i have got
Code:
<form name="form1" id="form1" method="post" action="mailto:addmetomaillist@navigatingcrowds.co.uk">
            <input name="textfield" type="text" size="35" />
          </td>
          <td width="1"></td>
          </tr>
          <tr>
            <td height="39" align="center" valign="middle" class="style6">Email</td>
            <td colspan="3" valign="middle"><form name="form2" id="form2" method="post" action="mailto:addmetomaillist@navigatingcrowds.co.uk">
              <input name="textfield" type="text" size="35" />
            </td>
            <td></td>
          </tr>
          <tr>
            <td height="39" align="center" valign="middle" class="style6">Comments</td>
            <td colspan="3" rowspan="2" align="left" valign="top"><form name="form3" id="form3" method="post" action="mailto:addmetomaillist@navigatingcrowds.co.uk">
              <textarea name="textarea" cols="70" rows="10"></textarea>
          </td>
          <td></td>
          </tr>
          <tr>
            <td rowspan="2" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
            <td height="151"></td>
          </tr>
          <tr>
            <td width="59" height="58" align="center" valign="top"><form name="form4" id="form4" method="post" action="">
            
			  <input name="Submit" type="submit" class="style6" value="Submit" />
			   </form>
           </td>
            <td width="119" align="center" valign="top"><form name="form5" id="form5" method="post" action="">
              <input name="Reset" type="reset" class="style6" value="Reset" />
            </form></td>
            <td width="405" valign="top"><form name="form1" id="form1" method="post" action="">
              <input name="Next" type="button" class="style6" id="Next" onclick="MM_goToURL('parent','flash.htm');return document.MM_returnValue" value="Next" />
            </form></td>
Anyone help?
Cheers
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
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
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +2. The time now is 08:54 AM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0
vB.Sponsors
© 2003 - 2007 HostSeeker.com - All rights reserved