HTML beginner |
|
Hallo
Ik zou zo'n quizsysteem willen bouwen zoals op sitemasters. Maar ik heb het volgende probleem:
Ik wil de tijd meegeven via de url (via variable 'tijd'), maar deze klopt niet. Oftewel geeft hij 0 seconden door oftewel 30. Wat dus niet klopt.
Voorbeeld: http://www.mast...t/quiz.php
M'n code:
<html>
<head>
<title>The A-team Fans V3.0 - Quiz</title>
<link href="style.css" rel="stylesheet" type="text/css">
<script language="JavaScript">
var interval, m="00", s=30;
function countdown() {
if(s==0) {window.location="quiz.php?tid=<?=$tid2; ?>&tijd="+s;
} else {
s-=1;
if (s <= 5) {
document.getElementById("time").innerHTML = "<font color='#FF0000'><b>"+(m + ":" + (s<10?"0":"") + s)+"</b></font>";
} else {
document.getElementById("time").innerHTML = m + ":" + (s<10?"0":"") + s;
}
}
}
</script>
</head>
<body onload="interval=setInterval('countdown();',1000);" class="quiz">
<div id="contentquiz">
<div class="quiz" align="left"><p>
<h2>The A-team Quiz</h2><p>
<?
//connectie db
$bSql = "SELECT * FROM vragen WHERE id =$tid";
$bQuery = mysql_query($bSql);
while ($bShow = mysql_fetch_object($bQuery))
{
echo "Vraag ".$teller."\n";
?>
<script LANGUAGE="JavaScript">
document.write('<form name=\"tijd\" action=\"quiz2.php?tid=<?=$tid2; ?>&tijd=' + s + '\" method=\"post\">');
</script>
<?
echo "<b>".$bShow->vraag." (".$bShow->gebruiker.")</b><br>\n";
echo "<input type=\"radio\" name=\"vraag".$bShow->id."\" value=\"1\" class=\"keuze\">".$bShow->antwoord1."<br>\n";
echo "<input type=\"radio\" name=\"vraag".$bShow->id."\" value=\"2\" class=\"keuze\">".$bShow->antwoord2."<br>\n";
echo "<input type=\"radio\" name=\"vraag".$bShow->id."\" value=\"3\" class=\"keuze\">".$bShow->antwoord3."<br>\n";
echo "<input type=\"radio\" name=\"vraag".$bShow->id."\" value=\"4\" class=\"keuze\">".$bShow->antwoord4."<br>\n";
echo "<br><input type=\"Submit\" name=\"Submit\" value=\"Volgende vraag\">\n";
echo "</form>\n";
}
echo "<div align=\"right\"><b>Resterende tijd:</b> <font id=\"time\" class=\"kader\">00:30</font> </div><br>\n";
?>
</div>
</div>
</body>
</html>
<html> <head> <title>The A-team Fans V3.0 - Quiz</title> <link href="style.css" rel="stylesheet" type="text/css"> <script language="JavaScript"> var interval, m="00", s=30; function countdown() { if(s==0) {window.location="quiz.php?tid=<?=$tid2; ?>&tijd="+s; } else { s-=1; if (s <= 5) { document.getElementById("time").innerHTML = "<font color='#FF0000'><b>"+(m + ":" + (s<10?"0":"") + s)+"</b></font>"; } else { document.getElementById("time").innerHTML = m + ":" + (s<10?"0":"") + s; } } } </script> </head> <body onload="interval=setInterval('countdown();',1000);" class="quiz"> <div id="contentquiz"> <div class="quiz" align="left"><p> <h2>The A-team Quiz</h2><p> <? //connectie db $bSql = "SELECT * FROM vragen WHERE id =$tid"; { echo "Vraag ".$teller."\n"; ?> <script LANGUAGE="JavaScript"> document.write('<form name=\"tijd\" action=\"quiz2.php?tid=<?=$tid2; ?>&tijd=' + s + '\" method=\"post\">'); </script> <? echo "<b>".$bShow->vraag." (".$bShow->gebruiker.")</b><br>\n"; echo "<input type=\"radio\" name=\"vraag".$bShow->id."\" value=\"1\" class=\"keuze\">".$bShow->antwoord1."<br>\n"; echo "<input type=\"radio\" name=\"vraag".$bShow->id."\" value=\"2\" class=\"keuze\">".$bShow->antwoord2."<br>\n"; echo "<input type=\"radio\" name=\"vraag".$bShow->id."\" value=\"3\" class=\"keuze\">".$bShow->antwoord3."<br>\n"; echo "<input type=\"radio\" name=\"vraag".$bShow->id."\" value=\"4\" class=\"keuze\">".$bShow->antwoord4."<br>\n"; echo "<br><input type=\"Submit\" name=\"Submit\" value=\"Volgende vraag\">\n"; } echo "<div align=\"right\"><b>Resterende tijd:</b> <font id=\"time\" class=\"kader\">00:30</font> </div><br>\n"; ?> </div> </div> </body> </html>
Wat is er mis?
|