![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
30/09/2009, 16:44
|
| | Fecha de Ingreso: septiembre-2009
Mensajes: 2
Antigüedad: 15 años, 4 meses Puntos: 0 | |
Respuesta: Problemas con select y javascript Cita:
Iniciado por zerokilled ¿que evento estas usando? asumo que onclick pero lo correcto seria onchange en el <select>. si estoy usando onchange. Cita: <select id="lstpasi" name="lstpasi" onchange="gettpasi(); verifyMatSelected(); updateImageSrc(1)" style="width:158px;">
<option value="" selected="selected">Sin Paspartu</option>
<option value="1">True - White</option>
<option value="2">Ivory</option>
<option value="3">Artic - Pearl</option> el javascript que uso para esta parte es: Cita: function verifyMatSelected() {
bottomMat = document.f1.lstpasi;
if (bottomMat.selectedIndex == 0 || bottomMat.options[bottomMat.selectedIndex].value == "") {
return false;
} else {
return true;
}
} Cita: function updateImageSrc(type, f, sku, name) {
if (!f) f = document.forms[0];
if (f.imgSrc) {
var src = f.imgSrc.src;
if (!sku) {
if (type && type == 1 && f.lstpasi.selectedIndex != 0)
sku = f.lstpasi.options[f.lstpasi.selectedIndex].value;
else if (type && type == 2 && f.topmatcolor.selectedIndex != 0)
sku = f.topmatcolor.options[f.topmatcolor.selectedIndex].value;
else sku = "";
}
if (!name) {
if (type && type == 1 && f.lstpasi.selectedIndex != 0) name = f.lstpasi.options[f.lstpasi.selectedIndex].text;
else if (type && type == 2 && f.topmatcolor.selectedIndex != 0) name = f.topmatcolor.options[f.topmatcolor.selectedIndex].text;
else name = " ";
}
if (hasBorders(type, f)) {
// change mat sku in image url
if (src.indexOf("&mat"+type) == -1) src += ("&mat"+type+"="+sku);
else {
src = src.substring(0, src.indexOf("&mat"+type)+6) + sku + "&" + src.substring(src.indexOf("&mat"+type)+6);
}
// add mat borders to image url
if (src.indexOf("&t=")==-1 && src.indexOf("&l=")==-1 && src.indexOf("&r=")==-1 && src.indexOf("&b=")==-1) {
f.submit();
}
// set border to 0 if no mat is selected
if (type && type == 1 && f.lstpasi.selectedIndex == 0) {
setValueOf( f.matTopI, f.matTopF, 0 );setValueOf( f.matBotI,f.matBotF, 0 );
setValueOf( f.matLeftI,f.matLeftF, 0 );setValueOf( f.matRightI,f.matRightF, 0 );
f.topmatcolor.selectedIndex = 0
setValueOf( f.matOffI, f.matOffF, 0 );
f.submit();
} else if (type && type == 2 && f.topmatcolor.selectedIndex == 0) {
setValueOf( f.matOffI, f.matOffF, 0 );f.submit();
}
f.imgSrc.src = src;
} else {
if (type == 1) {
setValueOf( f.matTopI, f.matTopF, 16 );setValueOf( f.matBotI,f.matBotF, 16 );
setValueOf( f.matLeftI,f.matLeftF, 16 );setValueOf( f.matRightI,f.matRightF, 16 );
} else if (type ==2) {
setValueOf( f.matOffI, f.matOffF, 4 );
}
f.submit();
}
}
changeHtmlString("mat"+type, name);
} Parte del popup donde actualiza la seleccion del select es esto: Cita: <table cellspacing="4" border="0" cellpadding="0">
<tr>
<td width="110" valign="top" align="center"><a style="text-decoration:none" onclick="return updateMatColor(1,'1',1,'True - White')" href="#"> <img src="images/1.jpg"> <br>
True - White</a> </td> y su javascript es: Cita: function updateMatColor(index, sku, type, name) {
var i
if (self.opener.document.forms[0].lstpasi) i =0;
else i = 1;
if (type == 1) {
matSel = self.opener.document.forms[i].lstpasi;
} else {
matSel = self.opener.document.forms[i].topmatcolor;
}
if (matSel.selectedIndex.value != sku) {
for ( var j =0; j < matSel.length; ++j) {
if (sku == matSel[j].value) {
matSel.selectedIndex = j;
}
}
}
if (self.opener.document.forms[0].imgSrc) {
updateImageSrc( type, self.opener.document.forms[0], sku, name);
}
if (!document.forms[0].keepOpen || !document.forms[0].keepOpen.checked) self.close();
return false;
} NOTA: Aclaro que los js son fragmentos de codigos que encontre por ahi y los adapte a mis necesidades.
lo que en si me falta es que cuando escojan una imagen del popup la seleccion del select se actualice y me cambie la imagen.
PD: Esto no es span pero dejo la pagina para que me puedan ayudar un poco mejor Cita: w ww.newartis. com/french. php |