• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

how to show whick checkbox is checked in jsp page without submit?

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

group1: checkbox1, checkbox2, checkbox3
group2: checkbox4, checkbox5, checkbox6
group3: checkbox7, checkbox8, checkbox9

if user check the checkbox 1, then the page will show a table with content
col1 col2
row1 group1 checkbox1.value

if user check the checbox 5, 6, the the page will show a table with content
col1 col2
row1 group1 checkbox1.value
row2 group2 checkbox5.value, checkbox6.value

that is, the table will show the checkbox user checked, without submit the form, is it possible to do this using javascript? if possible, how to write it??
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First, it sounds more like you want a radio button, not a checkbox--but if you want to be able to show all of them, that's fine too. (You could certainly do it with checkboxes as well, there would just be more JavaScript.)

Second, use a library like jQuery, Prototype, etc. and attach a click handler to your checkboxes. If the data is already on the page, just hide/show the appropriate div. If you need to retrieve the data, make an Ajax call and set the contents of a div with the result.
 
peter tong
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:First, it sounds more like you want a radio button, not a checkbox--but if you want to be able to show all of them, that's fine too. (You could certainly do it with checkboxes as well, there would just be more JavaScript.)

Second, use a library like jQuery, Prototype, etc. and attach a click handler to your checkboxes. If the data is already on the page, just hide/show the appropriate div. If you need to retrieve the data, make an Ajax call and set the contents of a div with the result.



why need to use library like jQuery etc? is it very difficult to implement this function using pure javascript? I am not the project leader and I afraid my supervisor not allow me to use extra library....
I need to use checkbox because the application allow user to select more than one item in a group.
About ajax, if each click cause a partial submit, will this make the application very slow response? I haven't use ajax before.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because it makes writing JavaScript easier. Of course it's not *necessary*--it's written in JavaScript, so anything you do with jQuery, you can do in "raw" JavaScript.

As far as making it "slow" goes, it depends on when you want it to be slow: on the initial page load, where it loads all the data, or on the checkbox click. It doesn't really matter very much (probably--hard to say without knowing more).
 
Friends help you move. Good friends help you move bodies. This tiny ad will help:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic