Solved

Count UP script input from a form

Posted on 2002-07-10
34
350 Views
Last Modified: 2011-08-18
Hello,

I have a fantasy football draft webite that we use to draft our leagues teams. It's a long draft meaning it takes about 21 days to complete. Each team owner either emails or phones me with their pick. I then through a form on an .asp page enter data. It gets submitted to an Access db. Users can query db from another webpage to see results of total draft/individual team/rounds... I want to add a countUP script that starts when I submit data to db. Need it to count by secs/mins/hours/days.

In essence what I'm doing is saying, "Current team has been on the clock - (countUp time)". We don't have a time limit between picks so this just gives the guys something to look at. To see how long someone has been on the clock so to speak. I hope this makes sense.

Up til this year I've had a countup javascript on my .html page. But it is a pain to have to always go in and change settings in the code. I want it easy!

BIll
0
Comment
Question by:bneuman
  • 19
  • 15
34 Comments
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 7144123
Grab the date added from your database, and use the now() function to get the current date/time, and then use the datediff() function:

You could do something like this with VBScript:

DateDiff returns the difference in intervals between two dates. The interval can be one of the following settings:


    "yyyy"          Year
    "q"          Quarter
    "m"          Month
    "y"          Day of Year
    "d"          Day
    "w"          Weekday
    "ww"          Week of Year
    "h"          Hour
    "n"          Minute
    "s"          Second

So, DateDiff("d",#10/5/98#,#10/8/98#) would return 3, since there are three days between 10/8/98 and 10/5/98.


Just continue on for hours, minutes, and seconds and you are done.

Fritz the Blank
0
 

Author Comment

by:bneuman
ID: 7144669
Fritz,

After looking this over and playing with some code is this typical results of what your suggestion would be?
******************************************************
Countdown to 2003!
There are 6 months left till the year 2003!
There are 175 days left till the year 2003!
There are 4184 hours left till the year 2003!
There are 250983 minutes left till the year 2003!
There are 15058970 seconds left till the year 2003!

If you are curious it is currently 4:57:10 PM on 7/10/2002.
******************************************************

I was hoping for something realtime. It counts up as you view it....

BIll
0
 

Author Comment

by:bneuman
ID: 7144846
Fritz or anyone,

I was hoping to use this or a script like this. I would like to be able to capture the time when I hit submit on a form in another webpage. This form adds the draft picks to the db.

**********************************************************
<head>

<SCRIPT LANGUAGE="JavaScript">
<!--

/*
 *
 *     "Count-Up (Form)"
 *
 *
 *     Created by Glub, Un-Inc. [06-02-97]
 *
 *     Copyright (C) 1996-97  Glub, Un-Inc.  All Rights Reserved.
 *     Feel free to reuse or modify this code,
 *     provided this header remains in tact.
 *     [http://www.glub.com/] [http://www.dotdotcom.com/]
 *
*/
/* Initializations */
var timerID;
var timerRunning = false;
var today = new Date();
var startday = new Date();
var secPerDay = 0;
var minPerDay = 0;
var hourPerDay = 0;
var secsLeft = 0;
var secsRound = 0;
var secsRemain = 0;
var minLeft = 0;
var minRound = 0;
var minRemain = 0;
var timeRemain = 0;

/* This function will stop the clock */
function stopclock()
{
     if(timerRunning)
          clearTimeout(timerID);

     timerRunning = false;
}

/* This function will start the clock */
function startclock()
{
     stopclock();
     showtime1();
}

/* This function will display the count-up */
function showtime1()
{
     startday = new Date("JULY 10 , 2002 13:30 EDT");
     startday.setYear("2002");
     today = new Date();
     secsPerDay = 1000 ;
     minPerDay = 60 * 1000 ;
     hoursPerDay = 60 * 60 * 1000;
     PerDay = 24 * 60 * 60 * 1000;

     /* Seconds */
     secsLeft = (today.getTime() - startday.getTime()) / minPerDay;
     secsRound = Math.round(secsLeft);
     secsRemain = secsLeft - secsRound;
     secsRemain = (secsRemain < 0) ? secsRemain = 60 - ((secsRound - secsLeft) * 60) : secsRemain = (secsLeft - secsRound) * 60;
     secsRemain = Math.round(secsRemain);

     /* Minutes */
     minLeft = ((today.getTime() - startday.getTime()) / hoursPerDay);
     minRound = Math.round(minLeft);
     minRemain = minLeft - minRound;
     minRemain = (minRemain < 0) ? minRemain = 60 - ((minRound - minLeft) * 60) : minRemain = ((minLeft - minRound) * 60);
     minRemain = Math.round(minRemain - 0.495);

     /* Hours */
     hoursLeft = ((today.getTime() - startday.getTime()) / PerDay);
     hoursRound = Math.round(hoursLeft);
     hoursRemain = hoursLeft - hoursRound;
     hoursRemain = (hoursRemain < 0) ? hoursRemain = 24 - ((hoursRound - hoursLeft) * 24)  : hoursRemain = ((hoursLeft - hoursRound) * 24);
     hoursRemain = Math.round(hoursRemain - 0.5);

     /* Days */
     daysLeft = ((today.getTime() - startday.getTime()) / PerDay);
     daysLeft = (daysLeft - 0.5);
     daysRound = Math.round(daysLeft);
     daysRemain = daysRound;

     /* Time */
     if (daysRemain == 1)
     {
          day_rem = " day, "
     }
     else
     {
            day_rem = " days, "
     }

     if (hoursRemain == 1)
     {
          hour_rem = " hour, "
     }
     else
     {
          hour_rem = " hours, "
     }

     if (minRemain == 1)
     {
          min_rem = " minute, "
     }
     else
     {
          min_rem = " minutes, "
     }

     if (secsRemain == 1)
     {
          sec_rem = " second"
     }
     else
     {
          sec_rem = " seconds"
     }

     timeRemain = daysRemain + day_rem + hoursRemain + hour_rem + minRemain +
     min_rem + secsRemain + sec_rem;
     document.up.face.value = timeRemain;
     timerID = setTimeout("showtime1()",1000);
     timerRunning = true;
}

//-->
</SCRIPT>
 
</HEAD>

<BODY BGCOLOR="#FFFFFF" onLoad="startclock()">

<CENTER>
<FORM NAME="up">
<INPUT TYPE="text" NAME="face" SIZE="35" VALUE="A browser supporting JavaScript 1.1+ is needed.">
</FORM>
<P>
<FONT SIZE=+1 FACE="Arial">
"SUDS DUDS" -  ON THE CLOCK
</FONT>
</P>
</CENTER>

</BODY>
</HTML>
0
 

Author Comment

by:bneuman
ID: 7146910
Hey did everyone give up? :-)

If I can't grap the now()function how about using an input on a form to fill the javascript? I'd rather the first idea. I'm too new at this....

BIll
0
 

Author Comment

by:bneuman
ID: 7147693
Ok, here is the addrecords.asp page. This is the form where data is added and submitted to the db. Above is the current script I'm using for the countup. When clicking on submit I'd like the function Now() to fill in the javascript section:

/* This function will display the count-up */
function showtime1()
{
    startday = new Date("JULY 10 , 2002 13:30 EDT");
   
    startday.setYear("2002");
    today = new Date();
    secsPerDay = 1000 ;
    minPerDay = 60 * 1000 ;
    hoursPerDay = 60 * 60 * 1000;
    PerDay = 24 * 60 * 60 * 1000;

**********************************************************
<html><head>
<title>Add Records to 2002 AFF Draft</title>
</head>
<body><center>
<h2 align="center">Add Player to 2002 AFF Draft</h2>


<table>
<table border="1">
<tr>
<td>1 Flapheads</td><td>2 Garfields Browns</td><td>3 Holsters</td><td>4 Jetstream</td><td>5 Jungle Karma</td><td>6 KD Krunch</td>
</tr>
<tr>
<td>7 Neumans Nutz</td><td>8 Skeeters Studs</td><td>9 Suds Duds</td><td>10 Tip a Few</td><td>11 The Waterboy</td><td>12 Woodchucks</td>
</tr>
</table

<td width="424"><form method="post" name="form1" action="addrecords2.asp">
<p><strong>Team ID</strong><br>
<input type="text" size="6" name="tm_id"><br>
<strong>Round</strong><br>
<input type="text" size="6" name="round"><br>
<strong>AFF Team</strong><br>
<input type="text" size="20" name="aff_tm"><br>
<strong>Position</strong><br>
<input type="text" size="6" name="pos"><br>
<strong>Player</strong><br>
<input type="text" size="30" name="player"><br>
<strong>NFL Team</strong><br>
<input type="text" size="20" name="nfl_tm"><br>
<strong>Date Picked</strong><br>
<input type="text" size="20" name="dt_pk"><br>
<strong>Time Picked</strong><br>
<input type="text" size="20" name="tm_pk"><br>
<strong>Overall Pick</strong><br>
<input type="text" size="6" name="ovr_pk"><br>
<strong>Overall Position</strong><br>
<input type="text" size="6" name="ovr_pos"><br>
<strong>CBS Ranking</strong><br>
<input type="text" size="6" name="rank"><br>


<p><input type="Submit" value="Submit Pick" name"b1"> </font></p>
</form>
</td>
</tr></center>
</table>
</center></div>
</body></html>
**********************************************************
I know what I want just don't know where to start... I'll increase points another 100 points.

BIll
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 7147883
Hey Bill,,

I am sorry to have dropped the ball--I have been and continue to be really busy. I'll see if I can find some time to write some code to get you started.

Fritz the Blank
0
 

Author Comment

by:bneuman
ID: 7150665
Fritz,

Looking forward to your help...

Bill
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 7150781
Okay, sorry to take so long. I have posted some code below that I think will do what you need it to. However, you will need to change one line of code:

var eventdate = new Date("July 13, 2002 20:05:00");

to some thing like:

var eventdate = new Date("<%datEventDate%>");

where datEventDate is pulled from your database.

Here's the code:

<HTML>
<HEAD>
<TITLE>Project: NetSite...JavaScript Countdown Clock</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
// AUTHOR:          Patrick Fairfield
//                    www.FairfieldConsulting.com  
//                    Based heavily on:
//                    Maxim V. Kollegov, All Rights Reserved.
//              http://www.geocities.com/SiliconValley/Lakes/8620
//              Modified with permission by Joe Hage - Team ScriptBuilder
//              Feel free to reuse this code provided you include this
//              AUTHOR section in your pages.
// DESC:        Display a ticking countdown clock on your web page.
// Sample HTML: COUNTDOWN.HTML
// PLATFORMS:   Netscape Navigator 3.0 and higher,
//                   Microsoft Internet Explorer 3.02 and higher
// ======================================================================
//change your event date event here.
var eventdate = new Date("July 13, 2002 20:05:00");

function toSt(n) {
  s=""
  if(n<10) s+="0"
  return s+n.toString();
}
 
function countdown() {
  cl=document.clock;
  d=new Date();
  count=Math.floor((eventdate.getTime()-d.getTime())/1000);
  if(count<=0)
    {cl.days.value ="----";
     cl.hours.value="--";
     cl.mins.value="--";
     cl.secs.value="--";
     return;
   }
  cl.secs.value=toSt(count%60);
  count=Math.floor(count/60);
  cl.mins.value=toSt(count%60);
  count=Math.floor(count/60);
  cl.hours.value=toSt(count%24);
  count=Math.floor(count/24);
  cl.days.value=count;    
 
  setTimeout("countdown()",500);
}
// end hiding script-->
</SCRIPT>
</HEAD>

<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000A0" ALINK="#FF0000" VLINK="#800000" onLoad="countdown()">

<!-- Insert HTML here -->


<FONT FACE="arial, helvetica" SIZE="-1">
<H2 ALIGN=CENTER><FONT FACE="arial, helvetica" COLOR="#800000">JavaScript Countdown Clock</FONT></H2>
<CENTER>
<P>
<FORM name="clock">
<TABLE BORDER=5 CELLSPACING=5 CELLPADDING=0 BGCOLOR="#000000">
     <TR>
          <TD ALIGN=CENTER WIDTH="31%" BGCOLOR="#000080"><FONT COLOR="#FFFFFF"><B>Days:</B></FONT></TD>
          <TD ALIGN=CENTER WIDTH="23%" BGCOLOR="#000080"><FONT COLOR="#FFFFFF"><B>Hours:</B></FONT></TD>
          <TD ALIGN=CENTER WIDTH="23%" BGCOLOR="#000080"><FONT COLOR="#FFFFFF"><B>Mins:</B></FONT></TD>
          <TD ALIGN=CENTER WIDTH="23%" BGCOLOR="#000080"><FONT COLOR="#FFFFFF"><B>Secs:</B></FONT></TD>
     </TR>
     <TR>
          <TD ALIGN=CENTER><INPUT name="days" size=4></TD>
          <TD ALIGN=CENTER><INPUT name="hours" size=2></TD>
          <TD ALIGN=CENTER><INPUT name="mins" size=2></TD>
          <TD ALIGN=CENTER><INPUT name="secs" size=2></TD>
     </TR>
     <TR>
          <TD COLSPAN="4" BGCOLOR="#000080">
               <CENTER><P><FONT FACE="arial,helvetica" SIZE="+2" COLOR="#FFFF00">Until</FONT></CENTER>
          </TD>
     </TR>
     <TR>
          <TD COLSPAN="4" BGCOLOR="#000000">
               <CENTER><P><FONT COLOR="#00FF00" SIZE=+1>
               <SCRIPT LANGUAGE="JavaScript">
               <!--
               document.write(" " + eventdate.toLocaleString() + " ");
               // end hiding script-->
               </SCRIPT>
               </FONT>
               </CENTER>
          </TD>
     </TR>
</TABLE>
</FORM>
</CENTER>
</BODY>
</HTML>
0
 

Author Comment

by:bneuman
ID: 7150853
Fritz,

I think I'm going to give up on this idea. I've been trying for 2 days straight and really have no idea on how to pull in the db date/time to start with.

I got excited to see you had responded. I checked out code and it's not what I expected. I have the countUP code already. The code you sent was to count DOWN. I appreciate you taking time to help me out but this one maybe too far over my head at this point. I guess I can just modify the code manually everytime some one makes their picks...

BIll
0
 
LVL 46

Accepted Solution

by:
fritz_the_blank earned 200 total points
ID: 7151298
Bill,

I am sorry to have wasted your time by not reading your question carefully enough. Take a look at this countup script (I think that I have it right this time) and if it works, we'll figure out a way to pass the necessary paramater from your database.

Fritz the Blank

<HTML>
<HEAD>
<TITLE>JavaScript Countup Clock</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
// AUTHOR:          Patrick Fairfield
//                    www.FairfieldConsulting.com  
//                    Based heavily on:
//                    Maxim V. Kollegov, All Rights Reserved.
//              http://www.geocities.com/SiliconValley/Lakes/8620
//              Modified with permission by Joe Hage - Team ScriptBuilder
//              Feel free to reuse this code provided you include this
//              AUTHOR section in your pages.
// DESC:        Display a ticking countdown clock on your web page.
// Sample HTML: COUNTDOWN.HTML
// PLATFORMS:   Netscape Navigator 3.0 and higher,
//                   Microsoft Internet Explorer 3.02 and higher
// ======================================================================
//change your event date event here.
var eventdate = new Date("July 10, 2002 20:05:00");

function toSt(n) {
  s="";
  n=Math.abs(n);
  if(n<10) s+="0"
  return s+n.toString();
}
 
function countdown() {
  cl=document.clock;
  d=new Date();
  count=Math.floor((eventdate.getTime()-d.getTime())/1000);
  if(count>=0)
    {cl.days.value ="----";
     cl.hours.value="--";
     cl.mins.value="--";
     cl.secs.value="--";
     return;
   }
  cl.secs.value=toSt(count%60);
  count=Math.floor(count/60);
  cl.mins.value=toSt(count%60);
  count=Math.floor(count/60);
  cl.hours.value=toSt(count%24);
  count=Math.floor(count/24);
  cl.days.value=Math.abs(count);    
 
  setTimeout("countdown()",500);
}
// end hiding script-->
</SCRIPT>
</HEAD>

<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000A0" ALINK="#FF0000" VLINK="#800000" onLoad="countdown()">

<!-- Insert HTML here -->


<FONT FACE="arial, helvetica" SIZE="-1">
<H2 ALIGN=CENTER><FONT FACE="arial, helvetica" COLOR="#800000">JavaScript Countup Clock</FONT></H2>
<CENTER>
<P>
<FORM name="clock">
<TABLE BORDER=5 CELLSPACING=5 CELLPADDING=0 BGCOLOR="#000000">
     <TR>
          <TD ALIGN=CENTER WIDTH="31%" BGCOLOR="#000080"><FONT COLOR="#FFFFFF"><B>Days:</B></FONT></TD>
          <TD ALIGN=CENTER WIDTH="23%" BGCOLOR="#000080"><FONT COLOR="#FFFFFF"><B>Hours:</B></FONT></TD>
          <TD ALIGN=CENTER WIDTH="23%" BGCOLOR="#000080"><FONT COLOR="#FFFFFF"><B>Mins:</B></FONT></TD>
          <TD ALIGN=CENTER WIDTH="23%" BGCOLOR="#000080"><FONT COLOR="#FFFFFF"><B>Secs:</B></FONT></TD>
     </TR>
     <TR>
          <TD ALIGN=CENTER><INPUT name="days" size=4></TD>
          <TD ALIGN=CENTER><INPUT name="hours" size=2></TD>
          <TD ALIGN=CENTER><INPUT name="mins" size=2></TD>
          <TD ALIGN=CENTER><INPUT name="secs" size=2></TD>
     </TR>
     <TR>
          <TD COLSPAN="4" BGCOLOR="#000080">
               <CENTER><P><FONT FACE="arial,helvetica" SIZE="+2" COLOR="#FFFF00">Since</FONT></CENTER>
          </TD>
     </TR>
     <TR>
          <TD COLSPAN="4" BGCOLOR="#000000">
               <CENTER><P><FONT COLOR="#00FF00" SIZE=+1>
               <SCRIPT LANGUAGE="JavaScript">
               <!--
               document.write(" " + eventdate.toLocaleString() + " ");
               // end hiding script-->
               </SCRIPT>
               </FONT>
               </CENTER>
          </TD>
     </TR>
</TABLE>
</FORM>
</CENTER>
</BODY>
</HTML>
0
 

Author Comment

by:bneuman
ID: 7151396
Fritz,

Yes that will work. I have put it in my webpage. Mad a few adjustments. Looks good. On this same webpage in a different frame I have a script that displays the last time the database was up dated. Can we use something here to update the count up script? This is the last date updated code:
**********************************************************
><%
' I placed this in a function so I wouldn't have to worry about
' any namespace collisions.  For example... if this was inline
' code and someone named a variable strSQL in a file this file
' gets included into you'd get an error.  This way you don't and
' there's no chance of the variables overwriting one another!
Function RetrieveAndIncrementCount()
     ' From adovbs.inc:
     Const adOpenKeyset = 1
     Const adLockPessimistic = 2
     Const adCmdText = &H0001

     ' Local variables
     Dim strFilename
     Dim strSQL
     Dim rsCounter
     Dim iCount

     ' Get filename and build SQL query
     strFilename = Request.ServerVariables("SCRIPT_NAME")
     strSQL = "SELECT page_name, hit_count FROM hit_count WHERE page_name='" & strFilename & "';"

     ' Open our recordset
     Set rsCounter = Server.CreateObject("ADODB.Recordset")
     
     ' Access version:
     rsCounter.Open strSQL, _
          "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("/commish/db/counter_db.mdb") & ";", _
          adOpenKeyset, adLockPessimistic, adCmdText
     
     
     ' If we've got a record then we read the current value
     ' If we don't then we create one, set the filename, and start at 0
     If rsCounter.EOF Then
          rsCounter.AddNew

          iCount = 0

          rsCounter.Fields("page_name").Value = strFilename
     Else
          rsCounter.MoveFirst

          iCount = rsCounter.Fields("hit_count").Value
     End If

     ' Increment the count and update the DB
     rsCounter.Fields("hit_count").Value = iCount + 1
     rsCounter.Update

     ' Close our connection
     rsCounter.Close
     Set rsCounter = Nothing

     ' Return the count (pre-incrementation).
     RetrieveAndIncrementCount = iCount
End Function
%></center>
<b>Times.</b><br><br>
<b>Last Updated:
<%
Dim oFSO,oFile,dMod
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
Set oFile = oFSO.GetFile(Server.MapPath("/commish/db/draft.mdb"))
dMod = oFile.DateLastModified
Set oFSO = Nothing
Set oFile = Nothing
Response.Write dMod
%>
0
 

Author Comment

by:bneuman
ID: 7151408
ooops, my bad, the script is just this:
***********************************************************
<%
Dim oFSO,oFile,dMod
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
Set oFile = oFSO.GetFile(Server.MapPath("/commish/db/draft.mdb"))
dMod = oFile.DateLastModified
Set oFSO = Nothing
Set oFile = Nothing
Response.Write dMod
%>
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 7151444
Okay,

Try something like instead of:

var eventdate = new Date("July 10, 2002 20:05:00");

use:

var eventdate = new Date("<%=dMod%>");


Fritz the Blank
0
 

Author Comment

by:bneuman
ID: 7151451
Tried it and get this:

NaN in all areas (days,hours,mins,secs,since)
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 7151457
What does this give you in your page?

Response.Write dMod

Fritz the Blank
0
 

Author Comment

by:bneuman
ID: 7151479
not sure if I did it right but it doesn't matter where I put it, I get the same results. Empty boxes for days, hrs,mins,secs and since.
0
 

Author Comment

by:bneuman
ID: 7151481
maybe I should explain that I open a file called frametest.html that opens my webpage. heres frametest.html:
***********************************************************
<HTML>
<HEAD>
<TITLE>2002 AFF Draft</TITLE>
</HEAD>



<FRAMESET ROWS="49%, 51%" BORDER="0">

<FRAMESET COLS="28, 20, 24, 28" frameborder="0" border="2" framespacing="0">

   <FRAME name="selections" SRC="selections.html" MARGINHEIGHT="2" MARGINWIDTH="10" scrolling=no>
   <FRAME SRC="count.asp" MARGINHEIGHT="5" MARGINWIDTH="21" scrolling=no>
   <FRAME SRC="subframe3.html" MARGINHEIGHT="12" MARGINWIDTH="5" scrolling=no>
   <FRAME SRC="pick.asp" MARGINHEIGHT="35" MARGINWIDTH="5" scrolling=no>
   </FRAMESET>
   
   <FRAME name="viewrecords" SRC="viewrecords.asp" MARGINHEIGHT="0">
</HTML>
***********************************************************
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 7151483
I am wondering if the dMod format is not one that JavaScript understands. When you have:

Response.Write dMod

in your code, what does it print out on your page, i.e., I am interested in the format.

Fritz the Blank
0
 

Author Comment

by:bneuman
ID: 7151488
it writes out, Response.Write dMod
0
 

Author Comment

by:bneuman
ID: 7151491
I hate to do this but I have to run out for a few hours. I will be back...... ;-)  I really appreciate all your help.

Bill
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 7151502
Okay, when you get back, here is the question--when you do the following code:

<%
Dim oFSO,oFile,dMod
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
Set oFile = oFSO.GetFile(Server.MapPath("/commish/db/draft.mdb"))
dMod = oFile.DateLastModified
Set oFSO = Nothing
Set oFile = Nothing
Response.Write dMod
%>

what gets written to your page, i.e., what does the date look like. Where I am going with this is that we may need to use some VBScript to modify the date format before passing it on to the javascript.

Fritz the Blank
0
 

Author Comment

by:bneuman
ID: 7151684
I'm back... here's what I get:

7/12/2002 9:31:52 PM

Bil
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 7151688
Great! We're closing in. Is this test page published anywhere so that I can play with it?

Fritz the Blank
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 7151691
I have changed the line of code that captures the event date to:

var eventdate = new Date("7/12/2002 9:31:52 PM");

and it seems to work just fine. Clearly, the problem lies in grabbing the variable from VBScript and dropping into JavaScript. I have done a lot of this, so it shouldn't be too much of a problem.

Fritz the Blank
0
 

Author Comment

by:bneuman
ID: 7151708
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 7151726
No date at all is being passed to the function; if you view the source you'll see the following:

var eventdate = new Date("");

so we need to pass the date properly to this function.

Is the date that you want on the count up clock the same as the last updated date? If so, how do you get that date onto the page dynamically?

Fritz the Blank

0
 

Author Comment

by:bneuman
ID: 7151744
yes this is the date/time I want to use. It is the date/time when the db is updated. It is displayed by the code I posted earlier. I manually enter the data you see on the bottom of the webpage through another webpage called addframe2.html.

would this be easier to get a field from the database. this would be the same thing for me.

Bill
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 7151754
Bill,

Since I can't see the server-side code that generates the last updated text, I can't help you further. However, all you need to do is to duplicate the process so that you can pass the date variable to the javascript. Alternatively, you can create a hidden field with the same value, and then do something like:

strDate=document.formName.hiddenFieldName.value
var eventdate = new Date(strDate);

Fritz the Blank
0
 

Author Comment

by:bneuman
ID: 7151771
Okay, I'll try that. One last question, how do you create a hidden field?
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 7151796
<input type="hidden" name="datHidden" value="7/12/2002 9:31:52 PM">


or:


<input type="hidden" name="datHidden" value='<%=dMod%>' >

Fritz the Blank
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 7151824
One more thing;

if you look at the source for the frame that holds the count up clock, there is no reference to the database modification date.

Perhaps you need to put your code:

<%
Dim oFSO,oFile,dMod
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
Set oFile = oFSO.GetFile(Server.MapPath("/commish/db/draft.mdb"))
dMod = oFile.DateLastModified
Set oFSO = Nothing
Set oFile = Nothing
Response.Write dMod
%>


there as well, but use it to populate the javascript function.

Fritz the Blank
0
 

Author Comment

by:bneuman
ID: 7151954
Well for the last 3 hours i have been playing with this problem. I thought for sure by adding the code that gets the last date modified into the frame page would work. NOPE. Didn't work when I put it on the same page as the other code either.

I want to thank Fritz the Blank for really going above and beyond. I really appreciate it. For this year i will just manually adjust code. Thanks again.

Bill
0
 

Author Comment

by:bneuman
ID: 7151957
Thanks for taking all the time for helping me with this problem. I'll keep trying...

Bill
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 7152353
Bill--

I am sorry that you are having so much trouble with this. Here is one more thing to try:

<HTML>
<HEAD>
<TITLE>JavaScript Countup Clock</TITLE>
<%
<%
Dim oFSO2,oFile2,dMod2
Set oFSO2 = Server.CreateObject("Scripting.FileSystemObject")
Set oFile2 = oFSO2.GetFile(Server.MapPath("/commish/db/draft.mdb"))
dMod2 = oFile2.DateLastModified
Set oFSO2 = Nothing
Set oFile2 = Nothing
%>


%>



<SCRIPT LANGUAGE="JavaScript">
<!--
// AUTHOR:          Patrick Fairfield
//                    www.FairfieldConsulting.com  
//                    Based heavily on:
//                    Maxim V. Kollegov, All Rights Reserved.
//              http://www.geocities.com/SiliconValley/Lakes/8620
//              Modified with permission by Joe Hage - Team ScriptBuilder
//              Feel free to reuse this code provided you include this
//              AUTHOR section in your pages.
// DESC:        Display a ticking countdown clock on your web page.
// Sample HTML: COUNTDOWN.HTML
// PLATFORMS:   Netscape Navigator 3.0 and higher,
//                   Microsoft Internet Explorer 3.02 and higher
// ======================================================================
//change your event date event here.
var eventdate = new Date("<%=dMod2%> ");

function toSt(n) {
  s="";
  n=Math.abs(n);
  if(n<10) s+="0"
  return s+n.toString();
}
 
function countdown() {
  cl=document.clock;
  d=new Date();
  count=Math.floor((eventdate.getTime()-d.getTime())/1000);
  if(count>=0)
    {cl.days.value ="----";
     cl.hours.value="--";
     cl.mins.value="--";
     cl.secs.value="--";
     return;
   }
  cl.secs.value=toSt(count%60);
  count=Math.floor(count/60);
  cl.mins.value=toSt(count%60);
  count=Math.floor(count/60);
  cl.hours.value=toSt(count%24);
  count=Math.floor(count/24);
  cl.days.value=Math.abs(count);    
 
  setTimeout("countdown()",500);
}
// end hiding script-->
</SCRIPT>
</HEAD>

<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000A0" ALINK="#FF0000" VLINK="#800000" onLoad="countdown()">

<!-- Insert HTML here -->


<FONT FACE="arial, helvetica" SIZE="-1">
<H2 ALIGN=CENTER><FONT FACE="arial, helvetica" COLOR="#800000">JavaScript Countup Clock</FONT></H2>
<CENTER>
<P>
<FORM name="clock">
<TABLE BORDER=5 CELLSPACING=5 CELLPADDING=0 BGCOLOR="#000000">
     <TR>
          <TD ALIGN=CENTER WIDTH="31%" BGCOLOR="#000080"><FONT COLOR="#FFFFFF"><B>Days:</B></FONT></TD>
          <TD ALIGN=CENTER WIDTH="23%" BGCOLOR="#000080"><FONT COLOR="#FFFFFF"><B>Hours:</B></FONT></TD>
          <TD ALIGN=CENTER WIDTH="23%" BGCOLOR="#000080"><FONT COLOR="#FFFFFF"><B>Mins:</B></FONT></TD>
          <TD ALIGN=CENTER WIDTH="23%" BGCOLOR="#000080"><FONT COLOR="#FFFFFF"><B>Secs:</B></FONT></TD>
     </TR>
     <TR>
          <TD ALIGN=CENTER><INPUT name="days" size=4></TD>
          <TD ALIGN=CENTER><INPUT name="hours" size=2></TD>
          <TD ALIGN=CENTER><INPUT name="mins" size=2></TD>
          <TD ALIGN=CENTER><INPUT name="secs" size=2></TD>
     </TR>
     <TR>
          <TD COLSPAN="4" BGCOLOR="#000080">
               <CENTER><P><FONT FACE="arial,helvetica" SIZE="+2" COLOR="#FFFF00">Since</FONT></CENTER>
          </TD>
     </TR>
     <TR>
          <TD COLSPAN="4" BGCOLOR="#000000">
               <CENTER><P><FONT COLOR="#00FF00" SIZE=+1>
               <SCRIPT LANGUAGE="JavaScript">
               <!--
               document.write(" " + eventdate.toLocaleString() + " ");
               // end hiding script-->
               </SCRIPT>
               </FONT>
               </CENTER>
          </TD>
     </TR>
</TABLE>
</FORM>
</CENTER>
</BODY>
</HTML>
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now