Hi VejOut,
just change the type of the submit input to button. So instead of type="submit" change it to type="button" and it will redirect to the desired url.
Swisse
I'm having major trouble getting a new URL to open in the same window if the form data is correct (it's a quiz). I've tried...
window.location
window.location.href
location.href
self.location
and many others and NOTHING opens the URL at all. This form must work offline (ie, no internet connection) which is why I'm trying to use JavaScript. I've been trying it in FF3 and IE8 and nothing works in either browser. I know it's getting in there as I get the final alert I set up but the URL is never opened. It MUST be in the same window so a user can hit their back button to back to it if needed.
The form is:
<form method="get" action="" title="Quiz One" id="quizOne">
<fieldset><legend>This is question one, the answer should be "City"</legend>
<ol>
<li><input type="radio" id="q1a1" name="question01" /> <label for="q1a1">Name</label></li>
<li><input type="radio" id="q1a2" name="question01" /> <label for="q1a2">Address</label></li>
<li><input type="radio" id="q1a3" name="question01" /> <label for="q1a3">City</label></li>
<li><input type="radio" id="q1a4" name="question01" /> <label for="q1a4">Country</label></li>
</ol>
</fieldset>
<fieldset><legend>This is question two, the answer should be "Name"</legend>
<ol>
<li><input type="radio" id="q2a1" name="question02" /> <label for="q2a1">Name</label></li>
<li><input type="radio" id="q2a2" name="question02" /> <label for="q2a2">Address</label></li>
<li><input type="radio" id="q2a3" name="question02" /> <label for="q2a3">City</label></li>
<li><input type="radio" id="q2a4" name="question02" /> <label for="q2a4">Country</label></li>
</ol>
</fieldset>
<input type="submit" title="Submit Quiz" name="Submit Quiz" onclick="examResults(this.form);" />
</form>
and the JavaScript file (external) is:
// JavaScript Document
function redirectThis(num) {
//window.open("http://www.apple.com");
alert(num);
if(num==2) {
alert("Got 'em all!");
window.location="http://www.google.com";
//window.location.href="http://www.google.com";
//location.href="http://www.google.com";
//self.location="http://www.google.com";
}
}
function examResults(form) {
var totalRight = 0;
if(form.question01[2].checked) {
alert("first one right");
totalRight++;
}
if(form.question02[0].checked) {
alert("second one right");
totalRight++;
}
alert("totalRight = " + totalRight);
redirectThis(totalRight);
}

Chowhound
Comic Vine
GameFAQs
GameSpot
Giant Bomb
TechRepublic