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 i开发者_高级运维t, 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.
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/
精彩评论