2
I have a menu that if the user selects the option it will change, etc! The problem is that it leaves all other programs open when accessing one.
Menu:
<body onLoad="AlternarAbas('td_usua','div_usua')">
<table width="945" height="50" align="left" valign="top" cellspacing="0" cellpadding="5" border="0" style="border-left: 1px solid #000000;" >
<tr>
<td height="20" width="50" class="menu" id="td_usua" onClick="AlternarAbas('td_usua','div_usua')">Usuario</td>
<td height="20" width="50" class="menu" id="td_empr" onClick="AlternarAbas('td_empr','div_empr')">Empresa</td>
<td height="20" width="50" class="menu" id="td_nota" onClick="AlternarAbas('td_nota','div_nota')">Nota Fiscal</td>
<td height="20" width="50" class="menu" id="td_soft" onClick="AlternarAbas('td_soft','div_soft')">Software</td>
</tr>
Alternarabas:
function AlternarAbas(menu,conteudo)
{
for (i=0;i<arAbas.length;i++)
{
m = document.getElementById(arAbas[i].menu);
m.className = 'menu';
c = document.getElementById(arAbas[i].conteudo)
c.style.display = 'none';
}
m = document.getElementById(menu)
m.className = 'menu-sel';
c = document.getElementById(conteudo)
c.style.display = '';
}
arAbas:
var arAbas = new Array();
arAbas[0] = new stAba('td_usua','div_usua');
arAbas[1] = new stAba('td_empr','div_empr');
arAbas[2] = new stAba('td_nota','div_nota');
arAbas[3] = new stAba('td_soft','div_soft');
stAba:
function stAba(menu,conteudo)
{
this.menu = menu;
this.conteudo = conteudo;
}
So I thought I’d use the switch
or (if..else)
to change the selection mode. That is, it will only open a certain area when it is accessed. But I have no idea how to implement .. Any suggestions or tips?
Even posting an answer, I would like to know at least whether there is a way to do using the switch
or the (if..else)
!
I don’t understand :( @Felipe - create a jsfiddle
– Jefferson Alison
Cool @Felipe, but I didn’t understand it like that.. What do you want when you click it to be active? Something like this?
– Jefferson Alison
@Jeffersonalison, my problem is that when I select a tab, it brings the contents of the other tabs together. ie, they remain open! I wish that when selecting a tab, only it has content and the others remain blank!
– Felipe