0

On textbox onchange property i have called one javascript function In that I have written this,

function testbox1()
{

var strline1side1 = document.frmartwork.side1textbox1.value;
document.cookie="lineside1="+strline1side1.replace(" "," ")+";path=/;";

}

I want to assign this "lineside1" cookie value when page is reload

window.onload=function()
{

document.frmartwork.side1textbox1.value = "here i want that cookie "


}

How can i do this?

Samich
  • 29,157
  • 6
  • 68
  • 77
user818671
  • 389
  • 4
  • 8
  • 21
  • possible duplicate of [Read Cookies using Javascript](http://stackoverflow.com/questions/2657906/read-cookies-using-javascript) – Quentin Sep 30 '11 at 07:26

2 Answers2

2

You should use jquery cookie plugin

function testbox1()
{

var strline1side1 = document.frmartwork.side1textbox1.value;
$.cookie('lineside1',strline1side1.replace(" "," "));

}

window.onload=function()
{

document.frmartwork.side1textbox1.value = $.cookie('lineside1')


}
Nicola Peluchetti
  • 76,206
  • 31
  • 145
  • 192
0

If you are using jQuery - use jQuery.cookies plugin. It's quiet simple to use.

$.cookies('cookiename') // get value
$.cookies('cookiename', value) // set value

function testbox1()
{
    $.cookies('lineside1', $('#side1textbox1').val());
}

$(document).ready(function(){
    $('#side1textbox1').val($.cookies('lineside1'));
});

Also, if you start using jQuery - use it :)

Samich
  • 29,157
  • 6
  • 68
  • 77