1 Reply Latest reply on Jul 27, 2002 1:03 PM by jasonbrome

    Select with dynamic name

    andrea74m

      I want to make a select where its name change with int i

      for example:

      menu_formato10
      menu_formato11
      ...




      Is there a dynamic method to capture the value of this select.

      I don't want to use for all different name a getParameter:

      request.getParameter(menu_formato10);
      request.getParameter(menu_formato11);

      Thanks
      Greatings
      Andrea

        • 1. Re: Select with dynamic name
          jasonbrome

          How about using the getParameterNames() method on the HttpServletRequest, and iterate through the Enumeration of parameter names, looking for ones that match your prefix,

          e.g.

          String myPrefix = "menu_formato1";

          Enumeration paramNames = request.getParameterNames();
          while(paramNames.hasMoreElements()) {
              String paramName = (String)paramNames.nextElement();
              if(paramName.startsWith(myPrefix)) {
          // Ok, we found a match...
                  String paramValue = request.getParameter(paramName);
          // Do something with it...
           
              }
          }