We help IT Professionals succeed at work.

CheckBox Mapping to DropDown

princehyderabad
on
Medium Priority
366 Views
Last Modified: 2010-04-01
hi experts,

I have a form:
while (rs.next())
{
...
<input type=checkbox name="<%=r%>" value="<%=sss%>">
   <option value="<%=ALevel%>"><%=AName%></option>

}

Output:

[ ] CheckBox1     [dropdown: PM, CM, SM]
[ ] CheckBox2     [dropdown: PM, CM, SM]
[ ] CheckBox3     [dropdown: PM, CM, SM]


If user check the checbox and select from dropdown item. i wanna pass that relation or mapping to Processing page. (ie) Passing Which checkbox and its corresponding dropdown value.

Without dropdown I used my Processing code as:
..
String[] selected1 = request.getParameterValues("CheckBoxName");
if (selected1 != null && selected1.length != 0)
              {
                for (int i = 0; i < selected1.length; i++)
             {
                       //Update Query
                      ???? NOW HERE HOW TO GET DROPDOWN VALUE ALSO ????
             }          
              }



tHX,
PH
Comment
Watch Question

Commented:
Hi,

It's not that straight forward. If you are using struts, you can make use of indexed properties.

here is one example
http://www.developer.com/java/ejb/article.php/2233591

regards,
fargo

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
thanks fargo, but I dont think its that complex. It has nothing to do with struts though I'm using struts action class for that form.

http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_21775732.html
This above link at bottom line explains how to get such values, excepts that its uses child-win to get in parent window.

Commented:
Hi,

How big is your resultset? Is it dynamic size or you know how big it is?

regards,
fargo

Author

Commented:
Quite a big !!

It shows 4 diff. Zone(South, North, East, West) and each zone has alteast 10-12 checkbox (ie) area names.

Commented:
Hi,

as i already said, if the number of input fields are finite (like 40 in your case) you can still give some fixed name and use them for the code. But it is not a good practise and i will still give you an opinion for indexed properties.

fargo

Author

Commented:
I think its better for go with index. Can U help me figure how to write java code to accept those indexed values. I dont know much abt index. I can do getparameter and getparametervalues stuff....sample code will help.

thx,
PH

Commented:
the link i gave you at my first post is the best i have.
go thru it..try to implement it and let us know if you face any problems.

fargo
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.