This week's book giveaway is in the HTML/CSS/JavaScript forum.
We're giving away four copies of Practical SVG and have Chris Coyier on-line!
See this thread for details.
Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

checkbox to pass many params

 
michael yue
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi does anyone know how to pass a few parameters together through the use of checknox. As I know it a checkbox can be assign a value and can be pass to another page by getting the array by using getParameterValues().
If checkbox is assigned id then it can extract all the id param in the next page.
But can I put a few parameters such as example id, name, age and so on to another page and use the etParameterValues() method to extract all the data. This sounds similar to vector but I was just wondering if it could be done or if there is another way.
thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65535
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why would you want to bundle all that data under a single name? How would you tell which is which?
In any case, one checkbox == one value. You can use hidden elements to pass additional parameters.
 
michael yue
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry let me explain in more detail.
here is sample list of fields
checkboxnameidage
----------------------------
box1joe223
box2jim326
I want to pass id and the name and age associated with it to another page if the box is clicked.
If use hidden elements can only past one name or age for one particular id only.
If this is impossible, are there some other way to pass multiple name, id and age params if many boxes are clicked.
Thanks again
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65535
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What occurs to me is that you are relying too much on data flowing to and from the page. The data obviously is available on the server in order to populate it on the page in the first place. So the only piece of data you really need to find out what "set" was checked is the id. Make the id the value of the checkbox and use the ids that come back from the page to hook up to the sets of data that they represent.
[ April 20, 2004: Message edited by: Bear Bibeault ]
 
Ali Gohar
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The best way is as Bear Bibeault said that you just hook up the id with the checkbox and then in the next page get that id and then you will be able to easily get the relevent fields from Database (If you are using Database).
If you are not using Database then you can use HashMap objects to hold the data (which stores data in key value pair)and then set these objects in session object and in the next page retrieve the objects from session and use according to your need.
In case of any confusion please ask freely.
 
michael yue
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My situation is that I need to have at least 2 values to determine that a record is unique. Example I need id and name to make sure that a certain record is unique to enable me to get the right value. If not i will maybe end up doing a function for wrong record.
Anyway thanks for the reply.
 
Ali Gohar
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can make the value of the checkbox as (id + "," + name) i.e. combining id with the name. and when you retrieve the string for example as "1,myname" then extract the thing before "," it will be the id and after comma obviously name.
Ask if there is any confusion.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!