2

Thanks to anyone in advance that can help me in my issue.

I'm simply trying to save the value of a form input type="text" to a cookie when the input value has changed. Think I almost had it, but I cannot get it to work.

Here is what I have so far

-This is the javascript Set_cookie Function.

function Set_Cookie( name, value, expires, path, domain, secure )
{
var today = new Date();
today.setTime( today.getTime() );

if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}

-This is the Function that is suppose to save the input on change.

$(document).ready(function () {
    $('#inputText1').change(function () {
      Set_Cookie( 'inputText1', .val($(this)), '', '/', '', '' );
    });
});

-Input Field

input type="text" name="inputText1" id="inputText1"

Thanks again to anyone who can help.

2
  • 1
    If you're getting paid by the parenthesis, you should check out Lisp :P Commented Sep 27, 2011 at 0:54
  • I figured out the answer. Will share with all tomorrow after stackoverflow lets me lol. It blows away the competition. Commented Sep 27, 2011 at 2:33

1 Answer 1

1

Give this project a try

http://plugins.jquery.com/project/Cookie

And this tutorial will help you

http://www.komodomedia.com/blog/2008/07/using-jquery-to-save-form-details/

Sign up to request clarification or add additional context in comments.

3 Comments

junedkazi, Have already spent 2 days with the jquery cookie by komodomedia.com. It works if there is one input field, But I will have several which causes that script to stop working some how. The direction I was taking might seem to solve that problem by giving each input field its own unique script.?? I'm so very lost lol.
Is ur set_cookie function being called or triggered ?
The Set_Cookie function needs to be called. I was trying to call it when the input #id value was changed...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.