Link to home
Avatar of error77
error77

asked on

Javascript/html code bug assistance needed

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
Avatar of Brad Brett
Brad Brett
Flag of United States of America image

The problem because thisyear is undefined, you must define it inside javascript code.
Avatar of error77
error77

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of Brad Brett
Brad Brett
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial