Foros del Web » Programación para mayores de 30 ;) » Java »

problema jsp y javascript

Estas en el tema de problema jsp y javascript en el foro de Java en Foros del Web. buenas, ojala me pudieran ayudar, miren tengo una jsp que muesttran datos de un servlet en ese jsp tengo varias funciones javascript pero tengo problema ...
  #1 (permalink)  
Antiguo 28/03/2005, 17:34
 
Fecha de Ingreso: marzo-2005
Mensajes: 2
Antigüedad: 19 años, 1 mes
Puntos: 0
problema jsp y javascript

buenas, ojala me pudieran ayudar, miren tengo una jsp que muesttran datos de un servlet en ese jsp tengo varias funciones javascript pero tengo problema con una que no me funciona es la funcion de contar ,que cuenta los checkboxs del jsp pero en esta funcion me sale un error que no reconocer el
playlist.ckbox.length no es un objeto o es nulo me dice lo mas curiioso es que hecho ese mismo metodo pero mas chico todo la pagina en otra pag y si sale
aqui les dejo los dos codigos
primero:el q no sale

<%@ Language=JavaScript %> <%@ page contentType="text/html;charset=windows-1252"%>
<jsp:useBean id="listaalu" scope="session" class="GestionAcademica.listas.ListaAlumnoLS"/>
<jsp:useBean id="BUsuario" scope="session" class="ClasesGenerales.beans.Usuario" />
<%@ page import="GestionAcademica.beans.ListaAlumno" autoFlush="true" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>untitled</title>
<SCRIPT language="JavaScript" type="text/javascript">
function lead0(val)
{
return val<10 ? "0"+val.toString() : val
}
function buildTime() {
var time = new Date()
var h=time.getHours()
if (h > 24) {h = h - 24;}
return h+":"+lead0(time.getMinutes())+":"+ lead0(time.getSeconds())
}
function fecha()
{
var time= new Date()
var d=time.getDate()
var mes = time.getMonth()
var año = time.getYear()
return d+"/"+"0"+mes+"/"+año
}
function contar()
{

var total=0;
var ch = playlist.ckbox.length;
for(var i=0;i<ch;i++)
{
if(playlist.ckbox[i].checked==true)
{
total=total+1;
}
}
return total;
}
function tick()
{
document.all.reloj.innerText = buildTime()
}
window.onload = new Function("if (window.isIE4) setInterval('tick()',1000)")
</SCRIPT>
</head>
<body >
<form method="POST" name=playlist action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" U-File="C:\Documents and Settings\mgarate\Mis documentos\Marco\jsp_Asistencia\_private\form_resu lts.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<p>&nbsp;&nbsp;&nbsp; </p>
<table border="0" width="99%" id="table4">
<tr>
<td width="26">&nbsp;</td>
<td width="51"><p align="center"><b>Fecha :</b></td>
<td width="99"><p align="center"><SPAN ID=fecha><SCRIPT Language=Javascript>document.write(fecha())</SCRIPT></SPAN></td>
<td width="57"><p align="center"><b>Hora :</b></td>
<td width="74"><p align="center"><SPAN ID=reloj><SCRIPT Language=Javascript>document.write(buildTime())</SCRIPT></SPAN></td>
<td width="119"><p align="center"><b>Matriculados :</b><SCRIPT Language=Javascript>document.write(contar())</SCRIPT>
</td>
<td width="36"><p align="center"></td>
<td>&nbsp;</td>
</tr>
<tr>
<td width="26">&nbsp;</td>
<td width="51">&nbsp;</td>
<td width="99">&nbsp;</td>
<td width="57">&nbsp;</td>
<td width="74">&nbsp;</td>
<td width="119">&nbsp;</td>
<td width="36">&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
<table border="0" width="101%" id="table2">
<tr>
<td width="13" height="76">&nbsp;</td>
<td width="8" height="76">
&nbsp;</td>
<td width="836" height="76">
<table border="1" width="100%" id="table3">
<tr>
<td width="271">
<p align="center"><b><font face="Arial" color="#FF9900">ESCUELA</font></b></td>
<td width="106">
<p align="center"><b><font face="Arial" color="#FF9900">CODIGO</font></b></td>
<td width="408">
<p align="center"><b><font face="Arial" color="#FF9900">ALUMNO</font></b></td>
<td>&nbsp;</td>
</tr>
<% for(int i=0;i<listaalu.size();i++){%>
<%ListaAlumno ls = listaalu.getListaDS(i);%>
<tr>
<td width="271"><p align="center"><%=ls.getDesEsc()%></td>
<td width="106"><p align="center"><%=ls.getCodCli()%></td>
<td width="408"><p align="center"><%=ls.getNombre()%></td>
<td>
<p align="center">
<input type="checkbox" name=ckbox value="<%=ls.getCodFac()+ls.getCodEsc()+ls.getCodC li()+ls.getCodCrr()+ls.getCodSec()+ls.getConSec()% >" checked></td>
</tr>
<%}%>

</table>
</td>
<td width="4" height="76">
&nbsp;</td>
<td height="76">&nbsp;</td>
</tr>
<tr>
<td width="13">&nbsp;</td>
<td width="8">
&nbsp;</td>
<td width="836">
<input type=submit value=" Grabar " name="B1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;
<input type="button" value="Restaurar" name="B2"></td>
<td width="4">
<p align="center">&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
<p align="center">&nbsp;</p>
</form>

</body>
</html>
y este el chico el q sale
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>formularios - javascript y checkbox - ejemplo 8</title>
<SCRIPT language="JavaScript" type="text/javascript">

<!-- Begin
function anyCheck() {
var total = 0;
var max = playlist.ckbox.length;
playlist.ckbox.length
for (var idx = 0; idx < max; idx++) {
if (eval("document.playlist.ckbox[" + idx + "].checked") == true) {
total += 1;
}
}
return total
}
// End -->
</script>

</HEAD>


<BODY bgcolor="#ffff99">

<form method="post" name=playlist action="--WEBBOT-SELF--">
1<input type=checkbox name=ckbox value="1" checked>
<br>2<input type=checkbox name=ckbox value="2" checked>
<p><SCRIPT Language=Javascript>document.write(anyCheck())</SCRIPT>
</form>
</body>
</html>
como ven son el mismo codigo identico pero nose porque no sale ojala me puedan ayudar bye
  #2 (permalink)  
Antiguo 28/03/2005, 17:47
Avatar de ~°The-Herps°~
Usuario baneado!
 
Fecha de Ingreso: septiembre-2004
Ubicación: M E X I C O
Mensajes: 498
Antigüedad: 19 años, 7 meses
Puntos: 0
No repitas Posts!!
  #3 (permalink)  
Antiguo 31/03/2005, 22:36
 
Fecha de Ingreso: noviembre-2002
Ubicación: DF
Mensajes: 1.056
Antigüedad: 21 años, 5 meses
Puntos: 37
Pues lo unico q veo diferente es que
if(playlist.ckbox[i].checked==true)


no tiene el "document." como parent para acceder al formulario playlist.

Otra cosa es que el <% for(int i=0;i<listaalu.size();i++){%>
no te diera mas que un registro, de esa manera no se generaria un ARREGLO de checkboxes, sino UN solo objeto con lo que no puedes accesarlo como arreglo, sino como el objeto directo.

Saludos
Juan Arturo


for(int i=0;i<listaalu.size();i++){%>
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:09.