Awena
Awena

Reputation: 1022

handling a cookie ( delete)

Im using chkArray.push($(this).val()); and document.cookie = 'ids='+chkArray; within a $('input[type=checkbox]:checked').each(function() to store checkboxes values.

Then with a simple onclick function (AJAX) fecth products info from db and display in a div.

So far it is working well, but :

thanks

Upvotes: 0

Views: 56

Answers (2)

Kotoradeluxe
Kotoradeluxe

Reputation: 21

Since you are already using jQuery, you can have a look at this plugin : jquery-cookie to help you with your problems.

Upvotes: 1

Haneev
Haneev

Reputation: 775

  • You can reset all cookies with document.cookie = ''. You can empty an array with chkArray = []
  • The cookie format is a key-value pair. For example, document.cookie = 'ids=hi; name=Han'. Now you have a cookie with two key-value pairs. ids and name.
  • You have to loop yourself to get values out the array. You can use array.join(','). You get a comma seperated list of ids

Upvotes: 1

Related Questions