Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8794657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:16:53+00:00 2026-06-13T23:16:53+00:00

($.cookie(‘cIDlist) is an array that looks like: 2, 0, 1, 2, 4 . The

  • 0

($.cookie('cIDlist") is an array that looks like: 2, 0, 1, 2, 4.

The function works as intented but somehow the function imageToSlotNr() uses both the integer numbers and the commas as values. How do I get it to ignore the separating or commas or just remove the commas? And why is this even happening?

$("#vkorzinu").click(function(){
    SLOTNUM = 1;
    $.each($.cookie('cIDlist'), function(){
        imageToSlotNr(this);
        SLOTNUM++;
    });
});

function imageToSlotNr(idnum){
  if(SLOTNUM<9){
  $("#slot"+SLOTNUM).css({"backgroundImage":"url('http://localhost/musli/"+idnum+"ingrid.png'    )","background-size":"70px"});
  } else {
       alert("full");
}};
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T23:16:54+00:00Added an answer on June 13, 2026 at 11:16 pm

    Your $.each is iterating over the characters in a string.

    You need to convert to an Array before iterating. Parsing it as JSON can be useful here.

    var arr = $.parseJSON("[" + $.cookie('cIDlist') + "]");
    
    $.each(arr, function(){
        imageToSlotNr(this);
        SLOTNUM++;
    });
    

    If you want the numbers as strings, you can use .split() instead of parsing it as JSON data.

    var arr = $.cookie('cIDlist').split(/\s*,\s*/);
    
    $.each(arr, function(){
        imageToSlotNr(this);
        SLOTNUM++;
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

document.cookie is like a string, but it is not a string. To quote the
I have a cookie handler / utility class that works quite well for me.
I am setting a cookie, but having some issue. Currently the cookie format is
With the new Cookie regulation, like all of us I need to display a
I am using Jquery Cookie but am having difficulty setting and retrieving the info.
i create a cookie and use it like this.inside a document.ready document.cookie = $('#rdb1').attr(id);
If i set a cookie in PHP with the setcookie() function, can i access
cookie[person][name], cookie[person][id], cookie[person][age] How to make the cookie like above?
I am setting a cookie. Something like: $_COOKIE['test'] = SHA1('124'.'mysalt'); Now 124 is my
I have a cookie which is generated from a servlet and that I would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.