• 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

how to send table "td" values to another jsp when particular row checkbox is checked

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Nag Venkat
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here my actual requirement is..when user selects checkbox ,all the data in that particular row should be send to another jsp file..if he selects two checkboxes then data related to both the checkboxes should be posted...Here do i need to write an checkBox Clik event,and get the values of td..etc...
can any one help me regarding this issue
 
Nag Venkat
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
is that change okay ,or else do i need to change any thing else,Sory i am new to this form
 
Sheriff
Posts: 67746
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
Of course, you can't just send template text, but here are a number of approaches you can take.

Put the table in a form and make each td value a read-only text field that is initially disabled. When you want to send a row, enable the fields in that row and submit the form.

Or

Create an invisible form with hidden inputs for each value you want to send. When the row is clicked, copy the td values into the hidden element, and submit the form.

Or

Use Ajax.

All of this requires the use of client-side JavaScript.

And, of course, you should be submitting the form to a servlet for processing, not directly to a JSP.
 
Bear Bibeault
Sheriff
Posts: 67746
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

hitendra sunkara wrote:is that change okay ,or else do i need to change any thing else,Sory i am new to this form



Welcome to the Ranch.

One thing I'd recommend is not to start the indentation so deeply. It makes the code harder to read.
 
Nag Venkat
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yeah,do i need to use this for each of the td element?


can you give me an example of how to get the value of td element in javascript,as the user can select multiple checkboxes ,how it can be done
 
Bear Bibeault
Sheriff
Posts: 67746
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
Hidden inputs are, well, hidden. So if you are going to use the first approach, you'd wan the value to be displayed, right? So hidden won't cut it.

Consider:


This makes the field visible, but read only. (You can use CSS to change the appearance of the field, such as removing borders.)

Be sure to enable the fields you want to submit before submitting the form.
 
Nag Venkat
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry i want to use 2nd approach,whre we are using hidden fields,what's my question is consider we have multiple rows...so when user clicks on two chekboxes ,then values of both the rows shoul be submitted right..Iam trying to use

for each of the td elemnet and get the selected checkbox value in jquery function like
($(this).find("td:first")..val....some thing like this not exactly. but some thing like this..
 
Nag Venkat
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how can i get the other values in that row,when a particular check box is checked
 
Bear Bibeault
Sheriff
Posts: 67746
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

hitendra sunkara wrote:sorry i want to use 2nd approach,whre we are using hidden fields,what's my question is consider we have multiple rows...so when user clicks on two chekboxes ,then values of both the rows shoul be submitted right


If you want to be able to submit multiple rows, the first approach is far cleaner. You could use a hidden input to repeat the value in the td (I personally think it's cleaner to use readonly and express the value only once).

for each of the td elemnet and get the selected checkbox value in jquery function like


As this is now about jQuery and the script necessary, I've moved it to the HTML/JavaScript forum.
 
Bear Bibeault
Sheriff
Posts: 67746
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
For your jQuery selection, you can use the .closest() method to find the enclosing <tr> element, and from there, find all the hidden input elements in that row, and enabled them.

Give the syntax a try and let's see how close you can get.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic