• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Passing check box value to servlet.

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello guys,

Got little bit tangled here...

I have a table in my jsp page..



On click of any check box in the table, it should be transferred to a servlet from there it should call a method where I have my business logic.

I am trying to do it through the following way,

I am calling a javascript function on "onselect" in checkbox ,and from there i am trying to call "document.location.href = my servlet name "

It seems not to work, could anyone help me out..

Thanks and regards,
Hemanth.
 
Sheriff
Posts: 67645
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"onselect"? Have you verified that that's a valid event for checkboxes?
 
hemanth acharya
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bear Bibeault,

Thanks for early response...

Yeah, "onselect" seem not to work for checkboxes, i made a work around for that functionality which i wanted..... I will get back to you once its fully functional...

Thank you,
Hemanth
 
Bear Bibeault
Sheriff
Posts: 67645
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What you have you done to find out what events are valid for checkboxes?
 
hemanth acharya
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bear Bibeault,

It was a trial and error method, just placed onselect and assigned a javascript for it... Seem not to work..


Thank you,
Hemanth.
 
Bear Bibeault
Sheriff
Posts: 67645
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you think that the trial and error method is effective? Maybe it'd be helpful to get yourself a good JavaScript and DOM reference so that you'd know for sure what to use?
 
hemanth acharya
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bear Bibeault,

Yeah , I will do that, But for now my work around seem to do the trick...
 
Bear Bibeault
Sheriff
Posts: 67645
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
hemanth acharya
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why was that for ....

 
Sheriff
Posts: 9693
42
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hemanth, what Bear is trying to say is onselect is not an event of checkbox. If its not working then the trial and error method says its wrong. Check the input tag page to see the events which input tag supports...
 
hemanth acharya
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ankit,

Oops , My bad.. I will do that...

Thank you,
Hemanth.
 
author
Posts: 4323
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Worse yet, trial and error may produce results that work in 'some' browsers but not in others, since not all browsers properly implement specs. In other words, the documentation is not just better to use because it will get to the correct solution faster, but will also be more reliable across multiple browsers and platforms.
 
whippersnapper
Posts: 1843
5
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Programming by Coincidence
 
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If each of your checkbox item has an 'id' and a 'name' , you can use
HttpServletRequest.getParamterValues('name') to retrieve a String array containing the list of 'checked' ids.
 
Bear Bibeault
Sheriff
Posts: 67645
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tina Ma wrote:If each of your checkbox item has an 'id' and a 'name' , you can use
HttpServletRequest.getParamterValues('name') to retrieve a String array containing the list of 'checked' ids.


No, you can't. The ids are not, I repeat not, submitted as part of the request. Only the names and values are.
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic