CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> Java

 Java Script for Time please help...

Print topic Send  topic

Author Message
Don_S

Posts: 50
Posted: 03/06/2006, 10:05 AM

I am working on some script to create an alert that pops up 15 minutes before a scheduled event. I have it setup so my page refreshes every 3 minutes. I tried using the code below tied to the "Before Show" event of a field in a grid. I keep getting a VBScript Error for the function:
"VBScript compilation (0x8000A0401)
Expected end of statement
/support/log_events.asp, line 13, column 19
function CallBacks();"

the function code is as follows,\
Thanks in advance,
Don

<script type="text/javascript">
<-- To hide from old browsers
function CallBacks()
{
date = new Date()
day = date.getDate()
month= date.getMonth() +1
year= date.getYear()
hour = date.getHours()
min= date.getMinutes()
c=":"
s="/"

CallDate = document.getElementById("CallDate").value;
CallTime = document.getElementById("CallTime").value;
Customer = document.getElementById("Customer").value;
Contact = document.getElementById("Contact").value;
Phone = document.getElementById("Phone_Nbr").value;
TestHour=hour
Testmin=min
if (min <10)
{
min = "0" + min
}

if (min - 15 < 0)
{
Testhour=hour- 1;
Testmin= 45 + min;
}

Date= month + s + day + s + year
Time= hour + c + min
TestTime= Testhour + c + Testmin

if (CallTime => TestTime)
{
alert ("You have a call back scheduled for" + CallTime;"With " + Contact + " at " + Customer;"Phone #: " + Phone)
}
}// -->
</script>
View profile  Send private message
wkempees


Posts: 1679
Posted: 03/06/2006, 10:41 AM

which line is 13?

_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
Don_S

Posts: 50
Posted: 03/06/2006, 11:26 AM

Line 13 refers to my logs_events.asp file. see below:

Thanks,
Don

<%
'BindEvents Method @1-31C7CFE7
Sub BindEvents()
Set tbl_Call_Backs.CallTime.CCSEvents("BeforeShow") = GetRef("tbl_Call_Backs_CallTime_BeforeShow")
Set tbl_Call_Backs.CCSEvents("BeforeShowRow") = GetRef("tbl_Call_Backs_BeforeShowRow")
End Sub
'End BindEvents Method

Function tbl_Call_Backs_CallTime_BeforeShow(Sender) 'tbl_Call_Backs_CallTime_BeforeShow @59-1EC2A604

'Custom Code @68-73254650
' -------------------------
fuction CallBacks();
' -------------------------
'End Custom Code

End Function 'Close tbl_Call_Backs_CallTime_BeforeShow @59-54C34B28



%>
View profile  Send private message
wkempees


Posts: 1679
Posted: 03/06/2006, 11:29 AM

the 'n' in fuction is there originally I assume O:)
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
Don_S

Posts: 50
Posted: 03/06/2006, 11:39 AM

ok... one thing I just noticed... function was mispelled but it is still not working. Getting Syntax Error for the same line.

Don
View profile  Send private message
wkempees
Posted: 03/06/2006, 2:10 PM

Start with these changes:

<script type="text/javascript">
change to
<script type="text/javascript" LANGUAGE="javascript">

<-- To hide from old browsers
missing exclamation mark
<!-- To hide from old browsers

all references to "min" change to "minute" min is a reserved word apparently

last line
}// -->
change to, 2 lines just in case
}
// -->

Now the script stumbles over
if { CallTime => TestTime )
because => should be >=

Change it and test report back, while I do some further testing












"Don_S" <Don_S@forum.codecharge> schreef in bericht
news:9440c79d7096fa@news.codecharge.com...
>I am working on some script to create an alert that pops up 15 minutes
>before a
> scheduled event. I have it setup so my page refreshes every 3 minutes. I
> tried
> using the code below tied to the "Before Show" event of a field in a grid.
> I
> keep getting a VBScript Error for the function:
> "VBScript compilation (0x8000A0401)
> Expected end of statement
> /support/log_events.asp, line 13, column 19
> function CallBacks();"
>
> the function code is as follows,\
> Thanks in advance,
> Don
>
> <script type="text/javascript">
> <-- To hide from old browsers
> function CallBacks()
> {
> date = new Date()
> day = date.getDate()
> month= date.getMonth() +1
> year= date.getYear()
> hour = date.getHours()
> min= date.getMinutes()
> c=":"
> s="/"
>
> CallDate = document.getElementById("CallDate").value;
> CallTime = document.getElementById("CallTime").value;
> Customer = document.getElementById("Customer").value;
> Contact = document.getElementById("Contact").value;
> Phone = document.getElementById("Phone_Nbr").value;
> TestHour=hour
> Testmin=min
> if (min <10)
> {
> min = "0" + min
> }
>
> if (min - 15 < 0)
> {
> Testhour=hour- 1;
> Testmin= 45 + min;
> }
>
> Date= month + s + day + s + year
> Time= hour + c + min
> TestTime= Testhour + c + Testmin
>
> if (CallTime => TestTime)
> {
> alert ("You have a call back scheduled for" + CallTime;"With " + Contact +
> "
> at " + Customer;"Phone #: " + Phone)
> }
> }// -->
> </script>
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

wkempees
Posted: 03/06/2006, 2:15 PM

Also remove the " ; " in the next line 2 times.

alert ("You have a call back scheduled for" + CallTime;"With " + Contact + "
at " + Customer;"Phone #: " + Phone)

Now at least it seems error free.
No result yet though, onwards with my testing.

wkempees


Posts: 1679
Posted: 03/06/2006, 2:38 PM

Call your function in the Client Onload
not using function CallBacks()
but just CallBacks()


I don't have your variables but I put an
alert( date + day + month + year + hour + minute ) just before your CallDate= line and it displays nicely

Rest is up to you unless I find something else.



_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
Don_S

Posts: 50
Posted: 03/06/2006, 3:07 PM

This code is killing me!
I still can not get it to work... I have gutted the code to pull the data from the DB and I still get a Syntax Error on the load. It's not running the function.
Help!!!
I've created a fresh page to see if that was the issue... still nothing works. I have no idea what I have done wrong at this point.

Don
View profile  Send private message
wkempees


Posts: 1679
Posted: 03/06/2006, 3:10 PM

Having the same problem, it's like it's being destroyed.
Bare or Bear with me.

_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
wkempees


Posts: 1679
Posted: 03/06/2006, 3:14 PM

In the page events
Client->On Load->Custom Code
  
//page_OnLoad @1-D0F4E1D3  
function page_OnLoad()  
{  
    var result;  
//End page_OnLoad  
  
//Custom Code @37-2A29BDB7  
    // -------------------------  
    // Write your own code here.  
    // -------------------------  
	CallBacks();  
//End Custom Code  
  
//Close page_OnLoad @1-BC33A33A  
    return result;  
}  
//End Close page_OnLoad  
  


_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
wkempees


Posts: 1679
Posted: 03/06/2006, 3:17 PM

in HTML mode find <body>
on the next line put
  
  
<script language="JavaScript" type="text/javascript">  
function CallBacks()  
{  
	alert ("function CallBacks");  
  
	date = new Date();  
	day = date.getDate();  
	month= date.getMonth() +1;  
	year= date.getYear();  
	hour = date.getHours();  
	minute= date.getMinutes();  
	c=":";  
	s="/";  
  
	alert ( date + day +month + year + hour + minute);  
  
	CallDate = document.getElementById("CallDate").value;  
	CallTime = document.getElementById("CallTime").value;  
	Customer = document.getElementById("Customer").value;  
	Contact = document.getElementById("Contact").value;  
	Phone = document.getElementById("Phone_Nbr").value;  
	TestHour=hour;  
	Testmin=minute;  
	if (minute <10)  
	{  
		minute = "0" + minute;  
	}  
  
	if (minute - 15 < 0)  
	{  
		Testhour=hour- 1;  
		Testmin= 45 + minute;  
	}  
  
	Date= month + s + day + s + year;  
	Time= hour + c + minute;  
	TestTime= Testhour + c + Testmin;  
  
	alert ( "hoi : " + TestTime );  
  
	if (CallTime >= TestTime)  
	{  
		alert ("You have a call back scheduled for" + CallTime + "With " + Contact + "at " + Customer + "Phone #: " + Phone);  
	}  
}  
</script>  
  
Please not and adept all the ";"

Now if you open the page it should at least display the alerts two times.

Get there first


_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
Don_S

Posts: 50
Posted: 03/06/2006, 3:33 PM

ok, that much worked.
Got the two alerts. I am trying to add the function to my "Before Show" event on my grid...will keep you posted.

Don
View profile  Send private message
wkempees


Posts: 1679
Posted: 03/06/2006, 3:33 PM

Don
I did the above, and still it will run in the "Live Page" about 3 or 4 runs, then it quits functioning.
I close CCS.
Restart CCS, open the project go to the page click Live Page and it works again.

Script still not flawless check CamelCaps for :
Testhour, Testmin if it is Testminute change it back to Testmin

Am not giving up yet



_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
wkempees


Posts: 1679
Posted: 03/06/2006, 3:37 PM

This is all correct syntaxwise but I haven't got the Document fields
so Go4it Don, I'll be there for another 20 minutes as I am at GMT+1
  
  
<script language="JavaScript" type="text/javascript">  
function CallBacks()  
{  
	alert ("function CallBacks");  
  
	date = new Date();  
	day = date.getDate();  
	month= date.getMonth() +1;  
	year= date.getYear();  
	hour = date.getHours();  
	minute= date.getMinutes();  
	c=":";  
	s="/";  
  
	alert ( date + day +month + year + hour + minute);  
  
	CallDate = document.getElementById("CallDate").value;  
	CallTime = document.getElementById("CallTime").value;  
	Customer = document.getElementById("Customer").value;  
	Contact = document.getElementById("Contact").value;  
	Phone = document.getElementById("Phone_Nbr").value;  
	Testhour=hour;  
	Testmin=minute;  
  
	alert ( Testhour + Testmin);  
  
	if (minute <10)  
	{  
		minute = "0" + minute ;  
	}  
  
	if (minute - 15 < 0)  
	{  
		Testhour=hour- 1;  
		Testmin= 45 + minute;  
	}  
  
	Date= month + s + day + s + year;  
	Time= hour + c + minute;  
	TestTime= Testhour + c + Testmin;  
  
	alert ( "hoi : " + TestTime );  
  
	if (CallTime >= TestTime)  
	{  
		alert ("You have a call back scheduled for" + CallTime + "With " + Contact + "at " + Customer + "Phone #: " + Phone);  
	}  
}  
</script>  
  
  

_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
Don_S

Posts: 50
Posted: 03/06/2006, 3:49 PM

The code works fine as long as I dont try to add it to the Server side "Before Show" event, as soon as I do that It crashes... I get "Expected end of statement" error message.

Don
View profile  Send private message
wkempees


Posts: 1679
Posted: 03/06/2006, 4:09 PM

It is JavaScript, expects to be run Client Side not Server Side


_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
wkempees


Posts: 1679
Posted: 03/06/2006, 4:12 PM

I've got it nearly working also, just have to get my element id's in order.
Which is rather hard.
Do you need further assistance, as I stated earlier
CallBacks should be in CustomCode Clientside On Load for the page or because you are in a Grid situation some analogue position for a Grid.
Too much for me to do the grid example, but if you could post back when succeeded would be appreciated.
Did you put all the " ; " in place?


_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
Don_S

Posts: 50
Posted: 03/06/2006, 4:23 PM

I did put all the ";" in place. How can I get this to work with the grid as it loads? What do you mean by "some analogue position"? I can feel we almost have this just need that last step. BTW thanks for all your hekp and time with this.
Don
View profile  Send private message
wkempees


Posts: 1679
Posted: 03/06/2006, 4:47 PM

Well I am working your code in a record form.
Im at 99,9 percent.
Analouge position, some place client side that fires for every row in your grid, when you refresh the page.
Not tested, but I think you'll have to use the page client onload but have to itterate through all the rows, by ???? a loop through getElementById ???
Takes some experimenting but I'll have a look at it.

BTW http://www.irt.org/articles/java.htm is where I got most of it on the fly.
I am honestly not a JS pro, just tried and tested your code step by step by putting lots of alerts in it.
Googled my way through right now %-)

I'm now struggling to get your final test together (the last IF statement) and then I am done and learned a lot.
FI the "id" of a label/textbox and so on is not filled in automatically I had to do them one by one, should be generated from the textbox name or so.
Wishes, Wishes, Wishes.
it's 01:30 here so I am breaking up a bit.


_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
wkempees


Posts: 1679
Posted: 03/06/2006, 4:57 PM

OK mine is working.
It was the CallBack hour testing against the Testhour
You make the minutes display as 05 if smaller than 10.
I did the same with the hours mine was 01:55 testing >= 1:23, failed
but 1:55 did just fine.

I am done for today, tomorrow I'll (maybe) have a look at itterating the grid.
Somehow I have a feeling that this could be solved in an easier way, like displaying a grid in which through SQL select only records are displayed within a fifteen minute time frame, executing the select by using the autorefresh coding on the page, you already had installed.
At least that is the way I do it in one of my applications handling the case load for an employee, based on selecting all appointment overdue or due today, which could be easily adapted to a time based version.

But hey, as I said, learned a lot that I can apply to my planned Xajax/CCS experiment.

Don, friend, GoodNight!

;-)


_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
wkempees


Posts: 1679
Posted: 03/06/2006, 4:59 PM

The SQL version, I would have solved in approx 7.125432 seconds.

_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
Don_S

Posts: 50
Posted: 03/07/2006, 9:08 AM

I'm still not getting this to work. What would your SQL solution be? I dont care how I get there as long as it works in the end.

thanks,
Don
View profile  Send private message
wkempees
Posted: 03/07/2006, 1:36 PM

Don,

Objective:
To show user Callback events due within the next 15 minutes.
Defined as CallDate and CallTime have to be, in time, before the current
time + 15 minutes.
Question is how to recognize which are allready done.
DoneCheckBox is a checkbox to be set when callback has been done, or is set
when a Note is added or whatever method you desire.

Method:
Display a Grid containing CallDate, CallTime, Contact name, Customer Name,
Phone Number, DoneCheckBox.
The Page displaying the grid has an autorefresh set in the META, refreshing
every 3 minutes
The Grids SQL will be fired when the page is refreshed.


SQL:
SELECT CallDate, CallTime, ContactName, CustomerName, Phone_Nbr,
DoneCheckBox
FROM <tablename>
WHERE Concat(CallDate," ",CallTime,":00") < = DATE_ADD(NOW(), INTERVAL 15
MINUTE)
AND DoneCheckBox <> 1

That should do it.
Assuming CallDate to be a string or date, Calltime to be a string.
Alter the SQL to suit your field definition.

Walter

Don_S

Posts: 50
Posted: 03/07/2006, 2:24 PM

I like that approach, but I am getting a SQL Error ""Concat' is not a recognized function name"

any ideas?

Don
View profile  Send private message
Don_S

Posts: 50
Posted: 03/07/2006, 2:27 PM

This is the SQL I'm Using taken from CCS

SELECT *
FROM tbl_Call_Backs
WHERE ( Concat(CallDate," ",CallTime,":00") < = DATE_ADD(NOW(), INTERVAL 15 ) )

Don
View profile  Send private message
wkempees
Posted: 03/07/2006, 3:14 PM

What SQL Database ?
MS SQL use +
MySQL use concat() or concat_ws() or check the manual for concatenation


"Don_S" <Don_S@forum.codecharge> schreef in bericht
news:9440e08bf46c11@news.codecharge.com...
> This is the SQL I'm Using taken from CCS
>
> SELECT *
> FROM tbl_Call_Backs
> WHERE ( Concat(CallDate," ",CallTime,":00") < = DATE_ADD(NOW(), INTERVAL
> 15 ) )
>
>
> Don
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

wkempees
Posted: 03/07/2006, 3:20 PM


Sometimes it is necessary to concatenate the retrieved results from several
different fields from a table, and each database provides a way to do this.

a.. MySQL: CONCAT()
b.. Oracle: CONCAT(), ||
c.. SQL Server: +
The syntax for CONCAT() is as follows:

CONCAT(str1, str2, str3, ...): Concatenate str1, str2, str3, and any any
other strings together. Please note the Oracle CONCAT() function only allows
two arguments -- only two strings can be put together using this function.
However, it is possible to concatenate more than two strings at a time in
Oracle using '||'.

MySQL: Concat_ws()

CONCAT_WS(str1, str2, str3, ...): Concatenate str2, str3, and any any other
strings together, separated by str1.

MySQL/Oracle:
SELECT CONCAT(region_name,store_name) FROM Geography
WHERE store_name = 'Boston';

Oracle:
SELECT region_name || ' ' || store_name FROM Geography
WHERE store_name = 'Boston';

SQL Server:
SELECT region_name + ' ' + store_name FROM Geography
WHERE store_name = 'Boston';

MySQL/Oracle:
SELECT CONCAT(region_name,store_name) FROM Geography
WHERE store_name = 'Boston';

Result:

'EastBoston'




Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.