• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

multiple Checkbox

 
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an array of checkbox in my application when the form is sbumittied how to get ,which checkbox is selected in my action class

form bean:-
String[] checkThis=null;

on my jsp
<logic:iterate name="row" />
<html:checkbox property="checkThis" />
</logic:iterate>

how to get the index of checked checkbox
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you're iterating over a list of beans and the checkbox represents a boolean value in one of those beans, you should use <html:checkbox> and specify an indexed property as the property. This link will show you how to use indexed properties.

example:

<logic:iterate id="user" name="users" >
<html:checkbox name="user" property="registered" indexed="true" value="true" />
</logic:iterate>

If you have a situation where the user is selecting one or more values from a list of possible values, you should use the <html:multibox> tag instead of <html:checkbox>. Use the same property nane for each tag, and make sure the value="" is different for each iteration of the tag. In your ActionForm make sure the property used by the checkboxes is of type String[]. When the form is submitted, your ActionForm will contain an array containing one element for each checked box that contains the value specified for that box.

example:

<hml:multibox property="color" value="blue" />
<hml:multibox property="color" value="green" />
<hml:multibox property="color" value="yellow" />
<hml:multibox property="color" value="red" />
[ July 20, 2006: Message edited by: Merrill Higginson ]
 
sudharshan tettu
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for ur timely reply....
it was a big help to my problem....
 
When evil is afoot and you don't have any arms you gotta be hip and do the legwork, but always kick some ... tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic