So basically, I am wondering whats wrong here.... I have 4 links inside table cells and each has a class assigned. the tab that is active is assigned "sel" while the others are "nav" ... what i'm trying to do is have them switch classes without changing the page using javascript. I did some ugly code below since i don't completely know javascript. Each link is currently linked to activate(id) where id is like link1 for one, link2 for another, depending on their ID.
What i want to happen is if Link1's tab is selected, and they click link2's tab, i want link 1's tab to become unselected and back to nav class and link2's tab selected and on the sel class. i tried below but somethings wrong, can someone find my error and/or make not-****ty code that will work for this? thx.
EDIT: heres the code each link has below, except link1 is replaced with link2 and so-on and so-forth. below it is my updated code. It still doesn't work. see any bugs?
the links code
<td width="25%" class="sel" onclick="activate('link1')" style="cursor:pointer" id="link1"><div align="center" class="style20 style18"><strong>Home</strong></div></td>
the function
<script type="text/javascript">
function activate(link){
if(link=='link1') {
document.link1.className = 'sel';
document.link2.className = 'nav';
document.link3.className = 'nav';
document.link4.className = 'nav';
}
if(link=='link2') {
document.link1.className = 'nav';
document.link2.className = 'sel';
document.link3.className = 'nav';
document.link4.className = 'nav';
}
}
</script>