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 8588531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:49:31+00:00 2026-06-11T22:49:31+00:00

I have a script with which I can save plain text using click event

  • 0

I have a script with which I can save plain text using click event and cookie plugin:

$('.fields').click(function(e) {
    var text = $('#inputBox').val();
    $.cookie('demoCookie',text,{expires: 7, path: '/' });
    $(".jq-text").text(text);
    .....

The cookie is called like this:

var cookie = $.cookie('demoCookie');    
if (cookie){
    $('.jq-text').text(cookie).show();

So now I want to append a list with a link and of course save it with a cookie:

$('.fields').click(function(e) {
    var text = $('#inputBox').val();
    $.cookie('demoCookie',text,{expires: 7, path: '/' });
    $(".jq-text").append('<li><a href="' + text + '">' + text + '</a></li>');

I cant get it to work: JsFiddle

The text is saved but not the list and a href.

ps The problem might be that the dynamically created list is gone the second one refreshes the page..

  • 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-11T22:49:32+00:00Added an answer on June 11, 2026 at 10:49 pm

    The problem is that you are overwriting the value every time you save one. That’s why you can only read back the last one you added. You’d need to read what is already there, append to it, then save it again.

    It will probably be a good idea to create an Array to save your values and make it a JSON string when you write it to the cookie. Then when you’re reading it back, you can parse the JSON into an array again (parseJSON jQuery command) and add your new value.

    Here’s an edited fiddle showing what I mean: http://jsfiddle.net/dx6CN/3/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script which can overwrite values in a configuration file using options,
I have a script which I can run perfectly if I call it manually
I have script which allows to display Bing search results. I can call for
I have a Python3 script that can take optional command line parameters which the
I have a script which similar to this: foo.php class Foo { function Foo()
I have following script which processes emails and save them to csv file. there
I have a script which allows to save and delete cookies: JsFiddle Type something
I have a python script which I have made dropable using a registry-key, but
Ok I have seen many posts on this script. Which can be found..... http://www.white-hat-web-design.co.uk/blog/resizing-images-with-php/
i have a script which is for virtual keyboard, i am facing some problem

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.