/    Sign up×
Community /Pin to ProfileBookmark

How click submit button auto in place of onclick()

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>
[/code]

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’)”>
[/code]

or need another program or set timeinterval in createcookie() and readcookie() function…is it?

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@JMRKEROct 16.2012 — AFAIK, you cannot cause JS to execute an onclick event. User should be doing this when they want.

I would not like my computer to override my choices with an automatic onclick event that I did not instigate.

Also, to save the same information over and over to a cookie every few minutes seems like a waste of computation time.

What is is that is so important to monitor?
Copy linkTweet thisAlerts:
@sajib0189authorOct 17.2012 — cause this is my experimental code ...after success of its saving and recalling data auto in cookie, i'll apply it in my factory production floor.

where inputs coming from PLC (Programmable logic control) and store data in one network server, from server to PC in IE its showing the values which is changing after every 2 seconds. i want to modify this page to save some specific value and call it after few sec where existing value already change and finally compare both values. i cant change the server program that why i need to change the page where it showing in IE.

any other way to save single value for few seconds and recall and again save/recall continuously?????? any help will be highly appreciable.....

my target is like it:

input=3 show=3

input=4 show=4 (compare max existing show 3 and new input 4 )

input=6 show=6 (compare max existing show 4 and new input 6 )

input=3 show=6 (compare max existing show 6 and new input 3 )

input=2 show=6 (compare max existing show 6 and new input 2 )

i want to save show data for few sec in cookie and recall it after existing value change....

thanks
Copy linkTweet thisAlerts:
@parkerfrank32Oct 17.2012 — Try this.

if(PushMsg()) document.forms[0].submit();
Copy linkTweet thisAlerts:
@sajib0189authorOct 17.2012 — i cant understand where i need to add it , in main program after each function end or in onclick selection.

pusgmsg() means what..actually i m not so expert ...
×

Success!

Help @sajib0189 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...