• 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

Check Box

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi i have n number of check boxes in jsp, i have assigned ids for each checkbox
i want kown which one is selected and catch the values of checked ones
in servlet.can any one give soln for this..plsss
 
Ranch Hand
Posts: 645
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ashok,
I m not sure abt the use of id,but I have following option for your problem....
<input type="checkbox" name="chk1" value="1">
<input type="checkbox" name="chk1" value="2">
<input type="checkbox" name="chk1" value="3">
make sure names for all checkbox are same
And you can use request.getParameterValues() to chekc whihc one is selected as below
String s[]=request.getParameterValues("chk1");//chk1 is the name of chkbox
for(int i=0;i<s.length;++i)
out.println(s[i]);
Hope this helps
Cheers
Praful
 
Ashok Kulkarni
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanx ,,,,
But i am getting Null pointer Exception
where i need to pass check box name through url ...
 
Praful Thakare
Ranch Hand
Posts: 645
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you just need to put all check box and submit button in same form tag
<form>
<input type=...
...
..
<input type=submit value="hit me">
</form>
are you using any link for submitting your form ??
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic