Javascript get parent

rfazendeiro

Centurion
Joined
Mar 8, 2004
Messages
110
Hi to all.

I have this code in javascript

Code:
var panels = new Array('panel1', 'panel2', 'panel3', 'panel4');

var selectedTab = null;
function showPanel(tab, name)
{
	if (selectedTab)
	{
		selectedTab.style.backgroundColor = '';
		selectedTab.style.paddingTop = '';
		selectedTab.style.paddingBottom = '';
	}
	selectedTab = tab;
	selectedTab.style.backgroundColor = 'white';
	selectedTab.style.paddingTop = '6px';

	for(i = 0; i < panels.length; i++)
	{
		document.getElementById(panels[i]).style.display = (name == panels[i]) ? 'block':'none';
	}

	return false;
 }

this code alows me to have a simple tab implementation. I then have a series of DIV that alow me tro control the tabs

Code:
<div class="panel" id="panel1" style="DISPLAY: none">
<td>Nome da Campanha:</td>
<td><asp:textbox id="txtPromoName" runat="server"></asp:textbox></td>
<td><asp:requiredfieldvalidator id="valPromoName" Display="Dynamic" EnableViewState="False" ErrorMessage="Preencha o campo" ControlToValidate="txtPromoName" Runat="server"></asp:requiredfieldvalidator></td>
</div>

<div class="panel" id="panel2" style="DISPLAY: none">
    ...
</div>

<div class="panel" id="panel3" style="DISPLAY: none">
    ...
</div>

<div class="panel" id="panel4" style="DISPLAY: none">
    ...
</div>

What i'm doing is there are validators in all div's and when there is an error i need to jump to to that div and to show the error. for examle let imagin that a user is filling the form in tab1 and submits the form, there is an error in tab3. So i wanna change the tab to tab3. here the code i have so far

Code:
 function CheckValidatorErrors() 
 {
	var val
	var parent = null;
	for(i=0;i< Page_Validators.length;i++) 
	{ 					
		if (!Page_Validators[i].isvalid)
		{
			val = Page_Validators[i];
                
                           //This the part that i'm missing
                           //Find the div that val is in and call
                           // the function showPanel
                         }
	}
}


any ideias on how to do this?

thx to all
 
Back
Top