Hello Everyone

Im a begginer in HTML and I have to make a Quiz page.
and when the visitor finish from choosing the questions and clicking on " finish", the results & the grades will appear in the " Result's page " .

I want something very simple. And I did that :
But It dosent work :(

===

<html>
<head>
<title>Main Page</title>
</head>
<link rel="stylesheet" type="text/css" href="bgm.css" />

<SCRIPT type=text/javascript>

function ss(browser)
  {
  document.getElementById("answerss").value=browser;
  }

function ww(browser)
  {
  document.getElementById("answerww").value=browser;
  }


<SCRIPT type=text/javascript>

function ss(browser)
  {
  document.getElementById("answerss").value=browser;
  }

function ww(browser)
  {
  document.getElementById("answerww").value=browser;
  }
  </script>
  </script>

<body>
<form>
<p align="center" style="padding:25px;border:1px solid green;">
<a href="http://localhost/db/contact.php">Welcome..... Please Contact to us</a></p>
<div align="center">
<table border="5" width="57%" id="table1" style="border-width: 0px">
<tr>
<td width="82%" style="border-style: none; border-width: medium">

<p align="center"><b><font size="3" color="#0000FF"><marquee behavior="slide" direction="right" loop="3">Internet Programming</marquee>Welcome to this simple test , I hope you will enjoy with it </font></b></td>

<td width="48%" style="border-style: none; border-width: medium"><font size="4" color="#0000FF"><b>
<?
if("Finish The Test"=="$B1")
{
if($R1=="Malaysia")
$first=10;
if($R2=="7")
$second=10;     
if($R3=="150000000 Kilo")
$third=10;
if($R4=="Monitor")
$fourth=10;
echo ("$all=$first+$second+$third+$fourth");
}
?>
</b></font></td></tr>

<tr>
<td colspan="2" style="border-style: none; border-width: medium"><b><font color="#FF0000">Where is the Highest Tower in the World?</font></b></td></tr>

<tr>
<form method="POST" action="Result.php">

<td colspan="2"style="border-style: none; border-width: medium">
<input type="radio" value="USA" name="R1" style="font-weight: 700"><b><FONT COLOR="#FFFF00">   America<FONT></b></td>
</tr>

<tr>
<td colspan="2" style="border-style: none; border-width: medium">
<input type="radio" value="Paris" name="R1" style="font-weight: 700"><b><FONT COLOR="#FFFF00">
Paris</FONT></b></td>
</tr>

<tr>
<td colspan="2" style="border-style: none; border-width: medium">
<input type="radio" value="Italia" name="R1" style="font-weight: 700"><b><FONT COLOR="#FFFF00">Italia</FONT> 
</b></td></tr>

<tr>
<td colspan="2" style="border-style: none; border-width: medium">
<input type="radio" value="Malaysia" name="R1" style="font-weight: 700"><b><FONT COLOR="#FFFF00">Malaysia</FONT></b></td></tr>

<tr>
<td colspan="2" style="border-style: none; border-width: medium">&nbsp;</td></tr>

<tr>
<td colspan="2" style="border-style: none; border-width: medium"><font color="#FF0000"><b>How many colors of the rainbow ?</b></font></td>
</tr>

<tr>
<td colspan="2" style="border-style: none; border-width: medium">
<input type="radio" value="9" name="R2" style="font-weight: 700"><b><FONT COLOR="#FFFF00">9</<FONT></b></td></tr>

<tr>
<td colspan="2" style="border-style: none; border-width: medium">
<input type="radio" value="15" name="R2" style="font-weight: 700"><b><FONT COLOR="#FFFF00">15</FONT></b></td>
</tr>

<tr>
<td colspan="2" style="border-style: none; border-width: medium">
<input type="radio" value="7" name="R2" style="font-weight: 700"><b><FONT COLOR="#FFFF00">7</FONT></b></td></tr>


<tr>
<td colspan="2" style="border-style: none; border-width: medium">
<input type="radio" value="20" name="R2" style="font-weight: 700"><b><FONT COLOR="#FFFF00">20</FONT></b></td>
</tr>

<tr>
<td colspan="2" style="border-style: none; border-width: medium"><font color="#FF0000"><b>How is the distance between Earth and Sun?</b></font></td></tr>

<tr>
<td colspan="2" style="border-style: none; border-width: medium">
<input type="radio" value="15000 Kilo" name="R3" style="font-weight: 700"><b><FONT COLOR="#FFFF00">15000 KM</FONT></b></td></tr>

<tr>
<td colspan="2" style="border-style: none; border-width: medium">
<input type="radio" value="50000 Kilo" name="R3" style="font-weight: 700"><b><FONT COLOR="#FFFF00">50000 KM</FONT></b></td></tr>

<tr>
<td colspan="2" style="border-style: none; border-width: medium">
<input type="radio" value="150000000 Kilo" name="R3" style="font-weight: 700"><b><FONT COLOR="#FFFF00">150,000,000 KM</FONT></b></td></tr>

<tr>
<td colspan="2" style="border-style: none; border-width: medium">
<input type="radio" value="We can not tell" checked name="R3" style="font-weight: 700"><b><FONT COLOR="#FFFF00">We can not tell</FONT></b></td></tr>

<tr>
<td colspan="2" style="border-style: none; border-width: medium"><font color="#FF0000"><b>LCD is Type of a :-</b></font></td></tr>

<tr>
<td colspan="2" style="border-style: none; border-width: medium">
<input type="radio" value="Monitor" name="R4" style="font-weight: 700"><span lang="en-us"><b><FONT COLOR="#FFFF00">Monitor</FONT></b></span></td></tr>

<tr>
<td colspan="2" style="border-style: none; border-width: medium">
<input type="radio" value="CPU" name="R4" style="font-weight: 700" checked><span lang="en-us"><b><FONT COLOR="#FFF00">CPU</FONT></b></span></td></tr>

<tr>
<td height="29" colspan="2" style="border-style: none; border-width: medium">
<input type="radio" value="Mic" name="R4" style="font-weight: 700"><span lang="en-us"><b><FONT COLOR="#FFFF00">Mic</FONT></b></span></td>
</tr>

<tr>
<td colspan="2" style="border-style: none; border-width: medium">
<input type="radio"value="Windows" name="R4" style="font-weight: 700"><span lang="en-us"><b><FONT COLOR="#FFFF00">Windows</FONT></b></span></td></tr>

<tr>
<td colspan="2"style="border-style: none; border-width: medium">
<p align="center">
<input type="submit"value="Finish The Test" name="B1">
</td></tr>

</form>
</table>
</div>
</body>
</html>

Please Please Please , Help to get out of this
I had been working 4 days and there is no result came out
and thanks for you .
topMMM
:)

Edited 3 Years Ago by Dani: Formatting fixed

To start with, you can't put script tags inside script tags. You can't put ANY tags inside script tags. It's better to use an external .js file.

CAPITAL letters are deprecated in tag, attribute, and styles. Newer browsers are case-sensitive, and they recognize only the lowercase versions of defined tag, attribute, and style names. <style> works, but <STYLE> does not.

0px is not a valid style. Use 0 for all values with a zero value. 0 with a unit of measure attached causes errors in Firefox.

Tangled tags prevent the DOM addressing of JavaScript from working right. You have tangled tags, with the table tag pair beginning inside the form tag pair, but ending outside the form tag pair, like this:

<form>
  <table>
  </form>
</table>

You must next tag pairs for them to work properly. Tag pairs must be entirely inside other tag pairs, or entirely outside them, like this:

<form>
  <table>
  </table>
</form>

Put both table tags inside the form tags.

The marquee tag is a nonstandard addition that works only in Internet Explorer. It is not cross-browser compatible. Don't use it.

I don't see any calls to the js functions. They don't run themselves. The one script in the body runs ONCE when the page loads, before anyone can click buttons.

Your finish test button should have an onclick feature to call your js.

You have to use a for loop to poll all of the radio buttons to find out which one is selected. The names R1, etc do NOT contain the selections checked by name. Checking a button does not change the value of the radio button group, but only the checked attributes of the individual buttons.

You have to ask the value of its checked attribute of the buttons, where i is the number of each button in the named group, beginning with 0 for the first one.

The word "checked" is not a valid attribute. It should say "checked=checked".

A border style of none indicates there shall be no border. Thus, you can't give it a width. Use margin or padding if you want to define a clear space around an object without a colored border.

You didn't assign any values in the cases where the answer is wrong. It will be zero the first time someone takes the text, but once you assign a value of 10 to $first, then the next time someone does the test, $first already has 10 in it, and it won't go away if the user selects the wrong answer.

Thank you so much MidiMagic and
I REALLY appreciate your helping :)

This article has been dead for over six months. Start a new discussion instead.