Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 28th, 2011, 07:29 AM
Authorized User
 
Join Date: Feb 2011
Posts: 21
Thanks: 9
Thanked 0 Times in 0 Posts
Default truble with the cookie part, can anyone help?

Hi,

I manage to swap images by clicking on thumbnails.

What I dont manage, is to save the last selected image into a cookie.

Can anyone help me solve this? Would appreciate it!


HTML Code:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="jquery-1.6.4.js"></script>
<script type="text/javascript" src="jquery.cookie.js"></script
<script>
$(document).ready(function () {
   var checkCookie = $.cookie("panel");
   if (checkCookie != "") {
     $('#panel a:eq('+checkCookie+')').next().show();
   }   $('.panel-version a').click(function(e){
       var src = $(this).attr('href');
       $.cookie("panel-version", href);
   }); });
</script>
</head>
<body>
<script type="text/javascript"> 
jQuery(function(){	
		$('#panel a').click(function(e){
		var src = $(this).attr('href');
		$('.panel-version').attr('src',src);
		e.preventDefault();
		});	});
</script>
</div>		  
<div class="panel" id="panel">
<img src="img1.png" alt="" class="panel-version" />
<h3>Panel colors</h3>
<ul id="nav">
<a href="img1.png"><img src="img1.png" class="panel1" alt="HTML tutorial" width="32" height="32" /></a>
<a href="img2.png"><img src="img2.png" class="panel2" alt="HTML tutorial" width="32" height="32" /></a>
<a href="img3.png"><img src="img3.png" class="panel3" alt="HTML tutorial" width="32" height="32" /></a>
</ul>
</div>
<img src="img1.png" alt="" class="panel-version" />
<img src="img1.png" alt="" class="panel-version" />
</body>
</html>
 
Old September 29th, 2011, 04:14 AM
Authorized User
 
Join Date: Feb 2011
Posts: 21
Thanks: 9
Thanked 0 Times in 0 Posts
Default

I found a solution, clap clap.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding a web part to a SharePoint web part page sawanjc BOOK: Beginning SharePoint 2007: Building Team Solutions with MOSS 2007 ISBN: 978-0-470-12449-9 0 July 15th, 2011 04:37 PM
Cookie question janilane BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 7 November 5th, 2009 04:18 AM
Cookie prv299 ASP.NET 2.0 Professional 3 May 29th, 2008 11:26 AM
Cookie Questions Ron Howerton ASP.NET 2.0 Professional 15 November 13th, 2007 10:32 AM
login cookie help daddycool2k ASP.NET 1.0 and 1.1 Basics 0 November 16th, 2003 03:17 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.