how to change color after 5 mins

  • 14 years ago

    hi,

    i have a list of tasks and need to highlight the one that has past 30min duratuion after the post ....show the use its that top priority task.

    does anyone know how this could be aheived?

     

  • 14 years ago

    You can achieve this using ASP timer with VBscript or Jscript
    Check this hint to see how the ASP timer can be used

  • 14 years ago
    Click here for javascript timer
  • 14 years ago

    hi
    here is a little function which can test each date in your task list and change the line color

    <%

    dim color

    function IsPast30(strDate)

    if

    now() > dateadd("n", 30, date_post) then

       IsPast30 = true

    else

       IsPast30 = false

    end if

    end function

    %>

    <html>

    <head>

    <meta http-equiv="Refresh" content=10 />

    </head>

    <

    body >

     

    ' here begins the list of your tasks
    'i suppose that you have a table to list it and that you are in a do while loop sequence 

    ' to initialize the color of the line


    color = #ffffff
    <table>


    <%

    if IsPast30(put the post date here) then

    color = #TheColorYouWant (may be a td bgcolor)

    end if

    <tr>

    <td bgcolor = <%=color%>>task 1</td>

    </tr>

    </td>

    ' you loop here

    </body>

    </html>

     

    Regards serval

  • 14 years ago

    thanks a lot serval , can you plase help convert it into javascript. you answered to thr point and detailed enough for me to understand . thanks again

    regard sreddy

  • 14 years ago

    hello sreddy.

    is your entire code in javascript ?

     

     

    Serval

  • 14 years ago

    Serval,

    i have HTML and java scritp, so to answer your question "yes" the entire code is in java script

    thanks for replying

    sreddy

  • 14 years ago

    Hello sreddy
    can you copy paste some lines of your code here so i can code something four you ?

     

    Serval

  • 14 years ago

    <

    html>

    <

    head>

    <title>Untitled Page</title>

    </

    head>

    <

    body>

    date in

    <i>dd/mm/yyyy format</i>

    <

    br>

    <!-- IN MY EXAMPLE YOU MUST CREATE A LABEL TO SHOW THE DATE OF YOUR TASK -->

    <

    label id = "lab01">12/12/2006 12:00</label>

    <

    br />

    <

    br />

    <

    script language=javascript>

    d=

    new Date()

    //this is to format the date ant the time in the correct format you use

    // add 1 to the day so it begins at 0 !

    Theday = d.getDay()+1

    // add "0" before the numbers if it is less than 10

    if

    (Theday < 10)

    {Theday =

    "0"+Theday}

    // add 1 to the month so it begins at 0 !

    TheMonth = d.getMonth()+1

    // add "0" before the numbers if it is less than 10

    if

    (TheMonth < 10)

    {TheMonth =

    "0"+TheMonth}

    //Create the date in the good format : the format you want !!!

    TheDate = Theday +

    "/" + TheMonth + "/" + d.getFullYear()

    TheMinute = d.getMinutes()

    TheHour = d.getHours()

    // I think that you will not use the seconds !!!

    TheTime = TheHour +

    ":" +TheMinute

    DateNow = TheDate + TheTime

     

    // COMPARE IF THE DATE IN THE LABEL IS LESS OR GREATER THAN THE Now DATE

    if

    (document.getElementById("lab01").innerText < DateNow)

    {

    // change the color of the label

    document.getElementById(

    "lab01").style.color="#FF0000";

    }

    else

    {

    // // change the color of the label

    document.getElementById(

    "lab01").style.color="#0000FF";

    }

     

    </

    script>

    </

    body>

    </

    html>

     

    this is to give you an example to begin ...

     

    SERVAL

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Better train people and risk they leave – than do nothing and risk they stay.” - Anonymous