ASP and Javascript problem

Discussion in 'HTML' started by Kamyk, Oct 13, 2004.

  1. Kamyk

    Kamyk Guest

    Hello all!

    I have problem with code. Firstly I have created the VBScript code which
    count me the time and days which left to the end of working week. I work
    from 8:00 am till 4 pm.
    I would like to show this information on the screen by using "input form
    element" and using onload event which is refreshed after every 1 second.
    Unfortunately I don`t want
    to replace vbscript code on javascript code to do so. I want to have
    vbscirpt. Could you do me a favour and rebuild this code below to make it
    properly working.

    I would be very grateful if you could help me
    Regards
    and thanx for help
    Marcin from Poland
    ----------------------------------------------------------------------------
    -----------------------

    <HTML>
    <HEAD>

    <% @language=vbscript %>
    <%
    function funkcja_czas()
    dim roznica_koniec_dnia_pracy,roznica_koniec_tygodnia, roznica_czas_m,
    roznica_czas_h, roznica_czas_s, znacznik_dnia1,znacznik_dnia2,
    znacznik_dnia, czas

    roznica_koniec_tygodnia=(7-weekday(date,vbMonday))

    roznica_koniec_dnia_pracy=roznica_koniec_tygodnia-2
    roznica_czas_h=(DateDiff("h",Time,CDate("16:00:00"))-1)

    if Hour(Time)<16 then
    czas=Cdate(Cstr(Hour((Time+Cdate("01:00:00")))) & ":00:00")
    roznica_czas_m=(DateDiff("n",time,czas))
    czas=Cdate(Cstr(Hour(Time) & ":" & Minute(Time+Cdate("00:01:00")) & ":00"))
    roznica_czas_s=(DateDiff("s",time,czas))
    if roznica_czas_s=60 then
    roznica_czas_s=0
    end if
    else
    roznica_czas_m=0
    end if


    if roznica_koniec_dnia_pracy=1 then
    znacznik_dnia1="dzieƱ"
    else
    znacznik_dnia1="dni"
    end if

    if roznica_koniec_tygodnia=2 then
    znacznik_dnia2="dzieƱ"
    else
    znacznik_dnia2="dni"
    end if

    funkcja_czas= ("Koniec tygodnia nastapi za " & roznica_koniec_tygodnia & " "
    & znacznik_dnia2 & "<BR>" & "Koniec tygodnia pracy nastapi za " &
    roznica_koniec_dnia_pracy &" "& znacznik_dnia1 & " " & roznica_czas_h & ":"
    & roznica_czas_m & ":" & roznica_czas_s & " sec.")
    end function
    ff="1"
    %>



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

    function clock()
    {

    document.clock.time.value=
    <%
    ff
    %>;
    window.setTimeout("clock()", 900);
    }

    // -->
    </SCRIPT>

    </HEAD>

    <BODY onload="clock();">

    <form name="clock">
    Time <input type=text name="time" size="20" style="border: 0">
    </form>
     
    Kamyk, Oct 13, 2004
    #1
    1. Advertising

  2. Kamyk

    Andy Dingley Guest

    On Wed, 13 Oct 2004 20:28:02 +0200, "Kamyk"
    <> wrote:

    >Could you do me a favour and rebuild this code below to make it
    >properly working.


    No - You have a misunderstanding here which is fundamental. You need
    to understand this first.


    ASP code runs on the server. It runs once, when the page is delivered.
    It cannot run on a timer, or in response to a user action.

    Client-side code runs on the client's browser. It is your only option
    if you want things to happen on the page after the user has loaded it,
    without re-loading the page.


    Client-side code is nearly always writen in JavaScript. ASP code can
    be JavaScript or VBScript.

    WHICH LANGUAGE YOU WRITE IN DOES NOT CONTROL WHERE THE CODE RUNS!


    Your current example is a mix of server-side VBScript and client-side
    JavaScript. You need to re-write all of this into client-side code.

    NORMALLY, you would write all of your client-side code in JavaScript.
    But I think this page is just for you, and you're just using IE. IE
    can also use VBScript on the client-side.

    Take out the ASP, make all the code client-side, leave the code in
    VBScript if you don't want to re-write it. Using .setTimeout() or
    ..setTimeoutInterval() is the right approach.


    As a long-term improvement, I suggest learnign JavaScript and using it
    for all your code, instead of VBScript. It's a better language.

    --
    Smert' spamionam
     
    Andy Dingley, Oct 13, 2004
    #2
    1. Advertising

  3. Kamyk

    aa Guest

    You mentioned ASP. I do not remember detailsm yet in ASP there is a method,
    probably in Response object with allows to refresh the screen at a necessary
    interval - will you check an ASP manual or consult on ASP NG
     
    aa, Oct 14, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David Virgil Hobbs
    Replies:
    0
    Views:
    524
    David Virgil Hobbs
    Jan 6, 2004
  2. tao lin
    Replies:
    2
    Views:
    4,902
    tao lin
    Jan 2, 2005
  3. Andy
    Replies:
    2
    Views:
    230
    kaeli
    Mar 4, 2004
  4. Kamyk

    ASP and Javascript problem

    Kamyk, Oct 13, 2004, in forum: Javascript
    Replies:
    0
    Views:
    81
    Kamyk
    Oct 13, 2004
  5. porter

    Javascript and IE? Javascript and C#?

    porter, Oct 5, 2007, in forum: Javascript
    Replies:
    6
    Views:
    296
    Thomas 'PointedEars' Lahn
    Oct 6, 2007
Loading...

Share This Page