[UNDEFINED ERROR] Please help :)
Hello there, this is my first post here, and I've just started javascript. My problem is that I get an undefined error on this page after i write the result and click on the "Click Here to vote" button.
Here's the page : http://85.204.99.55/top5/index.php?a=in&u=crimes
(Hope this won't be considered advertising)
My script source is :
Code:
<script type="text/javascript">
var a = Math.ceil(Math.random() * 20);
var b = Math.ceil(Math.random() * 20);
var c = a + b
function DrawBotBoot()
{
document.write("What is "+ a + " + " + b +"? ");
document.write("<input id='BotBootInput' type='text' maxlength='2' size='2'/>");
}
function ValidBotBoot(){
var d = document.getElementById('BotBootInput').value;
if (d == c){
window.location = "{$list_url}/index.php?a=in&u={$username}&sid={$sid}";
}
else
return false;
}
</script>
</head>
<body>
Are you human?<br />
<script type="text/javascript">DrawBotBoot()</script>
<input id="Button1" type="button" value="Click Here to Vote" onclick="alert(ValidBotBoot());"/>
The original code :
Code:
<script type="text/javascript">
var a = Math.ceil(Math.random() * 10);
var b = Math.ceil(Math.random() * 10);
var c = a + b
function DrawBotBoot()
{
document.write("What is "+ a + " + " + b +"? ");
document.write("<input id='BotBootInput' type='text' maxlength='2' size='2'/>");
}
function ValidBotBoot(){
var d = document.getElementById('BotBootInput').value;
if (d == c) return true;
return false;
}
</script>
</head>
<body>
Are you human?<br />
<script type="text/javascript">DrawBotBoot()</script>
<input id="Button1" type="button" value="Check" onclick="alert(ValidBotBoot());"/>
What am i missing? What did i do wrong?
Thank you in advance and have a nice day !