Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Setting A Cookie To Remember Selection


  • Please log in to reply

#1
The G

The G

    Member

  • Member
  • PipPipPip
  • 136 posts
This is probably rather easy to solve, but I'm no good at cookie coding.

What I'm trying to do is get a drop down menu (where they select an image) remember people's selection if they re-fresh the page or whatever, this is what I have

<script language="javascript">
<!--

function getCookieExpireDate(noDays){
  var today = new Date()
  var expr = new Date(today.getTime()+noDays*24*60*60*1000)
  return  expr.toGMTString()
  }
function makeCookie(name, data, noDays){
  var cookieStr = name + "="+ data
  if (makeCookie.arguments.length > 2){
	cookieStr += "; expires=" + getCookieExpireDate(noDays)
	}
  document.cookie = cookieStr
  }

/*Combo Box Image Selector:
By JavaScript Kit (www.javascriptkit.com)
Over 200+ free JavaScript here!
*/

function showimage()
{
if (!document.images)
return
document.images.pictures.src=
document.mygallery.picture.options[document.mygallery.picture.selectedIndex].value
}

//-->
</script>

<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100%"><form name="mygallery"><p><select
name="picture" size="1" onChange="showimage()">
<option selected value="picture1">pic1</option>
<option value="picture2">pic 2</option>
<option value="picture3">pic3</option>
</select></p>
</form>
</td>
</tr>
<tr>
<td width="100%"><p align="center"><img src="pic" name="pictures" width="99"
height="100"></td>
</tr>
</table>

Any help would be fantastic.
  • 0

Advertisements







Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP