O
Omar
Hi,
I've been trying to get the right way to send parameters to a JSP from
a HTML form. The referred JSP must get the values of the selects form,
because it executes queries and does stuff with that values. But the
only thing I've got it's a Tomcat error report.
The menu.jsp is something like this:
.... // HTML stuff
<script language='JavaScript'>
function valida()
{
var ok=true;
var indexAccion = document.forms[0].accion.selectedIndex;
var indexTablas = document.forms[0].tablas.selectedIndex;
var indexBDatos = document.forms[0].BDatos.selectedIndex;
if (indexAccion==0 || indexTablas==0 || indexBDatos==0)
{
alert("Elige un criterio");
ok=false;
}
if (ok)
document.forms[0].submit();
window.location.href =
document.forms[0].accion.options[indexAccion].value;
}
</script>
.... // HTML stuff
<form method='post' ***SHOULD BE THE accion.selectedIndex.value***>
<select name="accion">
<option value="inicio" selected>Selecciona una opcion
<option value="visualiza.jsp">Visualizar registros de la tabla
<option value="modifica.jsp">Modificar registros de la tabla
</select>
<select name="tablas">
<option value="inicio" selected>Selecciona una tabla
<option value="tbl1">Tabla 1
<option value="tbl2">Tabla 2
</select>
<select name="BDatos">
<option value="inicio" selected>Selecciona una base
<option value="db1">Base 1
<option value="db2">Base 2
</select>
<br><br><br>
<input type="button" value="Aceptar" onclick='valida()'>
</form>
Any ideas to figure it out?
Regards,
- Omar.
I've been trying to get the right way to send parameters to a JSP from
a HTML form. The referred JSP must get the values of the selects form,
because it executes queries and does stuff with that values. But the
only thing I've got it's a Tomcat error report.
The menu.jsp is something like this:
.... // HTML stuff
<script language='JavaScript'>
function valida()
{
var ok=true;
var indexAccion = document.forms[0].accion.selectedIndex;
var indexTablas = document.forms[0].tablas.selectedIndex;
var indexBDatos = document.forms[0].BDatos.selectedIndex;
if (indexAccion==0 || indexTablas==0 || indexBDatos==0)
{
alert("Elige un criterio");
ok=false;
}
if (ok)
document.forms[0].submit();
window.location.href =
document.forms[0].accion.options[indexAccion].value;
}
</script>
.... // HTML stuff
<form method='post' ***SHOULD BE THE accion.selectedIndex.value***>
<select name="accion">
<option value="inicio" selected>Selecciona una opcion
<option value="visualiza.jsp">Visualizar registros de la tabla
<option value="modifica.jsp">Modificar registros de la tabla
</select>
<select name="tablas">
<option value="inicio" selected>Selecciona una tabla
<option value="tbl1">Tabla 1
<option value="tbl2">Tabla 2
</select>
<select name="BDatos">
<option value="inicio" selected>Selecciona una base
<option value="db1">Base 1
<option value="db2">Base 2
</select>
<br><br><br>
<input type="button" value="Aceptar" onclick='valida()'>
</form>
Any ideas to figure it out?
Regards,
- Omar.