JavaScript - problema con funcion

 
Vista:

problema con funcion

Publicado por soFila (2 intervenciones) el 25/06/2009 21:31:10
Tengo un checkbox con el cual quiero ir habilitando a medida que los selecciono determinados campos, pero la funcion javascript no me funciona, es decir los campos estan x defecto deshabilitados cuando quiero habilitarlos con la funcion no hace nada...este es el código:

<script languaje="JavaScript">
function habilita(){

if(document.formAltaImp.impuestos.checked == true){
document.formAltaImp.impuestos.value = "true";
document.formAltaImp.timestamp.disabled=false;
document.formAltaImp.timestamp2.disabled=false;
document.formAltaImp.monto.disabled=false;
document.formAltaImp.atraso.disabled=false;

}else{
document.formAltaImp.impuestos.value = "false";
document.formAltaImp.timestamp.disabled=true;
document.formAltaImp.timestamp2.disabled=true;
document.formAltaImp.monto.disabled=true;
document.formAltaImp.atraso.disabled=true;
}
}

</script>


<form id="formAltaImp" name="formAltaImp" id="formAltaImp" action="asigImp.jsp?paga=true" method="post" onSubmit="return validarAlta()" class="formu" >

<label>Elegir Propiedad:
<select name="propiedad" id="propiedad" cols="20" onChange="para.value=this.value">
<%
while(inmu.next()){

out.println("<option value="+inmu.getInt("id_inmu")+">"+inmu.getString("localidad")+" "+inmu.getString("calleInm")+" "+inmu.getString("nroInm")+" "+inmu.getString("pisoInm")+" </option>");
}
%>
</select><br /><br /></label>
<input type="hidden" name="para" />
<table align="center" border="2" cellpadding="3" cellspacing="2" width="560">
<tr>
<th><label class="Estilo11" style="color: rgb(0, 51, 204); ">Impuesto</label></th>
<th> <label class="Estilo11" style="color: rgb(0, 51, 204); ">Fecha Vencimiento </label></th>
<th> <label class="Estilo11" style="color: rgb(0, 51, 204); ">Monto </label></th>
<th> <label class="Estilo11" style="color: rgb(0, 51, 204); ">Fecha Pago </label></th>
<th> <label class="Estilo11" style="color: rgb(0, 51, 204); ">Pago Con Mora? </label></th>
</tr>


<%
PreparedStatement pr=con.prepareStatement("SELECT * FROM impuesto,inmximp where inmximp.idInmueble=para.value and impuesto.idImp=inmximp.idImpuesto");
ResultSet resul = pre.executeQuery();
while(resul.next()){%>
<tr>
<td>
<%out.println("<input type=checkbox name=impuestos value="+resul.getInt("idImp")+" onSelect=habilita();>"+resul.getString("descripcion")+" </br>");

%>
</td>
<td> <input type="text" id="timestamp" name="timestamp" value="" disabled="true" >
<a href="javascript:show_calendar('document.formAltaImp.timestamp', document.formAltaImp.timestamp.value);"><img src="../CSS/cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the timestamp"></a>
</label>
</td>
<td>
<input name="monto" id="monto" type="text" disabled="true" />
</label></td>
<td>
<input type="Text" id="timestamp2" name="timestamp2" value="" disabled="true">
<a href="javascript:show_calendar('document.formAltaImp.timestamp2', document.formAltaImp.timestamp2.value);"><img src="../CSS/cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the timestamp"></a>
</label></td>

<td>
<input type="checkbox" id="atraso" name="atraso" disabled="true">
</td>
<%} %>
<tr>
<td colspan="5">
<p style="margin-left:35%"><input type="submit" name="Submit" value="Guardar" />
<input type="reset" name="Submit2" value="Restablecer" />
</p>
</td>
</tr>

</table>
</form>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:problema con funcion

Publicado por KAMALEON (3 intervenciones) el 29/06/2009 23:30:47
a ver, así a ojo creo que los eventos que acepta un checkbox son onclick, onfocus, onblur, onchange, ondblclick, onmousedown, onmousemove, onmouseover, onmouseout, oncontextmenu....

pero no existe un evento "onseleccionado" o "ondeseleccionado" (existe onselect pero no es para los checkboxes)

Necesitas verificar con javascript si está o no seleccionado.

Por ejemplo

<input name="NOMBRE" type="checkbox" onClick="if(this.checked == true)
{habilita()} else{ OTRAFUNCION() }" value="NOMBRE">


ESPERO TE SIRVA,
SALUDOS DESDE CHIMBOTE PERU
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar