Reputation: 936
I have the following piece of javascript on one of my pages
<script type="text/javascript">
var state = 'none';
function showhide(layer_ref, badgeid, location) {
alert("Run")
if (state == 'block') {
state = 'none';
}
else
{
state = 'block';
}
hza = document.getElementById(layer_ref);
hza.style.display = state;
if (state == 'block') {
badgeinfo(badgeid, location);
}
}
</script>
its called using
<td width="50%" align="right" valign="middle" onclick="showhide('id215', '215', 'req_215');"><img src="/images/badges/2015be-cs-csa.png" width="100" height="100" alt="Chief Scout's Bronze Award" /></td>
One on page its loads fine, i get the alert when i click the image, but on another page, nothing happens, the alert isn't shown.
The page is dynamically produced based on a couple of variables which define what section is loaded. Even if i change the javascript function to just the alert it doesn't do anything. If i change the section of the badges in the database so they load on another page its fine, and previously working badges if they are on this section don't load
This is the non working page http://new.wgcscouts.co.uk/test1.php
And this is a working one http://new.wgcscouts.co.uk/test2.php
Upvotes: 0
Views: 72
Reputation: 58521
In the working example, there is an index number appended to the section url...
url=url+"&section="+1;
The number at the end of line 51 is not being populated in the non-working example
url=url+"&section="+;
That is a syntax error for javascript, which then stops executing as it can't parse the input.
Upvotes: 1