
08/02/2007, 09:25
|
| | Fecha de Ingreso: mayo-2006 Ubicación: Bilbo
Mensajes: 76
Antigüedad: 18 años, 11 meses Puntos: 0 | |
Re: componer nombre de formulario A ver si consigo explicar lo que quiero.
Lo que quiero hacer es una aplicacion que muestra una serie de preguntas con sus opciones de respuesta. Es una encuesta.
Los datos de las preguntas y posibles respuestas los saca de una base de datos.
Tanto las preguntas como las respuestas tienen su Id unico.
El numero de preguntas asi como el numero de opciones de respuesta es variable, es decir, la tabla que contiene esos datos cambia constantemente.
Yo quiero mostrar las preguntas por pantalla y q la gente responda.
Luego hay un boton de "Votar" que es una llamada a una funcion jscript que esta en la misma asp.
En esta funcion lo que hago es mirar cual es la respuesta que ha marcado el usuario y guardo el id de esa respuesta. Asi:
IdPreguna1/IdRespues1|IdPregunta2\IdRespuesta2.....
Yo de momento tengo pintada la pagina con las preguntas y respuestas con un unico formulario y nombrandolas como tu me decias antes.
pregunta1
respuesta1
respuesta1
respuesta1
pregunta2
respuesta2
respuesa2
etc, etc....
Ahora el problema es q en la funcion jscript no se como recogerlas...
Si puedieses ayudarme te lo agradeceria muchisimo....
Te pego aqui el codigo completo por si te sirve de algo. Como veras la que me da problemas es la funcion Votar, q estoy haciendo pruebas asi q no hagas caso de lo q pone.
Mil gracias de nuevo.
<!-- ASP INICIO -->
<%@ Language=VBScript %>
<% Response.Buffer = true
'on error resume next
Dim rvDatosPreg
const IdPregunta = 0
const Pregunta = 1
Dim rvDatosResp
const IdRespuesta = 0
const IdPreguntaR = 1
const Respuesta = 2
Dim i
i = 0
Dim Codigos
Codigos = ""
Dim lRet
Dim TotRecsPreg
Dim TotRecsResp
'************************************************* *****************
' Listar las tareas
'************************************************* *****************
function ListarPreguntas()
dim objIncidencias
dim lRet
set objIncidencias = server.CreateObject("Intranet.clsIntranet")
if objIncidencias is nothing then
ListarPreguntas=1
else
lRet=objIncidencias.ListarPreguntas(rvDatosPreg, rvDatosResp, TotRecsPreg, TotRecsResp)
if lRet=0 then
ListarPreguntas=0
else
ListarPreguntas=1
end if
end if
set objIncidencias = nothing
end function
%>
<!-- ASP FIN -->
<!-- Javascript INICIO -->
<script language="JavaScript">
function Votar(TotRecsPreg, TotRecsResp)
{ alert(TotRecsResp);
var Datos = "";
var i;
//for (j=1;j<=TotRecsPreg;j++)
//{alert("AQui");
for (i=0;i<TotRecsResp-1;i++)
{
/*var valor = eval('document.frmVotaciones.IdRespuesta' + j + '[i].value');
alert(valor);*/
if (eval('document.frmVotaciones.IdRespuesta' + i + '[i].checked') == true)
{alert("si");
IdResp = eval('document.frmVotaciones.IdRespuesta' + i + '[i].value');
/*alert(IdResp);*/
Datos = Datos + IdResp + "|";
}
}
}
alert(Datos);
}
</script>
<!-- Javascript FIN -->
<%
lRet = ListarPreguntas()
%>
<html>
<head>
<title>Encuestas Vía Vedior</title>
<link href="assets/DUpoll.css" rel="stylesheet" type="text/css">
</head>
<body>
<FORM name="frmVotaciones" method="post">
<table width="100%" border="0" cellspacing="2" cellpadding="0">
<tr>
<td>
</td>
</tr>
<tr>
<td>
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#003399">
<tr>
<td bgcolor="#FFFFFF"> <table width="100%" border="0" cellspacing="4" cellpadding="4">
<tr>
<td>
<link href="assets/DUpoll.css" rel="stylesheet" type="text/css">
<div class="links">
<%If not rvDatosPreg.EOF then
while not rvDatosPreg.EOF
i = i + 1%>
<TABLE width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#666666">
<TR>
<TD align="left" valign="top" bgcolor="#FFFFFF">
<TABLE width="100%" border="0" cellpadding="2" cellspacing="2">
<TR>
<TD colspan="2" align="left" valign="middle" class="textBold">
<%=rvDatosPreg(1)%>
<INPUT type="hidden" name="IdPregunta" value="<%=rvDatosPreg(0)%>">
</TD>
</TR>
<%rvDatosResp.Movefirst
while not rvDatosResp.EOF
if rvDatosResp(1) = rvDatosPreg(0) then%>
<TR align="left">
<TD colspan="2" >
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr align="left">
<td width="5" rowspan="2">
<INPUT name="IdRespuesta<%=i%>" type="radio" class="form" value="<%=rvDatosPreg(0)%>/<%=rvDatosResp(0)%>">
</td>
<td class="text">
<%=rvDatosResp(2)%>
</td>
</tr>
</table>
</TD>
</TR>
<%end if
rvDatosResp.movenext
wend%>
</TABLE>
</TD>
</TR>
<TR>
<TD align="center" valign="middle" bgcolor="#F2F2F2" class="text"></TD>
</TR>
</TABLE>
<%rvDatosPreg.movenext
wend
end if
%>
</div>
</td>
</tr>
<TR align="right">
<TD align="left" valign="middle"><br>
<INPUT name="VOTE" type="button" class="form" value="Votar" onClick="javascript:Votar('<%=TotRecsPreg%>','<%=T otRecsResp%>');">
</TD>
<TD align="right" valign="middle" class="text">
</TD>
</TR>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
</FORM>
</body>
</html> |