views:

33

answers:

2

Hi
I have asp (classic) script and within javascript code. From database I get date in format yyyy-mm-dd (2010-10-14) and save in variable. Then, I pass this variable to javascript method:

Response.Write("<a href='Javascript: PassDate("&OurDate&","&Val1&","&Val2&");'>Pass</a>")

This method code is:

function PassDate(OurDate, Val1, Val2) { window.open("newsite.asp?date="+OurDate+"&val1="+Val1+"&val2="+Val2");

}

When I try get date on new site (newsite.asp) by Request.QueryString("date"), I get calculate value 1996 (2010-10-14 = 1986), instead date '2010-10-14'.
I try various ways to solve this problem, but it still calculate value.
For example, I try replace "-" for ".", but I get error about missing ")".
How could I solve this problem?
Thanks for help.

Regards

A: 

Have you considered saving the date using the javascript date object and then passing that to your method? My javascript is a little rusty, but I believe it would be something like the following:

var dateParts = split(OurDate, "-");
var myDate = new Date(dateParts[0], dateParts[1], dateParts[2]);
senloe
A: 

Use commas instead of dashes. That way, each part will be seen as a separate argument to the JavaScript function.

idealmachine
Thanks for reply. But how can I get all arguments - when I try: Response.Write(Request.QueryString("date")) I get only year: 2010?
luk4443
Surround it in square brackets, for example, [2010] or [2010,10,14] -- that way it will be seen as one argument (an array) to JavaScript (OurDate[0], OurDate[1], ...).
idealmachine
Thanks! It works. I have to only make: Replace(Request.QueryString("date"),",","-") and get date with dashes. Regards
luk4443