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?

1

2 Answers 2

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') } 
Sign up to request clarification or add additional context in comments.

2 Comments

$('#side1textbox1').val($.cookies('lineside1')); I used this but its not working
document.frmartwork.side1textbox1.value = document.cookie['lineside1']; But its showing me "undefine"
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 :)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.