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

The Archive Base Latest Questions

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

bit of a jQuery noob but learning quickly thanks to StackOverflow. Can anyone give

  • 0

bit of a jQuery noob but learning quickly thanks to StackOverflow.

Can anyone give me code that will get data from a form and write it out to a cookie (not a session cookie) using jQuery. I am loading the jQuery cookie plugin from here:

https://github.com/carhartl/jquery-cookie

I’d also like to know if I have to load my code when the DOM is ready as previously with php I loaded cookies first thing. Can’t get my head round the DOM yet.

Thanks in advance.

OK here is the current code, thanks to reply below. I can’t get the cookie working though but the alert works fine when uncommented:

           <form id="myform">
              <fieldset>
                <h3>Search</h3>
                <p>
                  <label>Your search *</label>
                  <input type="text" id="mysearch" pattern="[a-zA-Z ]{5,}" maxlength="30" />
                </p>
                <fieldset>
                    <input type="range" id="range" min="1" max="30" value="10"  />
                    <input type="range" id="range2" min="30" max="9000" value="2000"  />
                 </fieldset>

                <button id="subbtn" type="submit">Submit form</button>
                <button type="reset">Reset</button>
              </fieldset>
            </form>


        $(function() {
        // initialize tooltip
        $(".imgwrap").tooltip({ 
        //$(".tooltip").tooltip({ effect: 'slide'});
           // tweak the position
           offset: [10, 2],

           // use the "slide" effect
           effect: 'slide'

        // add dynamic plugin with optional configuration for bottom edge
        }).dynamic({ bottom: { direction: 'down', bounce: true } });
        });

        //this one loads the form validator
        $("#myform").validator();

        //this one for the slider
        $(":range").rangeinput();

    $("#subbtn").on("click", function () {
    // alert("Cookie!");
        $.cookie('Searchitem', $("#mysearch").val(), { expires: 365 });
    });

Any ideas why my cookie is not setting? Browser is set to accept and I’m debugging with Firebug.

  • 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:47:54+00:00Added an answer on June 13, 2026 at 11:47 pm

    A persistent cookie is the same as a session cookie except it has an expiration date so it hangs around.

    This will write the value of the text input to a cookie that expires in 365 days:

        <input id="txt" type="text" value="foo" />
        <input id="btn" type="button" value="write cookie" />
    

    …

        $(document).ready(function () {
            $("#btn").on("click", function () {
                $.cookie('myCookie', $("#txt").val(), { expires: 365 });
            });
        });
    

    EDIT

    New code per updated question:

        $(function () {
    
            // initialize tooltip
            $(".imgwrap").tooltip({
                //$(".tooltip").tooltip({ effect: 'slide'});
                // tweak the position
                offset: [10, 2],
    
                // use the "slide" effect
                effect: 'slide'
    
                // add dynamic plugin with optional configuration for bottom edge
            }).dynamic({ bottom: { direction: 'down', bounce: true} });
    
            //this one loads the form validator
            $("#myform").validator();
    
            //this one for the slider
            $(":range").rangeinput();
    
            $("#subbtn").on("click", function () {
                // alert("Cookie!");
                $.cookie('Searchitem', $("#mysearch").val(), { expires: 365 });
            });
    
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a bit of a nOOb with jQuery but I know it can do
I'm a noob at json (know a bit of jquery)....and trying to get a
I'm trying to add a bit of jQuery code to all elements that have
I have this bit jQuery with HTML. Unfortunately its not working correctly. Can anyone
I am using this bit of jQuery code to get href of the link:
I'm using a bit of JQuery code to create placeholder values for browsers that
I am looking for a simple bit of jquery that will load images in
I have this bit of jQuery script that can be found here: http://jsfiddle.net/RUqNN/45/ When
What is the syntax to get this bit of jQuery to call when say,
I have a simle bit of jQuery code which hides a group of gallery

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.