SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    May 2007
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do I create an a array of hidden variable of the same name on the fly?

    Hi,

    How to create multiple hidden variables on the fly? I need to display about 20 or more rows in a page. At the beginning of each row, there is a checkbox that user can select. All the 20 checkbox has the same name called "visiblerows", so it becomes an array. Once the user hit the submit button I need to find which rows are selected and create an array of hidden variable, let us call it as "aselectedrows", assigned with the selected values. My server side code looks for this hidden variable. The form uses POST method to make the server call. How do I create an a array of hidden variable of the same name on the fly? Your help would be greately appreciated.

    Thanks.

  2. #2
    SitePoint Guru
    Join Date
    Sep 2006
    Posts
    731
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by supercoder View Post
    Hi,

    All the 20 checkbox has the same name called "visiblerows", so it becomes an array. Once the user hit the submit button I need to find which rows are selected and create an array of hidden variable, let us call it as "aselectedrows", assigned with the selected values. My server side code looks for this hidden variable.
    Doing that makes your form JS dependent. You could generate each checkbox name with a sequential numeric suffix, (visiblerows1,visiblerows2 etc) then the server can read them individually.
    Tab-indentation is a crime against humanity.

  3. #3
    SitePoint Member
    Join Date
    May 2007
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't want to create a seperate name for each check box. I use servlet/jsp to process the form values. My server side code uses request.getParameterValues("selectedrows") and that returns a String array. That's what I need. Thanks.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •