Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 3rd, 2004, 05:01 AM
Registered User
 
Join Date: Apr 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default generating automatic numbers

i working with a online examination system project and i want include a message which warns the user that they have only this much of the time to complete the question. like " time left is 10 out of 60 seconds". i used refresh meta tag to refresh page for each 60 seconds, which changes the question. but i want to show the time to complete question also. how can i do that? if any one that pls help me. advance thanks.


 
Old April 5th, 2004, 12:35 PM
Joy Joy is offline
Registered User
 
Join Date: Apr 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

See if this helps! I found this code online.

<HEAD>

<SCRIPT LANGUAGE="JavaScript">

var up,down;var min1,sec1;var cmin1,csec1,cmin2,csec2;
function Minutes(data) {
for(var i=0;i<data.length;i++)
if(data.substring(i,i+1)==":")
break;
return(data.substring(0,i));
}
function Seconds(data) {
for(var i=0;i<data.length;i++)
if(data.substring(i,i+1)==":")
break;
return(data.substring(i+1,data.length));
}
function Display(min,sec) {
var disp;
if(min<=9) disp=" 0";
else disp=" ";
disp+=min+":";
if(sec<=9) disp+="0"+sec;
else disp+=sec;
return(disp);
}
function Up() {
cmin1=0;
csec1=0;
min1=0+Minutes(document.sw.beg1.value);
sec1=0+Seconds(document.sw.beg1.value);
UpRepeat();
}
function UpRepeat() {
csec1++;
if(csec1==60) {
csec1=0; cmin1++;
}
document.sw.disp1.value=Display(cmin1,csec1);
if((cmin1==min1)&&(csec1==sec1))
alert("Stopwatch Stopped");
else up=setTimeout("UpRepeat()",1000);
}
</SCRIPT>

<BODY>

<CENTER>
<FORM name="sw">
<TABLE border="0" width="100%">
<tr align="center">
<td><table border="3" width="100%"><tr>
<th colspan="2">Stopwatch</th></tr>
<tr align="center">
<td>Stop at<br>
<input type="text" name="beg1" size="7" value="0:10"></td>
<td><input type="button" value="Start" onclick="Up()"></td>
</tr>
<tr align="center"><td colspan="2">
<input type="text" name="disp1" size="7"></td></tr></table></td>
</TABLE>
</FORM>
</CENTER>





Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatic Redirect tna55 ASP.NET 2.0 Basics 2 April 4th, 2007 07:32 AM
Generating random numbers invisibleman18 Java Basics 2 March 26th, 2007 12:22 AM
Generating Squentila numbers in VBA Shabir Hussain Excel VBA 1 June 27th, 2005 06:20 AM
Automatic Redirect r_ganesh76 General .NET 3 September 9th, 2004 07:03 AM
Automatic URLs Imar Forum and Wrox.com Feedback 13 June 19th, 2003 03:01 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.