Hello, and again, I have a simple code that for a reason of it's own, it doesn't decide to work...
Code:
<script type="text/javascript">
function ChangeView(a,b) {
document.b.style.color=a;
}
</script>
<a class="viewbutton" onclick="ChangeView('white,historydiv');">History</a>
<div id="historydiv">
History Div
</div>
All that should do (but it doesn't) is first have a script that contains a function called ChangeView, that uses values 'a' and 'b'. Then there's a simple link that onclick, passes the values 'white' and 'historydiv' to the script, which should turn 'historydiv''s text white.
But it doesn't.
I've been at this for a long time now, all over the place, and I've gotten it to change historydiv if I specify it in the script, like this:
Code:
function ChangeView(a) {
document.historydiv.style.color=a;
}
But I want it to be able to do it from script, so I don't have to make millions of these to accommodate my million (much less) divs.
I have no idea what the problem of the code it (the first one). Am I missing some single quotes or something stupid like that? No error messages, just not working...
And BTW, there is no CSS for my historydiv. No fixed styles.
Last edited by Physicsguy; 12-07-2009 at 08:07 PM..
|