[RESOLVED] [JavaScript] Value Enter Issue

one of my friend mailed me about this help and i could not help him. please save this as .htm and pls tell what value should be entered in the Textbox to get the Alert Correct

<html>
<head>
<title>Solve It</title>
</head>
<body>

<center><h1>Can You?</h1></center>

<script language="JavaScript">

function chkcode(pass)
{
var temp = 0;
var alpha = "abcdefghijklmnopqrstuvwxyz";
var char1;
for (i = 0; i < pass.length; i++)
{
char1 = pass.charAt(i);
buf = (alpha.indexOf(char1));
buf += 1;
temp *= 26;
temp += buf;
}

if(temp == 913216169672)
{
alert("correct");
document.write("<h1><center>Congratulations");
load(pass);
}
else
alert("try again");
}

function load(pass)
{
document.write ("<a href =" + pass + ".html><h4>Next</h4></a>");
}
</script>
<br><br><br><br><br><br><br><br><br><br>

<form method=post name="f1"
onSubmit="chkcode(document.f1.name.value)">
<b><center>Enter Access Code</b><input type="text" name="name" size="25">
<input type="submit" value= "submit" ></center>

</form>
</body>
</html>
[1454 byte] By [chunks] at [2007-11-20 11:17:10]
# 1 Re: [RESOLVED] [JavaScript] Value Enter Issue
The trick here is to calculate the string backwards, trying to remove a value between 1 and 26 and dividing by 26 and see if you still have a whole number. If you have a whole number, that means it's a possible match for the actual answer. Once you reach 0, you've found a string that will calculate to your answer.

Here's how you do that in JavaScript:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Solver</title>
<script type="text/javascript">
function step(value, string) {
if (value == 0) {
var li = document.createElement("li");
li.appendChild(document.createTextNode(string));

var solutions = document.getElementById("solutions");
solutions.appendChild(li);

return;
}

for (var i = 1; i <= 26; i++) {
var result = (value - i) / 26;
if (Math.round(result) == result) {
step(result, String.fromCharCode(96 + i) + (string || ""));
}
}
}

window.onload = function () {
step(913216169672);
};
</script>
</head>
<body>
<h1>Solver</h1>
<p>Possible solutions:</p>
<ul id="solutions"></ul>
</body>
</html>
andreasblixt at 2007-11-8 0:43:23 >
# 2 Re: [RESOLVED] [JavaScript] Value Enter Issue
Thanks bro
chunks at 2007-11-8 0:44:24 >