How do I on the page load post the cookies which are a username and a checked checkbox with JQuery?

3rd of September 2013 0

How do I on the page load post the cookies which are a username and a checked checkbox with JQuery?

I am not sure what function to lead with and unsure about the checkbox. I rather not rely on the button click to be the event that prompts the code to save the username. Any resources? Any suggestions. I have mulled over this and have created so many files so forgive me if this is not exactly my code.

So here is my code:





Remember Me

$ (‘#createCookie’).click(function(){

if($ (‘#remember’).is(‘:checked’))
{

var username = $ (‘#username’).val();

$ .cookie(“testUser”, username, {expires: 1});
$ .cookie(“chkBx”, true, {expires: 1});

}

if(!$ (‘#remember’).is(‘:checked’))
{
alert(‘test’); //condition is firing
$ .removeCookie(“chkBx”);
$ .removeCookie(“testUser”);

}

});


Best answer:

Answer by Jeff P
“I rather not rely on the button click to be the event that prompts the code to save the username.”

Why? You have to have the user click something to generate an event. I don’t understand what your problem is exactly.

Give your answer to this question below!

Filed under § jquery forms — Tagged with , , , , , , ,

Share it!

Was it good for you to?

Sponsors

Support for the site!

No sponsors at the moment.



Your opinion matters. Add it below.


Tip: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Recent comments

Categories



Copyright jqueryui.info since 2010. All rights reserved. Design and the Absolute Theme by Tommie Hansen.