Código:
aqui las creo el primer arreglo es de pestanas verticales y le segundo de pestanas horizontales, ambos apuntando al mismo contenedor.<script language="javascript" type="text/javascript"> cargado = function () { menuTabshorizontal = new tabPrincipal (0, "div_01", 0, "btnGdeActivo", "btnGdeNoActivo"); menuTabs2.agregaTab("tab02_1","ahah_1.html", null); menuTabs2.agregaTab("tab02_2","tabPrincipal/mapa.html", null); menuTabs2.agregaTab("tab02_3","ahah_2.html", null); menuTabs2.agregaTab("tab02_4","ahah_4.html", null); menuTabs2.crear(); menuTabsvertical = new tabPrincipal (1, "div_01",0, "tabActivo", "tabNoActivo"); menuTabs1.agregaTab("tab01_1","ahah_1.html", null); menuTabs1.agregaTab("tab01_2","ahah_2.php", null); menuTabs1.agregaTab("tab01_3","tabPrincipal/mapa.html", null); menuTabs1.agregaTab("tab01_4","ahah_4.html", null); menuTabs1.crear(); <!-- arreglo para pestanas --> } </script>
la pagina va dirigida a un catalago de productos, el menu vertical indica el nombre del producto y las pestañas hoizontales, indican 4 caratersiticas de dicho producto, por lo que es necesario que al dar click en un producto x, las pesta►4as horizontales (menuTabshorizontal) se inicializen en la primera pestaña, el paramtero que indica en cual pestaña empiezan esta en la tercera posicion de "new tabPrincipal (0, "div_01", 0, "btnGdeActivo", "btnGdeNoActivo");" en este caso las dos empiezan en cero, el sigueinte java script regula el funcionamiento de este sitema:
Código:
function tabPrincipal (id, destino, activa, estiloActivo, estiloInactivo) { this.menuSel = null; this.id = id; this.destino = destino; this.activa = activa; this.cssActivo = estiloActivo; this.cssInactivo = estiloInactivo; this.tabs = new Array(); }; tabPrincipal.prototype.crear = function () { for (var t = 0; t<= this.tabs.length-1; t++) { var tabTemp = document.getElementById(this.tabs[t].id); tabTemp._parent = this; tabTemp._recurso = this.tabs[t].recurso; tabTemp._funcion = this.tabs[t]._funcion; tabTemp._funcion2 = this.tabs[t]._funcion2; tabTemp.onclick = function () { this._parent.peticionMenu(this, this._recurso, this._funcion, this._funcion2); return false; } } if (this.activa >= 0) { this.peticionMenu(document.getElementById(this.tabs[this.activa].id),this.tabs[this.activa].recurso); } }; tabPrincipal.prototype.agregaTab = function (id,recurso, funcion, funcion2) { var tabTemp= new Object(); tabTemp.id = id; tabTemp.recurso = recurso; tabTemp._funcion = funcion; tabTemp._funcion2 = funcion2; this.tabs.push(tabTemp); } tabPrincipal.prototype.peticionMenu = function (celda, recurso, funcion, funcion2) { oThis = this; if (celda != false) { this.menuOut(celda); } this.despliegaInfo("</br><img src='images/cargando.gif' width='20' height='20' />Cargando información</br>"); var oXMLHttp = zXmlHttp.createRequest(); oXMLHttp.open("get", recurso, true); oXMLHttp.onreadystatechange = function () { if (oXMLHttp.readyState == 4) { if (oXMLHttp.status == 200) { oThis.despliegaInfo(oXMLHttp.responseText, funcion, funcion2); }else { oThis.despliegaInfo("Ocurre un error de comunicación: "+ oXMLHttp.statusText) } } } document.documentElement.scrollTop = 0; oXMLHttp.send(null); } tabPrincipal.prototype.menuPress = function (celda) { celda.className = this.cssInactivo; } tabPrincipal.prototype.menuOut = function (celda) { if (this.menuSel != null) this.menuPress (this.menuSel); celda.className = this.cssActivo; this.menuSel = celda; } tabPrincipal.prototype.despliegaInfo = function (contenido, funcion, funcion2) { var divR = document.getElementById(this.destino); divR.innerHTML = contenido; if (funcion != null || funcion != undefined) { funcion(); } if (funcion2 != null || funcion2 != undefined) { funcion2(); } } /************************************************************/
el parametro se llama "activa", entonces yo tengo horas buscando como decirle a mi funcion que cuando de click en las pestañas verticales , las horizontales se inicializen en la pestaña cero, ya intenete en le menuOut y le menuPress, poniendo por ejemplo :
Código:
pero pues obvio esta mal, yo solo quiero saber de que forma puedo accesara ese parametro por medio de un click del mouse. es decir que cuando yo cambie de producto en el menu vertical, el menu horizontal se inicialize ne la pestaña numero 1.tabPrincipal.prototype.menuPress = function (celda) { celda.className = this.cssInactivo; menuTabs2.Activa =0; }
espero alguien me pueda ayudar un poco y gracias!!