im kind of new to JQuery... I would like to save the value of a form field as a cookie once i click on the button but it does not seem to work. The code i'm using is the following
$(function() {
$("#myButtonId").click( function() {
var myVar = $('#myTextField').val();
$.cookie("cookie", myVar);
//i try the next line just to control if the cookie was saved
alert($.cookie("cookie"));
});
});
When the alert pops up it just shows "undefined" as an output (meaning the cookie was not set), if i set the cookie outside the click function it works fine.
EDIT: if i may be of help... the button is the submit button to login to my web application, i want to save the login data so next time i open the application i dont have to rewrite the login data