Tengo esta funcion:
Código HTML:
function getById(id){ return document.getElementById(id); } function switchImage(){ var selection = getById('listimagen'); var pic = getById('picimagen'); var btn = getById('eliminar'); if(selection.value == "seleccionar"){ pic.setAttribute('src','../imagenes/none.gif'); btn.style.visibility = "hidden"; }else{ pic.setAttribute('src',selection.options[selection.selectedIndex].value); btn.style.visibility = "visible"; } }
Código HTML:
<tr> <td class="padding" align="right">Listado imágenes:</td> <td class="padding"> <select name="listimagen" size="1" id="listimagen" onchange="javascript:getValue(); return switchImage();"> <option value="seleccionar" selected>Seleccionar ...</option> <option value="d:/www/virtual3d//imagenes/EvangelineLilly_04_1024.jpg">EvangelineLilly_04_1024.jpg</option> <option value="d:/www/virtual3d//imagenes/EvangelineLilly_09_1024.jpg">EvangelineLilly_09_1024.jpg</option> <option value="d:/www/virtual3d//imagenes/evangeline_lilly008z.jpg">evangeline_lilly008z.jpg</option> </select> </td> </tr> <tr> <td> </td> <td valign="top"> <img src="../imagenes/none.gif" width="100" id="picimagen" alt="Click para ampliar imagen" class="cursor"> <div id="eliminar" style="visibility: hidden;"> <input type="hidden" name="direcccion" id="direcccion"> <input type="button" name="eliminar" value="Eliminar" onclick="javascript: return deleteFile();"></div> </td> </tr>
Salu2