Page 1 of 1

Query strings and JavaScript?

Posted: Sat Jul 07, 2007 11:20 pm
by cturner
Can someone please tell me how I can make a query string in JavaScript?

I want the following to be changed to a query string:

Code: Select all

      var y = calendar.date.getFullYear();
      var m = calendar.date.getMonth();     // integer, 0..11
      var d = calendar.date.getDate();      // integer, 1..31
      // redirect...
      window.location = "/" + y + "/" + m + "/" + d + "/calendar.php";
Thanks in advance.

Posted: Sat Jul 07, 2007 11:29 pm
by feyd
How is it supposed to change?

Posted: Sat Jul 07, 2007 11:39 pm
by cturner
The code comes from a calendar and when someone clicks on a day it is suppose to go to another page. I need it to go to another page so the other page can display some information for that date.

Posted: Sat Jul 07, 2007 11:43 pm
by cturner
I have solved it myself. The solution is:

Code: Select all

window.location = "calendar.php?day=" + d + "&month=" + m + "&year=" + y;
for anyone that needs to know.