Foros del Web » Programando para Internet » Javascript »

display

Estas en el tema de display en el foro de Javascript en Foros del Web. Hola gente tengo problema yo hice formulario con aplicación de javascript pero no anda Código HTML: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html ...
  #1 (permalink)  
Antiguo 23/02/2011, 09:40
 
Fecha de Ingreso: marzo-2010
Ubicación: Buenos Aires
Mensajes: 25
Antigüedad: 14 años, 1 mes
Puntos: 2
display

Hola gente tengo problema yo hice formulario con aplicación de javascript pero no anda

Código HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Formulario</title>

<script type="text/javascript">
	function alertselected(selectobj){
	 //alert(selectobj.value);
	 var val=selectobj.value;
	 switch(val){
		case '0':
			alert(selectobj.value);
			capaConsultar.style.display = "block";
		break;
	 };
	}
</script>
</head>

<body>
<table cellpadding="0" cellspacing="0" width="380">
<form  action="#">
	<tr>
    	<td>Inscripción a:</td>
        <td>
        	<select name="inscripcion" id="sample" onChange="alertselected(this)">
            	<option value="0A">Seminario (incluye exposición)</option>
                <option value="0">Sólo Exposición</option>
            </select>
        </td>
    </tr>
    <tr>
    	<td>Importe:</td>
        <td>
        	<table cellpadding="0" cellspacing="0" width="100%">
            	<tr>
                	<td>
                    	<table cellpadding="0" cellspacing="0" width="100%" id="capaConsultar" style="display:none;">
                        	<tr>
                            	<td>$30</td>
                            </tr>
                        </table>
                    </td>
                </tr>
                
            </table>
        </td>
    </tr>
    <tr>
    	<td>&nbsp;</td>
        <td>
        	<input type="submit" value="Subir" />
        </td>
    </tr>
    </form>
</table>
</body>
</html> 
desde ya muchas gracias.
  #2 (permalink)  
Antiguo 23/02/2011, 10:21
 
Fecha de Ingreso: febrero-2011
Ubicación: Avellaneda, Buenos Aires
Mensajes: 39
Antigüedad: 13 años, 1 mes
Puntos: 0
Respuesta: display

Estás intentando hacer visible la tabla "capaConsultar", pero el error está cuando querés seleccionarla.

La línea 14:
capaConsultar.style.display = "block";

Debés reemplazarla por:
document.getElementById('capaConsultar').style.dis play = "block";

Otro consejo, en vez de hacer un switch para verificar que haya seleccionado 'Sólo Exposición', podrías mejor usar un IF de la siguiente forma

if(val === '0')
{
alert(selectobj.value);
document.getElementById('capaConsultar').style.dis play = "block";
}

De este modo queda un poco más claro.
Saludos!
  #3 (permalink)  
Antiguo 23/02/2011, 11:29
 
Fecha de Ingreso: marzo-2010
Ubicación: Buenos Aires
Mensajes: 25
Antigüedad: 14 años, 1 mes
Puntos: 2
Respuesta: display

Perfecto está solucionado Gracias Amigazo

Etiquetas: display
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 20:45.