Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
text slideshow for quiz script
Old 07-19-2006, 06:54 PM text slideshow for quiz script
capetek's Avatar
Extreme Talker

Posts: 229
Location: Massachusetts
Trades: 0
Hello,


I am making a quiz script for a website I am doing and I am having a bit of trouble on the javascript part of the script. All the information in the page below is pulled from a mysql datbase with php. What i am trying to do is when you hit start it goes through all the generated divs one by one by the designated time which is changable via the admin panel. The problems I'm having with the script im using is:

the script doesnt seem to be following the time limit for all questions
the script has a long pause in the begining.
the script does not stop when finished displaying all results

Any help would be appreciated, if you know of another method i could use then please let me know. Thanks

script in action:
Code:
http://dlgresults.com/dev/wm/quiz.inc.php
code:
Code:
<script language="JavaScript" type="text/JavaScript">
<!--

var defaultTimeOut = 15000; //Default timeout 15 seconds

//Starts the rotation.
function startRotation (howMany, timeOut) {
    defaultTimeOut = timeOut;
    setTimeout('rotateLayers(' + howMany + ')', defaultTimeOut);
}

// This function rotates the visibility of layers randomly.
function rotateLayers (howMany) {
    for (var i=1; i<=howMany; i++) eval("document.all.rotatingLayer" + i +
".style.visibility = 'hidden'");
    eval("document.all.rotatingLayer" + (Math.round(Math.random() * (howMany
- 1)) + 1) + ".style.visibility = 'visible'");
    setTimeout('rotateLayers(' + howMany + ')', defaultTimeOut);
}

//-->
</script>
<style type="text/css">
.questionflick {layer-background-color: #FFFFCC; border: 1px none #000000; visibility:
hidden; position:absolute; }
</style>

<?
	require('includes/config.php');
	require('core/database.php');
	$database = new database();
	$database->connect();


switch ($function) {

default:

$query = $database->query("SELECT * FROM quiz");

	while ($list = mysql_fetch_array($query)) {

		$id = stripslashes($list['id']);
		$name = stripslashes($list['name']);
		$description = stripslashes($list['description']);
		$names22 .= '
		<div><a href="?function=start&quid='.$id.'">'.$name.'</a> &bull; '.$description.'</div>
		';
    	    $row_count++; 
  		
		}	

echo '<h2>Select a quiz below to start</h2>
	 	'.$names22.''; 


break;

case "start" :

$quid = $_GET['quid'];

		$query = $database->query("SELECT * FROM quiz where id = $quid");

	while ($list = mysql_fetch_array($query)) {

		$id = stripslashes($list['id']);
		$name = stripslashes($list['name']);
		$description = stripslashes($list['description']);
		$howlong = stripslashes($list['howlong']);
  		
		
		
		
		}	

			$i = '1';
	$query = $database->query("SELECT * FROM quiz_quest WHERE main = $quid ORDER by id ");
	while ($list = mysql_fetch_array($query)) {
	
		$qid = stripslashes($list['id']);
		$qquestion = stripslashes($list['question']);
		$qmain = stripslashes($list['main']);
		$qquestions .= '
		<div id="rotatingLayer'.$i++.'" class="questionflick">'.$qquestion.'</div>
		';
	
	}
	$howmany = mysql_num_rows($query);


	
?>

<input name="start" type="button" id="start" value="Click here to start <?php echo $name;?>!"
onClick="startRotation(<?php echo $howmany;?>, <?php echo $howlong;?>);"/>

<?
$howlong = $howlong / 1000;
	echo '<h1>'.$howmany.' Questions, you have '.$howlong.' seconds per question</h1>';
	echo '<h2>'.$qquestions.'</h2>';
break;
}



?>
__________________
Anthony LeBoeuf
Cape-Tek IT Solutions

Please login or register to view this content. Registration is FREE

Great hosting at affordable pricing!
capetek is offline
Reply With Quote
View Public Profile Visit capetek's homepage!
 
 
Register now for full access!
Reply     « Reply to text slideshow for quiz script
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.07922 seconds with 12 queries