For my website I had to add javascript with my PHP site in order to get the anchor tag from the current page. This in order to compare it to the id of an <span> tag in the page. Javascript is not my strong side. So of course the script doesn't work.This is the problem:
Here is my PHP/javascript code:
This code looks as folows in the source code of the page......
This all worked fine when I used document.write instead of the line styling the term....so the line.....
otherwise
.....is causing the trouble.
It looks fine to me...I have no idea what went wrong because the "Termname" does not turn red. Anyone have any ideas??
Thanx
Here is my PHP/javascript code:
Code:
$output .= "<script type=\"text/javascript\">
if( \"#term{$term->tid}\" == location.hash){
document.all[\"term{$term->tid}\"].style.color=\"red\"
</script>";
$output .= "<span id=\"term{$term->tid}\">{$term->name}</span>";
This code looks as folows in the source code of the page......
Code:
<script type="text/javascript">
if( "#term1" == location.hash){
document.all["term1"].style.color="red"
}
</script>
<span id="term1">Termname</span>
This all worked fine when I used document.write instead of the line styling the term....so the line.....
Code:
document.all[\"term{$term->tid}\"].style.color=\"red\"
Code:
document.all["term1"].style.color="red"
It looks fine to me...I have no idea what went wrong because the "Termname" does not turn red. Anyone have any ideas??
Thanx