Foros del Web » Creando para Internet » HTML »

Mostrar imagen en celda tras obtener ruta desde base mysql mediante select option

Estas en el tema de Mostrar imagen en celda tras obtener ruta desde base mysql mediante select option en el foro de HTML en Foros del Web. ESTIMADOS AMIGOS NECESITO AYUDA URGENTE TENGO UN FORMULARIO DE ACTUALIZACION DE REGISTRO Y NECESITO QUE EL USUARIO AL SELECIONAR UN REGISTRO MUESTRE CIERTOS DATOS Y ...
  #1 (permalink)  
Antiguo 08/04/2011, 13:21
 
Fecha de Ingreso: julio-2003
Ubicación: Santiago
Mensajes: 26
Antigüedad: 20 años, 8 meses
Puntos: 0
Exclamación Mostrar imagen en celda tras obtener ruta desde base mysql mediante select option

ESTIMADOS AMIGOS NECESITO AYUDA URGENTE TENGO UN FORMULARIO DE ACTUALIZACION DE REGISTRO Y NECESITO QUE EL USUARIO AL SELECIONAR UN REGISTRO MUESTRE CIERTOS DATOS Y LA IMAGEN DE ESTE SEGUN LA RUTA OBTENIDA MEDIANTE EL SELECT OPTION, EL PROBLEMA ES QUE ME MUESTRA BIEN TODOS LOS DATOS DEL REGISTRO PERO NO LOGRO QUE ME MUESTRA LA IMAGEN Y ADEMAS NECESITO QUE SI AUN NO SELECCIONA NADA MUESTRE UNA IMAGEN POR DEFAULT

COMO PUEDO HACERLO PAR FAVOR ADJUNTO MI CODIGO :

<table width="100%" border="0" align="center">
<tr>
<form name="Formulario" method="post" action="actualizalink.php" enctype="multipart/form-data">
<tr>
<td style="font-family:Tahoma, Geneva, sans-serif; font-size:12px; color:#930; font-weight: bold;" width="140" height="20" align="left"><span class="Estilo6"><strong>Seleccionar Link</strong></span></td>
<td width="371">
<?php
$cadena = mysql_query("SELECT * FROM links ORDER BY id ASC",$link);
?>
<select name="selecnot" id="selecnot" onChange="codigo.value=this.options[this.selectedIndex].getAttribute('codigo');nombre.value=this.options[this.selectedIndex].getAttribute('nombre');vinculo.value=this.options[this.selectedIndex].getAttribute('vinculo');ruta.value=this.options[this.selectedIndex].getAttribute('ruta');!this.selectedIndex">
<option value="0" responsable="">Seleccione Link </option>
<?php
while ($row = mysql_fetch_assoc($cadena))
{
?>
<option value="<?php echo $row['id']?>"codigo="<?php echo $row['id']?>"nombre="<?php echo $row['nombre']?>"vinculo="<?php echo $row['vinculo']?>"ruta="<?php echo $row['ruta']?>" > <?php echo $row['nombre']?>
</option>
<?PHP
// GUARDO LA RUTA DE LA IMAGEN SELECCIONADA
$fotoactual = $row['ruta'];
}
?>
</select>
<label>
<input name="codigo" type="hidden" id="codigo" />
</label>
</td>
</tr>
<!-- AQUI QUIERO QUE SE MUESTRE LA IMAGEN QUE CORRESPONDE A LA OPCION ELEGIDA DEL SELECT -->
<tr>
<td style="font-family:Tahoma, Geneva, sans-serif; font-size:12px; color:#930; font-weight: bold;" width="140" align="left">Imagen Actual</td>
<td align="left">
<img name="fotolink" id="fotolink" src='<?php $fotoactual; ?>' alt="IMAGEN LINK" height='80' width='180' align='center' />
</td>
</tr>
<!-- fin de la muestra de imagen -->

<tr>
<td style="font-family:Tahoma, Geneva, sans-serif; font-size:12px; color:#930; font-weight: bold;" width="140" align="left">Nombre Link</td>
<td align="left"><input name="nombre" id="nombre" type="text" size="50" maxlength="50" style="font-family:Verdana, Geneva, sans-serif; font-size:11px; color:#F60;" onChange="ValNombre(this.value);"/></td>
</tr>
<tr>
<td style="font-family:Tahoma, Geneva, sans-serif; font-size:12px; color:#930; font-weight: bold;" align="left">Vinculo</td>
<td align="left"><input name="vinculo" id="vinculo" type="text" size="50" maxlength="50" style="font-family:Verdana, Geneva, sans-serif; font-size:11px; color:#F60;" onChange="ValVinculo(this.value);"/></td>
</tr>
<tr>
<td style="font-family:Tahoma, Geneva, sans-serif; font-size:12px; color:#930; font-weight: bold;" align="left">Ruta Imagen</td>
<td align="left">
<input name="ruta" type="text" id="ruta" value="" size="50" maxlength="50" style="font-family:Verdana, Geneva, sans-serif; font-size:11px; color:#F60;" />
</td>
</tr>
<tr>
<td style="font-family:Tahoma, Geneva, sans-serif; font-size:12px; color:#930; font-weight: bold;" width="292" align="left">Seleccionar nueva Imagen</td>
<td align="left"><input type="file" name="imagen" size="36"></td>
</tr>
<tr>
<td height="40" align="center"><input type="submit" name="act" value="Actualizar Link"/></td>
</tr>
</form>
</tr>
</table>
  #2 (permalink)  
Antiguo 08/04/2011, 14:39
Avatar de laratik  
Fecha de Ingreso: mayo-2010
Ubicación: Cali
Mensajes: 317
Antigüedad: 13 años, 10 meses
Puntos: 63
Respuesta: Mostrar imagen en celda tras obtener ruta desde base mysql mediante select

Hola plataformas, después de revisar tu código, veo que estas utilizando demasiado código dentro del manejador de eventos, para próximos proyectos, trata de que no sea así, ya que se hace muy difícil la lectura del código (a HTML lo que es de HTML y a javascript lo que es de javascript).

ERRORES

1. te falto un echo al mostrar la $imagenactual <?php echo $fotoactual; ?>

2. y mas imporatante, no estas modificando dentro del javascript para que se muestre una nueva imagen cada vez que cambias el select.

Referente a lo de tener una imagen por defecto creo que podrías manejarlo desde javascript para cuando sea index 0.

Código completo y corregido:

Código HTML:
<html> 
<head> 
<script type="text/javascript">
function r(sel) {
	if(sel.selectedIndex == 0) {
		document.getElementById("mostrar").src = "images/errorIcon.gif";
	}
	codigo.value=sel.options[sel.selectedIndex].getAttribute('codigo');
	nombre.value=sel.options[sel.selectedIndex].getAttribute('nombre');
	vinculo.value=sel.options[sel.selectedIndex].getAttribute('vinculo');
	ruta.value=sel.options[sel.selectedIndex].getAttribute('ruta');
	document.getElementById("mostrar").src = sel.options[sel.selectedIndex].getAttribute('ruta');
}

</script>
</head> 
<body> 
<ul> 
<table width="100%" border="0" align="center">
<tr>
<form name="Formulario" method="post" action="actualizalink.php" enctype="multipart/form-data">
<tr>
<td style="font-family:Tahoma, Geneva, sans-serif; font-size:12px; color:#930; font-weight: bold;" width="140" height="20" align="left"><span class="Estilo6"><strong>Seleccionar Link</strong></span></td>
<td width="371">
<?php
$link = mysql_connect("localhost","root","******");
mysql_query("SET NAMES 'utf8'"); //selecciona el cotejamiento de la base de datos
mysql_select_db("universidad",$link);
$cadena = mysql_query("SELECT * FROM links ORDER BY id ASC",$link);
?>
<select name="selecnot" id="selecnot" onChange="r(this)">
<option value="0" responsable="">Seleccione Link </option>
<?php 
while ($row = mysql_fetch_assoc($cadena))
{
?>
<option value="<?php echo $row['id']?>"codigo="<?php echo $row['id']?>"nombre="<?php echo $row['nombre']?>"vinculo="<?php echo $row['vinculo']?>"ruta="<?php echo $row['ruta']?>" > <?php echo $row['nombre']?>
</option>
<?PHP
// GUARDO LA RUTA DE LA IMAGEN SELECCIONADA
$fotoactual = $row['ruta'];
}
?>
</select>
<label>
<input name="codigo" type="hidden" id="codigo" />
</label>
</td>
</tr>
<!-- AQUI QUIERO QUE SE MUESTRE LA IMAGEN QUE CORRESPONDE A LA OPCION ELEGIDA DEL SELECT --> 
<tr>
<td style="font-family:Tahoma, Geneva, sans-serif; font-size:12px; color:#930; font-weight: bold;" width="140" align="left">Imagen Actual</td>
<td align="left">
<img id="mostrar" name="fotolink" id="fotolink" src='images/errorIcon.gif' alt="IMAGEN LINK" height='80' width='180' align='center' />
</td>
</tr>
<!-- fin de la muestra de imagen -->

<tr>
<td style="font-family:Tahoma, Geneva, sans-serif; font-size:12px; color:#930; font-weight: bold;" width="140" align="left">Nombre Link</td>
<td align="left"><input name="nombre" id="nombre" type="text" size="50" maxlength="50" style="font-family:Verdana, Geneva, sans-serif; font-size:11px; color:#F60;" onChange="ValNombre(this.value);"/></td>
</tr>
<tr>
<td style="font-family:Tahoma, Geneva, sans-serif; font-size:12px; color:#930; font-weight: bold;" align="left">Vinculo</td>
<td align="left"><input name="vinculo" id="vinculo" type="text" size="50" maxlength="50" style="font-family:Verdana, Geneva, sans-serif; font-size:11px; color:#F60;" onChange="ValVinculo(this.value);"/></td>
</tr>
<tr>
<td style="font-family:Tahoma, Geneva, sans-serif; font-size:12px; color:#930; font-weight: bold;" align="left">Ruta Imagen</td>
<td align="left">
<input name="ruta" type="text" id="ruta" value="" size="50" maxlength="50" style="font-family:Verdana, Geneva, sans-serif; font-size:11px; color:#F60;" />
</td>
</tr>
<tr>
<td style="font-family:Tahoma, Geneva, sans-serif; font-size:12px; color:#930; font-weight: bold;" width="292" align="left">Seleccionar nueva Imagen</td>
<td align="left"><input type="file" name="imagen" size="36"></td>
</tr>
<tr>
<td height="40" align="center"><input type="submit" name="act" value="Actualizar Link"/></td>
</tr>
</form>
</tr>
</table>
</body> 
</html> 
Creo que la parte de $fotoactual = $row['ruta']; sobra si lo piensas manejar con una imagen por defecto.
__________________
Programar apasiona y lo que apasiona es un arte, por lo tanto programar es un arte.

Quiero karma para en mi próxima vida ser un billonario bien dotado con alas.
  #3 (permalink)  
Antiguo 08/04/2011, 15:12
 
Fecha de Ingreso: julio-2003
Ubicación: Santiago
Mensajes: 26
Antigüedad: 20 años, 8 meses
Puntos: 0
Exclamación Respuesta: Mostrar imagen en celda tras obtener ruta desde base mysql mediante select

Gracias amigo pero me esta dando 2 errores

Detalles de error de página web 1

Agente de usuario: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; InfoPath.2; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E)
Fecha: Fri, 8 Apr 2011 20:59:31 UTC


Mensaje: 'codigo' is undefined
Línea: 65
Carácter: 2
Código: 0
URI: http://www.bto.cl/editalink.php?&SID=14f42afa7537582a7d3544543222569 d

DETALLE ERROR 2
<img id="mostrar" name="fotolink" id="fotolink" src='fotol/default.jpg' alt="IMAGEN LINK" height='80' width='180' align='center' />

me lo muestra como error

y el codigo ya con el tuyo embebido
es :

<?PHP
// CONECTAMOS A LA BASE DE DATOS
include("conexion.php");
$link=Conectarse();
?>



adjunto el godigo que me enviaste con las modificaciones la variable $link la tengo definida al principio por lo solo la invoco dentro de tu codigo.



esto esta en el HEAD
<script language="JavaScript" type="text/JavaScript">
// FUNCION VALIDA FECHA EN BLANCO
function ValNombre(pCampo)
{
// Verifica si no esta en blanco
if (pCampo == "")
{ alert("EL NOMBRE DEL LINK NO PUEDE ESTAR EN BLANCO");
document.Formulario.nombre.focus();
return false;
}
// Devuelve validación sin errores
return true;
}
// VALIDA TITULO EN BLANCO
function ValVinculo(pCampo)
{
// Verifica si no esta en blanco
if (pCampo == "" || pCampo.length == 0)
{ alert("EL VINCULO DEL LIN NO PUEDE ESTAR EN BLANCO");
document.Formulario.vinculo.focus();
return false;
}
// Devuelve validación sin errores
return true;
}
<!--FIN FUNCIONES -->
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

TU FUNCION
// FUNCION MUESTRA IMAGEN
function r(sel) {
if(sel.selectedIndex == 0) {
document.getElementById("mostrar").src = "fotosl/default.jpg";
}
codigo.value=sel.options[sel.selectedIndex].getAttribute('codigo');
nombre.value=sel.options[sel.selectedIndex].getAttribute('nombre');
vinculo.value=sel.options[sel.selectedIndex].getAttribute('vinculo');
ruta.value=sel.options[sel.selectedIndex].getAttribute('ruta');
document.getElementById("mostrar").src = sel.options[sel.selectedIndex].getAttribute('ruta');
}
</script>


y luego el html

<table width="100%" border="0" align="center"> <tr> <form name="Formulario" method="post" action="actualizalink.php" enctype="multipart/form-data">
<tr>
<td style="font-family:Tahoma, Geneva, sans-serif; font-size:12px; color:#930; font-weight: bold;" width="140" height="20" align="left"><span class="Estilo6"><strong>Seleccionar Link</strong></span></td>
<td width="371">
<?php
mysql_query("SET NAMES 'utf8'"); //selecciona el cotejamiento de la base de datos mysql_select_db("universidad",$link);
$cadena = mysql_query("SELECT * FROM links ORDER BY id ASC",$link); ?>

<select name="selecnot" id="selecnot" onChange="r(this)"> <option value="0" responsable="">Seleccione Link </option> <?php while ($row = mysql_fetch_assoc($cadena)) { ?> <option value="<?php echo $row['id']?>"codigo="<?php echo $row['id']?>"nombre="<?php echo $row['nombre']?>"vinculo="<?php echo $row['vinculo']?>"ruta="<?php echo $row['ruta']?>" > <?php echo $row['nombre']?> </option>

<?PHP
// GUARDO LA RUTA DE LA IMAGEN SELECCIONADA
$fotoactual = $row['ruta']; } ?>
</select>

<label> <input name="codigo" type="hidden" id="codigo" /> </label>
</td>
</tr>
<!-- AQUI QUIERO QUE SE MUESTRE LA IMAGEN QUE CORRESPONDE A LA OPCION ELEGIDA DEL SELECT --> <tr> <td style="font-family:Tahoma, Geneva, sans-serif; font-size:12px; color:#930; font-weight: bold;" width="140" align="left">Imagen Actual</td>

<td align="left">
<?php echo $fotoactual; ?>
<img id="mostrar" name="fotolink" id="fotolink" src='fotol/default.jpg' alt="IMAGEN LINK" height='80' width='180' align='center' />
</td>
</tr>
<!-- fin de la muestra de imagen -->

Espero me puedas corregir los errores y te pasaste muchas gracias por la ayuda
  #4 (permalink)  
Antiguo 08/04/2011, 15:32
 
Fecha de Ingreso: julio-2003
Ubicación: Santiago
Mensajes: 26
Antigüedad: 20 años, 8 meses
Puntos: 0
Respuesta: Mostrar imagen en celda tras obtener ruta desde base mysql mediante select

Corregi el problema que me daba el img

pero sigue dandome un error de codigo no definido en JAVA

TE ADJUNTO DE NUEVO EL CODIGO COMO QUEDO

JAVA

<script language="JavaScript" type="text/JavaScript">
// FUNCION VALIDA FECHA EN BLANCO
function ValNombre(pCampo)
{
// Verifica si no esta en blanco
if (pCampo == "")
{ alert("EL NOMBRE DEL LINK NO PUEDE ESTAR EN BLANCO");
document.Formulario.nombre.focus();
return false;
}
// Devuelve validación sin errores
return true;
}
// VALIDA TITULO EN BLANCO
function ValVinculo(pCampo)
{
// Verifica si no esta en blanco
if (pCampo == "" || pCampo.length == 0)
{ alert("EL VINCULO DEL LIN NO PUEDE ESTAR EN BLANCO");
document.Formulario.vinculo.focus();
return false;
}
// Devuelve validación sin errores
return true;
}
<!--FIN FUNCIONES -->
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
// FUNCION MUESTRA IMAGEN
function r(sel) {
if(sel.selectedIndex == 0) {
document.getElementById("mostrar").src = "fotosl/default.jpg";
}
codigo.value=sel.options[sel.selectedIndex].getAttribute('codigo');
nombre.value=sel.options[sel.selectedIndex].getAttribute('nombre');
vinculo.value=sel.options[sel.selectedIndex].getAttribute('vinculo');
ruta.value=sel.options[sel.selectedIndex].getAttribute('ruta');
document.getElementById("mostrar").src = sel.options[sel.selectedIndex].getAttribute('ruta');
}
</script>

HTML

<table border="0" align="center">
<tr>
<form name="Formulario" method="post" action="actualizalink.php" enctype="multipart/form-data">
<td style="font-family:Tahoma, Geneva, sans-serif; font-size:12px; color:#930; font-weight: bold;" width="140" height="20" align="left"><span class="Estilo6"><strong>Seleccionar Link</strong></span></td>
<td width="371">
<?php
mysql_query("SET NAMES 'utf8'"); //selecciona el cotejamiento de la base de datos mysql_select_db("universidad",$link);
$cadena = mysql_query("SELECT * FROM links ORDER BY id ASC",$link);
?>

<select name="selecnot" id="selecnot" onChange="r(this)"> <option value="0" responsable="">Seleccione Link </option>

<?php
while ($row = mysql_fetch_assoc($cadena))
{
?>
<option value="<?php echo $row['id']?>"codigo="<?php echo $row['id']?>"nombre="<?php echo $row['nombre']?>"vinculo="<?php echo $row['vinculo']?>"ruta="<?php echo $row['ruta']?>" > <?php echo $row['nombre']?>
</option>
<?php
}
?>
</select>
<label> <input name="codigo" type="hidden" id="codigo" /> </label>
</td>
</tr>
<!-- AQUI QUIERO QUE SE MUESTRE LA IMAGEN QUE CORRESPONDE A LA OPCION ELEGIDA DEL SELECT --> <tr> <td style="font-family:Tahoma, Geneva, sans-serif; font-size:12px; color:#930; font-weight: bold;" width="140" align="left">Imagen Actual</td>

<td align="left">
<img id="mostrar" name="fotolink" src="fotol/default.jpg" alt="IMAGEN LINK" height='80' width='180' align='center' />
</td>
</tr>
<!-- fin de la muestra de imagen -->
<tr>
<td style="font-family:Tahoma, Geneva, sans-serif; font-size:12px; color:#930; font-weight: bold;" width="140" align="left">Nombre Link</td>
<td align="left"><input name="nombre" id="nombre" type="text" size="50" maxlength="50" style="font-family:Verdana, Geneva, sans-serif; font-size:11px; color:#F60;" onChange="ValNombre(this.value);"/></td>
</tr>
<tr>
<td style="font-family:Tahoma, Geneva, sans-serif; font-size:12px; color:#930; font-weight: bold;" align="left">Vinculo</td>
<td align="left"><input name="vinculo" id="vinculo" type="text" size="50" maxlength="50" style="font-family:Verdana, Geneva, sans-serif; font-size:11px; color:#F60;" onChange="ValVinculo(this.value);"/></td>
</tr>
<tr>
<td style="font-family:Tahoma, Geneva, sans-serif; font-size:12px; color:#930; font-weight: bold;" align="left">Ruta Imagen</td>
<td align="left">
<input name="ruta" type="text" id="ruta" value="" size="50" maxlength="50" style="font-family:Verdana, Geneva, sans-serif; font-size:11px; color:#F60;" />
</td>
</tr>
<tr>
<td style="font-family:Tahoma, Geneva, sans-serif; font-size:12px; color:#930; font-weight: bold;" width="292" align="left">Seleccionar nueva Imagen</td>
<td align="left"><input type="file" name="imagen" size="36"></td>
</tr>
<tr>
<td height="40" align="center"><input type="submit" name="act" value="Actualizar Link"/></td>
</tr>
</form>
</tr>
</table>


ESPERO ME PUEDAS AYUDAR GRACIAS
  #5 (permalink)  
Antiguo 08/04/2011, 15:35
 
Fecha de Ingreso: julio-2003
Ubicación: Santiago
Mensajes: 26
Antigüedad: 20 años, 8 meses
Puntos: 0
Respuesta: Mostrar imagen en celda tras obtener ruta desde base mysql mediante select

AMIGO laratik

TAMPOCO ME CARGA NINGUN DATO EN LOS INPUT

ESPERO TU RESPUESTA GRACIAS

ATENTAMENTE CARLOS
  #6 (permalink)  
Antiguo 08/04/2011, 15:39
Avatar de laratik  
Fecha de Ingreso: mayo-2010
Ubicación: Cali
Mensajes: 317
Antigüedad: 13 años, 10 meses
Puntos: 63
Respuesta: Mostrar imagen en celda tras obtener ruta desde base mysql mediante select

Acabo de realizar pruebas sobre el codigo que me has enviado y no encuentro cuales son los errores, de hecho me funciona perfectamente, de hecho el unico error me lo envia chrome diciendome que no encuentra http://localhost/fotol/default.jpg , lo cual es logico ya que yo no tengo el archivo. Pero el resto
__________________
Programar apasiona y lo que apasiona es un arte, por lo tanto programar es un arte.

Quiero karma para en mi próxima vida ser un billonario bien dotado con alas.
  #7 (permalink)  
Antiguo 11/04/2011, 11:32
 
Fecha de Ingreso: julio-2003
Ubicación: Santiago
Mensajes: 26
Antigüedad: 20 años, 8 meses
Puntos: 0
Exclamación Respuesta: Mostrar imagen en celda tras obtener ruta desde base mysql mediante select

Cita:
Iniciado por laratik Ver Mensaje
Acabo de realizar pruebas sobre el codigo que me has enviado y no encuentro cuales son los errores, de hecho me funciona perfectamente, de hecho el unico error me lo envia chrome diciendome que no encuentra [url]http://localhost/fotol/default.jpg[/url] , lo cual es logico ya que yo no tengo el archivo. Pero el resto
Amigo disculpa pero no me carga en los input los datos del select y tampoco me muestra la imagen que corresponde puedes revisar por fa me urge dejarlo listo hoy

Un abrazo Carlos

si tienes skype agregame para que hablemos en linea es asinformatica2009 CHILE

Última edición por plataformas; 11/04/2011 a las 11:45
  #8 (permalink)  
Antiguo 11/04/2011, 14:20
Avatar de laratik  
Fecha de Ingreso: mayo-2010
Ubicación: Cali
Mensajes: 317
Antigüedad: 13 años, 10 meses
Puntos: 63
Respuesta: Mostrar imagen en celda tras obtener ruta desde base mysql mediante select

Lo lamento pero en estos momentos no me puedo conectar por ese medio, si lo deseas puedes postear el código (o enviarlo a mi correo, el cual se encuentra debajo de mi avatar), según entiendo estas extrayendo bien los datos de la base de datos, ya que estos aparecen en el select, pero la falla esta en el javascript que no te los muestras en el input.

Como te lo dije, he hecho pruebas en mi servidor local, tratando de emular la tabla que tienes:

*---------------------*
| Links |
-----------------------
| ID |
-----------------------
| nombre |
-----------------------
| vinculo |
-----------------------
| ruta |
*---------------------*


y todo bien, es más se deberia ver así:

__________________
Programar apasiona y lo que apasiona es un arte, por lo tanto programar es un arte.

Quiero karma para en mi próxima vida ser un billonario bien dotado con alas.
  #9 (permalink)  
Antiguo 11/04/2011, 14:58
 
Fecha de Ingreso: julio-2003
Ubicación: Santiago
Mensajes: 26
Antigüedad: 20 años, 8 meses
Puntos: 0
Exclamación Respuesta: Mostrar imagen en celda tras obtener ruta desde base mysql mediante select

Cita:
Iniciado por laratik Ver Mensaje
lo lamento pero en estos momentos no me puedo conectar por ese medio, si lo deseas puedes postear el código (o enviarlo a mi correo, el cual se encuentra debajo de mi avatar), según entiendo estas extrayendo bien los datos de la base de datos, ya que estos aparecen en el select, pero la falla esta en el javascript que no te los muestras en el input.

Como te lo dije, he hecho pruebas en mi servidor local, tratando de emular la tabla que tienes:

*---------------------*
| links |
-----------------------
| id |
-----------------------
| nombre |
-----------------------
| vinculo |
-----------------------
| ruta |
*---------------------*


y todo bien, es más se deberia ver así:


ok revisare nuevo que me puede estar fallando gracias amigo te cuento
  #10 (permalink)  
Antiguo 12/04/2011, 10:35
 
Fecha de Ingreso: julio-2003
Ubicación: Santiago
Mensajes: 26
Antigüedad: 20 años, 8 meses
Puntos: 0
Exclamación Respuesta: Mostrar imagen en celda tras obtener ruta desde base mysql mediante select

Cita:
Iniciado por plataformas Ver Mensaje
ok revisare nuevo que me puede estar fallando gracias amigo te cuento
Disculpa amigo pero me aparece esto
Detalles de error de página web

Agente de usuario: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; InfoPath.2; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E)
Fecha: Tue, 12 Apr 2011 16:30:33 UTC


Mensaje: 'codigo' is undefined
Línea: 65
Carácter: 2
Código: 0
URI: http://www.bto.cl/editalink.php?&SID=c8916d80a6e87beef84289be737470b 9

hace referencia a que la variable codigo no se encuentra definida y no me muestra nada

te vuelvo adjuntar el codigo compreto

<?PHP
include ("PaginaPrincipal.php");
// CONECTAMOS A LA BASE DE DATOS
include("conexion.php");
$link=Conectarse();
?>


<script language="JavaScript" type="text/JavaScript">
// FUNCION VALIDA FECHA EN BLANCO
function ValNombre(pCampo)
{
// Verifica si no esta en blanco
if (pCampo == "")
{ alert("EL NOMBRE DEL LINK NO PUEDE ESTAR EN BLANCO");
document.Formulario.nombre.focus();
return false;
}
// Devuelve validación sin errores
return true;
}
// VALIDA TITULO EN BLANCO
function ValVinculo(pCampo)
{
// Verifica si no esta en blanco
if (pCampo == "" || pCampo.length == 0)
{ alert("EL VINCULO DEL LIN NO PUEDE ESTAR EN BLANCO");
document.Formulario.vinculo.focus();
return false;
}
// Devuelve validación sin errores
return true;
}
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
// FUNCION MUESTRA IMAGEN
function r(sel) {
if(sel.selectedIndex == 0) {
document.getElementById("mostrar").src = "fotosl/default.jpg";
}
codigo.value=sel.options[sel.selectedIndex].getAttribute('codigo');
nombre.value=sel.options[sel.selectedIndex].getAttribute('nombre');
vinculo.value=sel.options[sel.selectedIndex].getAttribute('vinculo');
ruta.value=sel.options[sel.selectedIndex].getAttribute('ruta');
document.getElementById("mostrar").src = sel.options[sel.selectedIndex].getAttribute('ruta');
}
</script>

<div id="central">
<!-- Center column -->
<table WIDTH="98%" cellpadding="0" cellspacing="0">
<TR>
<TD COLSPAN="5" class="mainpage_subheadline" VALIGN="top" WIDTH="550" HEIGHT="15"><img SRC="images/1x1.gif" WIDTH="550" HEIGHT="15"></TD>
</TR>
<tr>
<td>
<div id="flashcontent">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="65%">
<div id="centro">
<p class="right_boxheadline" align="LEFT" style="width:550px; color: #333;" valign=bottom>MENU DE ADMINISTRACION WEB BTO - EDITAR LINK</p>
</div><img src="images/links.jpg" alt="" width="91" height="66" align="right"/>

<table border="0" align="center">
<tr>
<form name="Formulario" method="post" action="actualizalink.php" enctype="multipart/form-data">
<td style="font-family:Tahoma, Geneva, sans-serif; font-size:12px; color:#930; font-weight: bold;" width="140" height="20" align="left"><span class="Estilo6"><strong>Seleccionar Link</strong></span></td>
<td width="371">
<?php
mysql_query("SET NAMES 'utf8'"); //selecciona el cotejamiento de la base de datos mysql_select_db("universidad",$link);
$cadena = mysql_query("SELECT * FROM links ORDER BY id ASC",$link);
?>

<select name="selecnot" id="selecnot" onChange="r(this)"> <option value="0" responsable="">Seleccione Link </option>

<?php
while ($row = mysql_fetch_assoc($cadena))
{
?>
<option value="<?php echo $row['id']?>"codigo="<?php echo $row['id']?>"nombre="<?php echo $row['nombre']?>"vinculo="<?php echo $row['vinculo']?>"ruta="<?php echo $row['ruta']?>" > <?php echo $row['nombre']?>
</option>
<?php
}
?>
</select>
<label> <input name="codigo" type="hidden" id="codigo" /> </label>
</td>
</tr>
<!-- AQUI QUIERO QUE SE MUESTRE LA IMAGEN QUE CORRESPONDE A LA OPCION ELEGIDA DEL SELECT --> <tr> <td style="font-family:Tahoma, Geneva, sans-serif; font-size:12px; color:#930; font-weight: bold;" width="140" align="left">Imagen Actual</td>

<td align="left">
<img id="mostrar" name="fotolink" src="fotol/default.jpg" alt="IMAGEN LINK" height='80' width='180' align='center' />
</td>
</tr>
<!-- fin de la muestra de imagen -->
<tr>
<td style="font-family:Tahoma, Geneva, sans-serif; font-size:12px; color:#930; font-weight: bold;" width="140" align="left">Nombre Link</td>
<td align="left"><input name="nombre" id="nombre" type="text" size="50" maxlength="50" style="font-family:Verdana, Geneva, sans-serif; font-size:11px; color:#F60;" onChange="ValNombre(this.value);"/></td>
</tr>
<tr>
<td style="font-family:Tahoma, Geneva, sans-serif; font-size:12px; color:#930; font-weight: bold;" align="left">Vinculo</td>
<td align="left"><input name="vinculo" id="vinculo" type="text" size="50" maxlength="50" style="font-family:Verdana, Geneva, sans-serif; font-size:11px; color:#F60;" onChange="ValVinculo(this.value);"/></td>
</tr>
<tr>
<td style="font-family:Tahoma, Geneva, sans-serif; font-size:12px; color:#930; font-weight: bold;" align="left">Ruta Imagen</td>
<td align="left">
<input name="ruta" type="text" id="ruta" value="" size="50" maxlength="50" style="font-family:Verdana, Geneva, sans-serif; font-size:11px; color:#F60;" />
</td>
</tr>
<tr>
<td style="font-family:Tahoma, Geneva, sans-serif; font-size:12px; color:#930; font-weight: bold;" width="292" align="left">Seleccionar nueva Imagen</td>
<td align="left"><input type="file" name="imagen" size="36"></td>
</tr>
<tr>
<td height="40" align="center"><input type="submit" name="act" value="Actualizar Link"/></td>
</tr>
</form>
</tr>
</table>
</td>
</tr>
</table>
<table width="31%" border="0" align="center">
<tr>
<td width="175">
<p align="center"><a href="mlinks.php" ><img src="menu/volverm1.jpg" alt="VOLVER MENU" width="150" height="25" onMouseOver="src='menu/volverm2.jpg'"
onMouseOut="src='menu/volverm1.jpg'" border="0" /></a></p>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
<!-- Center Column end -->
</div>

como podrias probar mi codigo para que veas el error ?


ojala me puedas ayudar lo que tu me muestras que funciona es lo que necesito pero por alguna razon no me funciona

Gracias
  #11 (permalink)  
Antiguo 12/04/2011, 10:53
 
Fecha de Ingreso: julio-2003
Ubicación: Santiago
Mensajes: 26
Antigüedad: 20 años, 8 meses
Puntos: 0
Respuesta: Mostrar imagen en celda tras obtener ruta desde base mysql mediante select

Quizas hay algo en mi codigo que esta diferente en el tuyo espero lo puedas detectar y gracias de nuevo
  #12 (permalink)  
Antiguo 12/04/2011, 13:32
Avatar de laratik  
Fecha de Ingreso: mayo-2010
Ubicación: Cali
Mensajes: 317
Antigüedad: 13 años, 10 meses
Puntos: 63
Respuesta: Mostrar imagen en celda tras obtener ruta desde base mysql mediante select

Ya me esta pareciendo muy extraño que te este causando tantos problemas este código, he copiado y pegado el código que has dejado (lo único que he cambiado es la conexión a la base de datos, que creo que ahí no este el problema) y me ha funcionado perfectamente, de hecho puedes ver como funciona desde el siguiente enlace, te repito solo he copiado y pegado. De todas maneras ya te he agregado a Skype, aunque solo voy a estar conectado hasta las 4:30 pm hora colombiana (Creo que son 6:30 en Chile). saludos.
__________________
Programar apasiona y lo que apasiona es un arte, por lo tanto programar es un arte.

Quiero karma para en mi próxima vida ser un billonario bien dotado con alas.
  #13 (permalink)  
Antiguo 12/04/2011, 14:14
 
Fecha de Ingreso: julio-2003
Ubicación: Santiago
Mensajes: 26
Antigüedad: 20 años, 8 meses
Puntos: 0
Exclamación Respuesta: Mostrar imagen en celda tras obtener ruta desde base mysql mediante select

Cita:
Iniciado por laratik Ver Mensaje
Ya me esta pareciendo muy extraño que te este causando tantos problemas este código, he copiado y pegado el código que has dejado (lo único que he cambiado es la conexión a la base de datos, que creo que ahí no este el problema) y me ha funcionado perfectamente, de hecho puedes ver como funciona desde el siguiente [URL="http://www.mirdware.co.cc/prueba.php"]enlace[/URL], te repito solo he copiado y pegado. De todas maneras ya te he agregado a Skype, aunque solo voy a estar conectado hasta las 4:30 pm hora colombiana (Creo que son 6:30 en Chile). saludos.
Sabes amigo probe tu en lace y ces puede ser algun complemenme da el mismo error entonces podria ser algo relacionado con el navegador o no se en realidad

te adjunto la imagen de tu link

  #14 (permalink)  
Antiguo 12/04/2011, 14:16
 
Fecha de Ingreso: julio-2003
Ubicación: Santiago
Mensajes: 26
Antigüedad: 20 años, 8 meses
Puntos: 0
Respuesta: Mostrar imagen en celda tras obtener ruta desde base mysql mediante select

fijate como aparece el eeror en la barra de estado y al desplegarlo es el que esta al costado derecho, que podra ser es extraño que te funcione y ami no faltara algo en mi hosting ?
o en mi navegador ?
  #15 (permalink)  
Antiguo 12/04/2011, 14:23
Avatar de laratik  
Fecha de Ingreso: mayo-2010
Ubicación: Cali
Mensajes: 317
Antigüedad: 13 años, 10 meses
Puntos: 63
Respuesta: Mostrar imagen en celda tras obtener ruta desde base mysql mediante select

mea culpa por no probarlo en IE, efectivamente sale ese molesto error (en Firefox y Chrome no salen ) pues bien sustituyendo la función por metodos DOM, de esta manera:

Código Javascript:
Ver original
  1. function r(sel) {
  2. if(sel.selectedIndex == 0) {
  3. document.getElementById("mostrar").src = "fotosl/default.jpg";
  4. }
  5. document.getElementById("codigo").value=sel.options[sel.selectedIndex].getAttribute('codigo');
  6. document.getElementById("nombre").value=sel.options[sel.selectedIndex].getAttribute('nombre');
  7. document.getElementById("vinculo").value=sel.options[sel.selectedIndex].getAttribute('vinculo');
  8. document.getElementById("ruta").value=sel.options[sel.selectedIndex].getAttribute('ruta');
  9. document.getElementById("mostrar").src = sel.options[sel.selectedIndex].getAttribute('ruta');
  10. }

Debería solucionarse, cualquier cosa me comentas.
__________________
Programar apasiona y lo que apasiona es un arte, por lo tanto programar es un arte.

Quiero karma para en mi próxima vida ser un billonario bien dotado con alas.
  #16 (permalink)  
Antiguo 12/04/2011, 14:46
 
Fecha de Ingreso: julio-2003
Ubicación: Santiago
Mensajes: 26
Antigüedad: 20 años, 8 meses
Puntos: 0
Respuesta: Mostrar imagen en celda tras obtener ruta desde base mysql mediante select

Cita:
Iniciado por laratik Ver Mensaje
mea culpa por no probarlo en ie, efectivamente sale ese molesto error (en firefox y chrome no salen ) pues bien sustituyendo la función por metodos dom, de esta manera:

Código javascript:
Ver original
  1. function r(sel) {
  2. if(sel.selectedindex == 0) {
  3. document.getelementbyid("mostrar").src = "fotosl/default.jpg";
  4. }
  5. document.getelementbyid("codigo").value=sel.options[sel.selectedindex].getattribute('codigo');
  6. document.getelementbyid("nombre").value=sel.options[sel.selectedindex].getattribute('nombre');
  7. document.getelementbyid("vinculo").value=sel.options[sel.selectedindex].getattribute('vinculo');
  8. document.getelementbyid("ruta").value=sel.options[sel.selectedindex].getattribute('ruta');
  9. document.getelementbyid("mostrar").src = sel.options[sel.selectedindex].getattribute('ruta');
  10. }

debería solucionarse, cualquier cosa me comentas.


perfecto amigo ahora si funciono que bueno gracias te pasaste, ahora dime si alguien lo ve en crhome o firefox no funcionara ?

Gracias que deberia hacer para que funcione en todos los navegadores ?
  #17 (permalink)  
Antiguo 12/04/2011, 14:52
Avatar de laratik  
Fecha de Ingreso: mayo-2010
Ubicación: Cali
Mensajes: 317
Antigüedad: 13 años, 10 meses
Puntos: 63
Respuesta: Mostrar imagen en celda tras obtener ruta desde base mysql mediante select

En firefox, chrome y opera funciona perfectamente, de hecho los métodos DOM son estándares, por lo que cualquier navegador que los siga no debería tener problemas (y esos son la mayoría, por no decir que todos). Como te dije fue culpa mía, tan solo acomode el codigo que tenias anteriormente, lo probé en chrome y al ver que funcionaba no me preocupe por probar en otros navegadores.

Ahora si te puedo asegurar que funciona por lo menos en mis cuatro navegadores. SALUDOS.
__________________
Programar apasiona y lo que apasiona es un arte, por lo tanto programar es un arte.

Quiero karma para en mi próxima vida ser un billonario bien dotado con alas.
  #18 (permalink)  
Antiguo 12/04/2011, 14:59
 
Fecha de Ingreso: julio-2003
Ubicación: Santiago
Mensajes: 26
Antigüedad: 20 años, 8 meses
Puntos: 0
Respuesta: Mostrar imagen en celda tras obtener ruta desde base mysql mediante select

GRACIAS AMIGO TE PASASTE ANTE FUTURAS DUDAS TE PUEDO MOLESTAR PORQUE LA VERDAD SABES HARTO DE PHP Y MYSQL YO HACE POCO EMPECE A TRABAJAR CON ESTE LENGUAJE Y MOTOR DE BASE

GRACIAS UN ABRAZO ESPERO SIGAMOS EN CONTACTO MI SKYPE ES asinformatica2009 por si me quieres agregar para hablar en linea soy de CHILE

Etiquetas: celda, mediante, mysql, option, ruta, select, tras
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 09:29.