hi
i want to display the selected values from a "select" object into a new window with jsp but no matter what i do, it always writes "null"
can you help me? this is mi code

<form id="form1" name="form1" method="post" onsubmit="revisar()" action="echo.jsp">
    <table width="699" border="0" cellspacing="10" cellpadding="4">
      <tr>
        <th width="241" scope="row">
         <div align="left">Habilitar/desabilitar secuencias</div>
        </th>
        <td>
          <input type="checkbox" name="sec0" id="sec0">rotación a la izquierda	<br/>
          <input type="checkbox" name="sec1" id="sec1">rotación a la derecha	<br/>
          <input type="checkbox" name="sec2" id="sec2">intercalado		<br/>
          <input type="checkbox" name="sec3" id="sec3">parpadeo			<br/>
          <input type="checkbox" name="sec4" id="sec4">cuenta binaria rebotando
        </td>
        <td><input type="button" value="Actualizar" onclick="registrar()"/></td>
      </tr>
      <tr>
        <th scope="row">
         <div align="left">Asignar secuencias a botones</div>
        </th>
        <td>
          botón 1 <select name="lista1" id="lista1"></select><br/>
          botón 2 <select name="lista2" id="lista2"></select><br/>
          botón 3 <select name="lista3" id="lista3"></select><br/>
          botón 4 <select name="lista4" id="lista4"></select><br/>
        </td>
        <td><input type="submit" value="Actualizar" /></td>
      </tr>
    </table>
  </form>

registrar() is a javascript wich fills the selects with the marked checkboxes. it creates them something like this like this
Option listax.options[listax.options.length] = new Option(text4,s4);
so they all have a text to display and a shortened value

revisar() is another javascript that makes sure no options were repeated in the selects. IT also WORKS.

echo.jsp is the one not working.

<%@ page language="java"
session="true"
isThreadSafe="true"
contentType="text/html; charset=ISO-8859-1" %>
<%
String name1 = request.getParameter("list1");
String name2 = request.getParameter("list2");
String name3 = request.getParameter("list3");
String name4 = request.getParameter("list4");
%>
content <br/><br/>
<%=name1 %><br/>
<%=name2 %><br/>
<%=name3 %><br/>
<%=name4 %><br/>
<html>

only displays nulls
and when i use the getParameterValues("listx"), the arrays it returns are filled with weird stuff (string java lang @ numbers numbers numbers letters numbers)
what am i missing?

First of all study some html. The "select" tag misses the "option" tag which is the one that has the "value" attribute. If you look at the tag, you don't give it any value. So of course it displays null since you don't send anything.

http://www.w3schools.com/default.asp

Second don't just call methods and expect them to do whatever you want or think they do. The getParameterValues method returns an array. If you don't know what happens when you print an array, or what are those strange numbers are: "string java lang @ numbers numbers numbers letters numbers" then STOP right now what you are doing and start studying basic java. Because what you just saw was the call of the toString method that was inherited by the Object class. And if you look at the API of the Object class then the toString method prints just that.

First of all study some html. The "select" tag misses the "option" tag which is the one that has the "value" attribute. If you look at the tag, you don't give it any value. So of course it displays null since you don't send anything.

Quit acting so mighty and knowitall. if you can't read, then you shouldn't write: i know the select tag misses the options

lemme QUOTE MYSELF:

registrar() is a javascript wich fills the selects with the marked checkboxes. it creates them something like this
Option listax.options[listax.options.length] = new Option(text4,s4);
so they all have a text to display and a shortened value

this means the registrar() javascript function creates the options[] for each list. if YOU don't know anything about creating dynamic drop menus then YOU SHOULD CHECK OUT this site
http://www.javascriptkit.com/javatutors/selectcontent.shtml

Second don't just call methods and expect them to do whatever you want or think they do. The getParameterValues method returns an array. If you don't know what happens when you print an array, or what are those strange numbers are: "string java lang @ numbers numbers numbers letters numbers" then STOP right now what you are doing and start studying basic java. Because what you just saw was the call of the toString method that was inherited by the Object class. And if you look at the API of the Object class then the toString method prints just that.

here i do have to say i forgot about arrays actually being pointers. I'M SORRY: i should have printed it on a FOR loop
but still this doesn't solves my problem

because now it shows me a NullPointerException meaning the array is empty. i dont get it.

so i quit that and go back to the getParameter("listx") and only shows me the true, false, null stuff

you saw my SELECTS are called listX (list1-list4)
assuming the available OPTIONs revisar() generates for them are: right, left, blink, on, off,
with values s0, s1, s2, s3, s4

if someone picks
list1: left
list2: off
list3: right
list4: blink

how do i get the corresponding s1, s4, s0, s2 to be displayed by the jsp?

I am sorry for not reading the entire post. I focused on the code.
...
I think I noticed something that might be the solution. Maybe by the time you read this, you have seen it too, or it is just a typo while you were posting the code:

<select name="[B]lista1[/B]" id="lista1"></select><br/>

String name1 = request.getParameter("[B]list1[/B]");

Try this: String name1 = request.getParameter("[U]lista1[/U]"); Instead of this:" String name1 = request.getParameter("list1"); If this doesn't solve your problem, can you post some more code?

I am sorry for not reading the entire post. I focused on the code.
...
I think I noticed something that might be the solution. Maybe by the time you read this, you have seen it too, or it is just a typo while you were posting the code:

<select name="[B]lista1[/B]" id="lista1"></select><br/>

String name1 = request.getParameter("[B]list1[/B]");

Try this: String name1 = request.getParameter("[U]lista1[/U]"); Instead of this:" String name1 = request.getParameter("list1"); If this doesn't solve your problem, can you post some more code?

oks, it seems we are at peace here.

yeah, you're rigth that was the problem
i read your post, made the correction and it worked.
i'd been looking at code all day that i was so tired i misread that name
sorry for taking this long to write back to let you know, but thanks a lot. ;D
see you around

oks, it seems we are at peace here.
see you around

Ok, No problem.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.