View Full Version : Help!


Make.Me.Believe
01-31-2003, 03:19 AM
I followed your tutorial on how to make a quiz, and it all works except when I click on the submit button, it says error on page and doesn't do anything. Can you please help?

Alcy
01-31-2003, 04:24 AM
Could you post the code/tutorial you're using? ;)

Make.Me.Believe
01-31-2003, 11:17 AM
Okay I put this in the head:

<SCRIPT LANGUAGE="JavaScript">
<!--
function process()
{
var StrawberryGashes = 0;
var Underjoyed = 0;
var Lovesong = 0;
var MyCat = 0;
var Horrible = 0;
var f = document.f;
var i = 0;

for (i = 0; i < f.one.length; i++) if
(f.one[i].checked) value = f.one[i].value;
if (value == "1") { MyCat; }
if (value == "2") { Lovesong++; }
if (value == "3") { Underjoyed++; }
if (value == "4") { StrawberryGashes++; }
if (value == "5") { Horrible++; }

for (i = 0; i < f.two.length; i++) if
(f.two[i].checked) value = f.two[i].value;
if (value == "1") { Lovesong++; }
if (value == "2") { Underjoyed++; }
if (value == "3") { StrawberryGashes++; }
if (value == "4") { Horrible++; }
if (value == "5") { MyCat++; }

for (i = 0; i < f.three.length; i++) if
(f.three[i].checked) value = f.three[i].value;
if (value == "1") { MyCat++; }
if (value == "2") { Horrible++; }
if (value == "3") { StrawberryGashes++; }
if (value == "4") { Lovesong++; }
if (value == "5") { Underjoyed++; }


for (i = 0; i < f.four.length; i++) if
(f.four[i].checked) value = f.four[i].value;
if (value == "1") { Lovesong++; }
if (value == "2") { Horrible++; }
if (value == "3") { StrawberryGashes++; }
if (value == "4") { Underjoyed++; }
if (value == "5") { MyCat++; }

for (i = 0; i < f.five.length; i++) if
(f.five[i].checked) value = f.five[i].value;
if (value == "1") { Underjoyed++; }
if (value == "2") { StrawberryGashes++; }
if (value == "3") { Lovesong++; }
if (value == "4") { MyCat++; }
if (value == "5") { Horrible++; }

var out = "StrawberryGashes";
i = StrawberryGashes;
if (Underjoyed > i) { out = "Underjoyed"; i = Underjoyed; }
if (Lovesong > i) { out = "Lovesong"; i = Lovesong; }
if (MyCat > i) { out = "MyCat"; i = MyCat; }
if (Horrible > i) { out = "Horrible"; i = Horrible; }
location.href = out + ".html";
}
function err(msg, url, line)
{
location.href = "error.html";
}
//window.onerror = err;
// -->
</SCRIPT>


and in the body tag:

<form name="f">

<b>Which of these best describes you?</B><br /><br />
<input type="radio" name="one" value="1">Bright and Cheery.<br />
<input type="radio" name="one" value="2">Romantic.<br />
<input type="radio" name="one" value="3">Social outcast.<br />
<input type="radio" name="one" value="4">Sad, gloomy.<br />
<input type="radio" name="one" value="5">Troublemaker.<br />
<p>


<b>What style of music do you like?</B><br /><br />
<input type="radio" name="two" value="1">Punk.<br />
<input type="radio" name="two" value="2">Metal.<br />
<input type="radio" name="two" value="3">Rock.<br />
<input type="radio" name="two" value="4">Goth.<br />
<input type="radio" name="two" value="5">Anything.<br />
<p>
<b>Your love life is...</B><br /><br />
<input type="radio" name="three" value="1">Perfect.<br />
<input type="radio" name="three" value="2">Not quite where you want it to be, but not bad.<br />
<input type="radio" name="three" value="3">Hopeless.<br />
<input type="radio" name="three" value="4">Complicated.<br />
<input type="radio" name="three" value="5">Nonexistant.<br />
<p>
<b>Your favorite color is...</B><br /><br />
<input type="radio" name="four" value="1">Blue<br />
<input type="radio" name="four" value="2">Black<br />
<input type="radio" name="four" value="3">Red<br />
<input type="radio" name="four" value="4">Green<br />
<input type="radio" name="four" value="5">Gold<br />
<p>
<b>Your biggest fear is...</B><br /><br />
<input type="radio" name="five" value="1">Animal-related.<br />
<input type="radio" name="five" value="2">Death.<br />
<input type="radio" name="five" value="3">Rejection.<br />
<input type="radio" name="five" value="4">Being abducted by aliens.<br />
<input type="radio" name="five" value="5">I'm not afraid of anything!<p>

<INPUT TYPE="button" VALUE="What am I?" onClick="process();">

<p>Learn how to make your own at
<a href="http://www.``````````````" target="_blank">``````````````</a>



The tutorial I used was this one: http://www.``````````````/quizhowto.shtml

Thanks!

starlet
01-31-2003, 05:20 PM
That code works fine for me, i tested it out and when i click submit it trys to go to the pages its meant to (Lovesong.html Horrible.html StrawberryGashes.html Underjoyed.html MyCat.html)
Did you create those pages and have them uploaded in the same directory? If its still not working could you post the URL for it...it could be its something else on your page thats stopping it from working because the codeing itself is fine :)

Make.Me.Believe
01-31-2003, 08:12 PM
I did create all of those pages, it might be that it's a Geocities website maybe? The URL is http://www.geocities.com/sk8ergirl272/quiz.html

Thanks!

epolady
01-31-2003, 08:16 PM
Your body tag's not closed, whether or not this is the problem is beyond me

<body bgcolor="#FFFFFF" link="#0000FF" vlink="#FF0000" text="#000000">

Make.Me.Believe
01-31-2003, 08:38 PM
That didn't help...

starlet
01-31-2003, 11:39 PM
At the end you have an extra starting <html> and <body> tag...this is the code i tested and works fine, so just copy and paste and hopefully it'll fix it...

<html>
<head>
<title>quiz</title>
<SCRIPT LANGUAGE="JavaScript">
<!--
function process()
{
var StrawberryGashes = 0;
var Underjoyed = 0;
var Lovesong = 0;
var MyCat = 0;
var Horrible = 0;
var f = document.f;
var i = 0;

for (i = 0; i < f.one.length; i++) if
(f.one[i].checked) value = f.one[i].value;
if (value == "1") { MyCat; }
if (value == "2") { Lovesong++; }
if (value == "3") { Underjoyed++; }
if (value == "4") { StrawberryGashes++; }
if (value == "5") { Horrible++; }

for (i = 0; i < f.two.length; i++) if
(f.two[i].checked) value = f.two[i].value;
if (value == "1") { Lovesong++; }
if (value == "2") { Underjoyed++; }
if (value == "3") { StrawberryGashes++; }
if (value == "4") { Horrible++; }
if (value == "5") { MyCat++; }

for (i = 0; i < f.three.length; i++) if
(f.three[i].checked) value = f.three[i].value;
if (value == "1") { MyCat++; }
if (value == "2") { Horrible++; }
if (value == "3") { StrawberryGashes++; }
if (value == "4") { Lovesong++; }
if (value == "5") { Underjoyed++; }


for (i = 0; i < f.four.length; i++) if
(f.four[i].checked) value = f.four[i].value;
if (value == "1") { Lovesong++; }
if (value == "2") { Horrible++; }
if (value == "3") { StrawberryGashes++; }
if (value == "4") { Underjoyed++; }
if (value == "5") { MyCat++; }

for (i = 0; i < f.five.length; i++) if
(f.five[i].checked) value = f.five[i].value;
if (value == "1") { Underjoyed++; }
if (value == "2") { StrawberryGashes++; }
if (value == "3") { Lovesong++; }
if (value == "4") { MyCat++; }
if (value == "5") { Horrible++; }

var out = "StrawberryGashes";
i = StrawberryGashes;
if (Underjoyed > i) { out = "Underjoyed"; i = Underjoyed; }
if (Lovesong > i) { out = "Lovesong"; i = Lovesong; }
if (MyCat > i) { out = "MyCat"; i = MyCat; }
if (Horrible > i) { out = "Horrible"; i = Horrible; }
location.href = out + ".html";
}
function err(msg, url, line)
{
location.href = "error.html";
}
//window.onerror = err;
// -->
</SCRIPT>
</head>
<body bgcolor="#FF0000" link="#0000FF" vlink="#FF0000" text="#000000">

<form name="f">

<b>Which of these best describes you?</B><br /><br />
<input type="radio" name="one" value="1">Bright and Cheery.<br />
<input type="radio" name="one" value="2">Romantic.<br />
<input type="radio" name="one" value="3">Social outcast.<br />
<input type="radio" name="one" value="4">Sad, gloomy.<br />
<input type="radio" name="one" value="5">Troublemaker.<br />
<p>


<b>What style of music do you like?</B><br /><br />
<input type="radio" name="two" value="1">Punk.<br />
<input type="radio" name="two" value="2">Metal.<br />
<input type="radio" name="two" value="3">Rock.<br />
<input type="radio" name="two" value="4">Goth.<br />
<input type="radio" name="two" value="5">Anything.<br />
<p>
<b>Your love life is...</B><br /><br />
<input type="radio" name="three" value="1">Perfect.<br />
<input type="radio" name="three" value="2">Not quite where you want it to be, but not bad.<br />
<input type="radio" name="three" value="3">Hopeless.<br />
<input type="radio" name="three" value="4">Complicated.<br />
<input type="radio" name="three" value="5">Nonexistant.<br />
<p>
<b>Your favorite color is...</B><br /><br />
<input type="radio" name="four" value="1">Blue<br />
<input type="radio" name="four" value="2">Black<br />
<input type="radio" name="four" value="3">Red<br />
<input type="radio" name="four" value="4">Green<br />
<input type="radio" name="four" value="5">Gold<br />
<p>
<b>Your biggest fear is...</B><br /><br />
<input type="radio" name="five" value="1">Animal-related.<br />
<input type="radio" name="five" value="2">Death.<br />
<input type="radio" name="five" value="3">Rejection.<br />
<input type="radio" name="five" value="4">Being abducted by aliens.<br />
<input type="radio" name="five" value="5">I'm not afraid of anything!<p>

<INPUT TYPE="button" VALUE="What am I?" onClick="process();">

<p>Learn how to make your own at
<a href="http://www.``````````````" target="_blank">``````````````</a>
</BODY>
</HTML>

Make.Me.Believe
01-31-2003, 11:52 PM
It works! Thanks so much!