Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing check box value to servlet.

 
hemanth acharya
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64692
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
Author and ninkuma
Marshal
Pie
Posts: 64692
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
Author and ninkuma
Marshal
Pie
Posts: 64692
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
Author and ninkuma
Marshal
Pie
Posts: 64692
86
IntelliJ IDE Java jQuery Mac Mac OS X
 
hemanth acharya
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why was that for ....

 
Ankit Garg
Sheriff
Posts: 9510
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Ankit,

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

Thank you,
Hemanth.
 
Scott Selikoff
author
Saloon Keeper
Posts: 4010
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • 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.
 
Michael Matola
whippersnapper
Ranch Hand
Posts: 1817
4
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Programming by Coincidence
 
Tina Ma
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • 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
Author and ninkuma
Marshal
Pie
Posts: 64692
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic