2 Replies Latest reply on Nov 15, 2001 7:14 AM by jcordes

    Listen JSP

    kramisimo

      Hallo,
      ich habe eine Frage, wie kann man in JSP eine Liste Dynamische generieren, ich meine:



      kann man bei diese input die name als Array definieren?
      wenn ja, wie kann man diese Array setzen?

      Gruss,

      krami.

        • 1. Re: Listen JSP
          hraun

          Krami
          Erm, I'm not sure that I understood the question correctly (Babelfish isn't perfect :^D ).
          I gather what you are asking is:
          "If I can create a dynamic list like this:
          < input type="text " name="QTY[ ] " size="5 " VALUE = " < %=warenkorb,getQTY(i)% > " >

          How can I get the name to be dynamic too? "

          If that is your question, then this is my answer:

          One idea would just be to concatenate the name to the array value like this:
          name="<%="QTY"+i%>"

          But I wonder how you would then read the values in your servlet. The way I do it is like this:

          < input type="text " name="QTY" size="5 " VALUE = " < %=warenkorb,getQTY(i)% > " >
          Then I can get all the values that the user entered in the form of an array. like this:
          String quantities = request.getParameterValues("QTY");

          Hope this helps ?!
          Bis bald
          Peet
          ps (try babelfish http://world.altavista.com/tr)

          • 2. Re: Listen JSP
            jcordes

            Hi !

            You can create a dynamic list like this

            <% for (int i=0; i < myArray.length; i++){ %>
            <input type="text" name="QTY" size="5" VALUE="<%=myArray%>">
            <% } %>

            If you're using the same name for input-fields you get an array of values (for example in your servlet). You have no other chance then to iterate through your array, setting them individually.

            Bye,

            Jochen.