aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes how to send table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "how to send table "td" values to another jsp when particular row checkbox is checked" Watch "how to send table "td" values to another jsp when particular row checkbox is checked" New topic
Author

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

hitendra sunkara
Ranch Hand

Joined: Jul 25, 2013
Posts: 35
hitendra sunkara
Ranch Hand

Joined: Jul 25, 2013
Posts: 35
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
hitendra sunkara
Ranch Hand

Joined: Jul 25, 2013
Posts: 35
is that change okay ,or else do i need to change any thing else,Sory i am new to this form
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61761
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61761
    
  67

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.
hitendra sunkara
Ranch Hand

Joined: Jul 25, 2013
Posts: 35
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
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61761
    
  67

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.
hitendra sunkara
Ranch Hand

Joined: Jul 25, 2013
Posts: 35
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..
hitendra sunkara
Ranch Hand

Joined: Jul 25, 2013
Posts: 35
how can i get the other values in that row,when a particular check box is checked
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61761
    
  67

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
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61761
    
  67

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to send table "td" values to another jsp when particular row checkbox is checked