![]() |
ASP and Javascript problem
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> |
Re: ASP and Javascript problem
On Wed, 13 Oct 2004 20:28:02 +0200, "Kamyk"
<marcinzmyslowski@poczta.onet.pl> 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 |
Re: ASP and Javascript problem
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 |
| All times are GMT. The time now is 08:51 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.