Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Check Box

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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 ??
 
Because those who mind don't matter and those who matter don't mind - Seuss. Tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic