/    Sign up×
Community /Pin to ProfileBookmark

On refresh save form values

I am trying to do a check on a random number that was generated and the number the user enters. If they don’t match I want the page to reload and generate a new random number, but keep the information the user typed in the other fields. It works in firefox, but not in IE.

Here is the function that does the checking.

[code=php]
function check()
{
//random number that is stored
var ran1 = document.form1.hiddenfield.value;
//number the user enters to match hiddenfield
var ran2 = document.form1.mrRandom.value;
//field that needs to be kept when page is reloaded
var ran3 = document.form1.box.value;
if(ran1 != ran2)
{
message = “Numbers don’t match”;
alert(message);
location.reload();
document.form1.mrRandom.value = “”;
document.form1.box.value = ran3;
return false;
}
return true;
}
[/code]

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @skywalker2208 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 4.29,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...