i made a java script program that save values from text field to cookies and recall it in another text field with recall button.
but i m trying to make auto means without any submit button its save and recall after few seconds.
or make the button to click auto…
is it possible?
my code are here:
[code]
<html>
<head>
<script type = “text/javascript”>
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime() + (10000));
var expires = “; expires = “+ date.toGMTString();
}
else{var expires = “”}
document.cookie = name + “=” + value + expires + “; path=/”; // available throughout the directory
}
function readCookie(name) {
var nameEQ = name + “=”;
var ca = document.cookie.split(‘;’);
for(var i=0;i < ca.length;i++) {
var cb = ca[i];
while (cb.charAt(0)==’ ‘) {cb = cb.substring(1,cb.length)}
if (cb.indexOf(nameEQ) == 0) {
retval = cb.substring(nameEQ.length,cb.length);
document.getElementById(“txtInput1″).value = retval;
return retval;
}
}
return null; // no display if cookie not found
}
function eraseCookie(name) {
createCookie(name,””,-1); // set cookie to expire on previous day
}
</script>
<body>
<input type = “text” id = “txtInput” value=”12″>
<input type = “text” id = “txtInput1”>
<input type = “button” value = “Save” onclick=”createCookie(‘mycookie’,document.getElementById(‘txtInput’).value, 10)”>
<input type = “button” value = “Recall” onclick = “readCookie(‘mycookie’)”>
</body>
</html>
i think i need to make change here:
[code]
<input type = “button” value = “Save” onclick=”createCookie(‘mycookie’,document.getElementById(‘txtInput’).value, 10)”>
<input type = “button” value = “Recall” onclick = “readCookie(‘mycookie’)”>
or need another program or set timeinterval in createcookie() and readcookie() function…is it?