Javascript/html code bug assistance needed

error77
error77 used Ask the Experts™
on
Hi all,

I am having trouble with this code:

<a href="#"  onclick="javascript:window.location.href = 'index.php?month=' +thisyear+'-1-1'" rel="external"> Link here</a>

For some reason it's not working ... Is there a syntax error somewhere?

THanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Mohamed AbowardaSenior Software Engineer

Commented:
The problem because thisyear is undefined, you must define it inside javascript code.

Author

Commented:
I have defined it in the head of my page.

Here's the code I used.
<script>
    var thisyear = new Date().getFullYear();
</script>

Hope this helps

Thanks
Senior Software Engineer
Commented:
I have tested your code and it's working perfectly, if you still have a problem, post the error message and your full html file so I can help you further.

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