RE: [PHP] how to make javascript variable global?
| From: | Patricia Hu | Date: | Fri, 27 Oct 2000 17:51:47 +0000 |
| Subject: | RE: [PHP] how to make javascript variable global? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-23935@lists.php.net to get a copy of this message | ||
Thanks very much for your info.
I know what you meant but I have wanted to get the start time when the user clicks Submit button on purpose b/c I want to take into account the time it takes for the request to be sent to server, server processes it or calls another program(such as CGI), etc. If the start time is counted from the moment the page is being loaded, I might lose some important performance factor, such as the time difference in calling an Apache PHP module and a CGI program.
Also actually everything is within a same page. A variable $submit is used to test if this is first time access or actually a submission. I got this line of code:
--------------------------------------------
var start=document.forms[0].startime.value;
--------------------------------------------
and was hoping to use it to get the start time recorded earlier in the later JavaScript code part so as to compare(starttime is the var where the click time is stored), but it did not work, don't know why:-(
So the question is again: if I need to get the value of a JavaScript variable in one <script>..</script> section from an earlier <script> .... </script> part(both <script>..</script> are within a same file), can I do it, if yes, how?
Your help is most appreciated.
Best regards,
Patricia
From: "Opec Kemp ( Ozemail )" <okemp@ozemail.com.au> To: "Patricia Hu" <hxlvt@hotmail.com> CC: "PHP List" <php-general@lists.php.net> Subject: RE: [PHP] how to make javascript variable global? Date: Fri, 27 Oct 2000 11:07:27 +1000 The problem is that you're not sending the "starttime" with your form. That is why it doesn't know the starttime. Essenatially, when the user click on the submit button it treats this as a new request even if you're submitting to the same page. To accomplish what you want to do, it might be easier IMHO to do this: 1) Do nothing in the first page. 2) Once the submission is received on the 2nd page, at the start you start the counter ie get the current time 3) Once your processing in the 2nd script is finished, you get the current time 4) subtract the finish time from the start and display, either with jscript alert() or just a simple output to browser._________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. Share information about yourself, create your own public profile at http://profiles.msn.com.