add date into url as parameter

Mark Drelinger
Mark Drelinger used Ask the Experts™
I have the following script that redirects a user to a web site.
I need to add yesterday's date to the end as paramater txtStartDate, i format 03/04/2014.  This way, each time someone clicks the link, the resulting page is already filtered for them.

<script type="text/javascript">
window.location.href = ""
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Big MontyWeb Ninja at large

of course, to format it, you'll need to come up with some code for that as well:

<script type="text/javascript">
function getTommorrowsDate() {
var newDate = new Date() - 1;
var dd = newDate;
var mm = newDate.getMonth();

var yyyy = newDate.getFullYear();
if( dd< 10){ dd='0'+dd }
if( mm < 10){ mm='0'+mm }
return = mm+'/'+dd+'/'+yyyy;

window.location.href = "" + getTommorrowsDate()

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial