Forums Register Login
adding hidden values that is a list
Whats the syntax for declaring a hidden field thats a list? And adding to it etc? I want to be able to store some rows when a user saves.

I currently have a screen with a spreadsheet where the user can collapse and expand rows via a plus/minus button. I want the screen to remember after the save which rows where collapsed or expanded and refresh accordingly.
All form elements with the same name will participate in the same request parameter of that name. The array of values can be retrieved from the request within the servlet via request.getParameterValues().
how do I implement it...like below?

steve kelly wrote:how do I implement it...like below?

Does that seem like valid HTML to you? Remember, everything you do at the browser is just HTML. Any JSP-isms are just to iniitally generated the HTML page to send the browser.

As I said, all form elements with the same name become the array of values. So to create an array of "rowID" values:


As for the original question, if you want to have a dropdown list that's hidden, then in your drop down element use
if that's what you want. Otherwise if you want an array follow Bear's post
OK I this is what I am doing...

I have this declaring my hidden field on jsp page

When user saves I have this code that iterates through the plus/minus rows and determines if they needed to ba added to a variable "rowID"

later when I want to access this variable the alert below is always undefined. I want to access whats been stored. How do I do this?

Your row variable is declared deep within a function. It will only be available within that function. Declare it at a higher scope.

Though I'm still not exactly sure what you are trying to accomplish. What are you actually trying to collect?
Basically the rows are collapsing plus/minus nested rows in a spreadsheet form. So I want the ability for user to click save and the screen to remember which lines they had previously expanded or collapsed after the save/submit.

Right now after saving I re-expand all lines and its very inconvient if you have lots of lines. Maybe I am just going about this totoally wrong?
And each row has a unique id, and you want to just send this list of ids to the server? (So that you can use the list to determine which rows are "open" next time the page is viewed?)

Bear Bibeault wrote:And each row has a unique id, and you want to just send this list of ids to the server? (So that you can use the list to determine which rows are "open" next time the page is viewed?)

what you said in the bold. yes
Are you doing this at submit time? If so, how can it be determined if a row is opened or closed?

In any case, to send the info back to the server you can:
  • Create multiple hidden inputs as I detailed in a previous reply. If they all have the same name, the values can be retrieved as an array.
  • "Cheat" and create a single hidden input that contains the list as a comma-separated string that you can parse at the server.

  • The latter involves less logic on the page, and more on the server. The former, just the opposite.
    Barry's not gonna like this. Barry's not gonna like this one bit. What is Barry's deal with tiny ads?
    Rocket Oven Kickstarter - from the trailboss

    This thread has been viewed 5697 times.

    All times above are in ranch (not your local) time.
    The current ranch time is
    Jul 19, 2018 16:44:15.