blue77
June 16th, 2005, 02:26 PM
Thanks for any help.. i'm going nuts...
in the 'head' of the html code I have...
<script language="JavaScript">
function answer() {
x = "";
x = document.ans.text.value;
if (x==correct answer){
window.location=x + '.htm';
}
else {
window.open(x + '.htm');
}
}
</script>
in the body I have...
<form name=ans onsubmit="answer()">
<input type=text name="text" size="25">
<div align="center"><center><p><input type="submit" value="Submit"></p>
</form>
What I want this to do... when I get the 'correct answer' I want the page to go to x.htm ... when I get the incorrect answer I want a popup of x.htm...
the 'logic' works (that is the java script knows the answer.. and compare the values... when it gets the wrong answer a popup DOES occur... and NOTHING happens when I get the right answer...
if i switch the pop up code and the 'redirect' code... I get a pop up just fine with the correct answer.. and nothing happens with the incorrect answer...
why am I not being redirected? what am I doing wrong?
does any of that make sense?
I'm guessing there is some issue with me calling the window.location function inside another function, being called by the 'onsubmit' function... i'm guessing you can't redirect that way...
any insight would be very helpful
in the 'head' of the html code I have...
<script language="JavaScript">
function answer() {
x = "";
x = document.ans.text.value;
if (x==correct answer){
window.location=x + '.htm';
}
else {
window.open(x + '.htm');
}
}
</script>
in the body I have...
<form name=ans onsubmit="answer()">
<input type=text name="text" size="25">
<div align="center"><center><p><input type="submit" value="Submit"></p>
</form>
What I want this to do... when I get the 'correct answer' I want the page to go to x.htm ... when I get the incorrect answer I want a popup of x.htm...
the 'logic' works (that is the java script knows the answer.. and compare the values... when it gets the wrong answer a popup DOES occur... and NOTHING happens when I get the right answer...
if i switch the pop up code and the 'redirect' code... I get a pop up just fine with the correct answer.. and nothing happens with the incorrect answer...
why am I not being redirected? what am I doing wrong?
does any of that make sense?
I'm guessing there is some issue with me calling the window.location function inside another function, being called by the 'onsubmit' function... i'm guessing you can't redirect that way...
any insight would be very helpful