| Author |
saving multiple rows
|
bubu lina
Greenhorn
Joined: Aug 11, 2008
Posts: 28
|
|
hello
i have some stupid problems at jsp-servlet comunication.
in my jsp i have a table with multiple columns, <input type="text"..> and one column that has a checkbox. of course i take the data from a database,so i can have a lot of rows in that table. My plan is to have this checkbox being editable..for any row. So when the user pressed the "save" button, it saves the changes in db. I have the checkbox a name, to send it to the servlet . this works correct. now i wanted to detect when the users checks and unchecks the checkbox.
This is done with js i presume, at onclick. but i don't get what i am seding in that javascript, so i can use in the servlet, (in my logic of distinguishing the cheked and uncheck box).
as i said, trivial question, but i am a bit stuck. thank you
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56216
|
|
|
If the checkbox is unchecked it will not be sent to the server as part of the form submission.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
bubu lina
Greenhorn
Joined: Aug 11, 2008
Posts: 28
|
|
|
then how can i make a list of unchecked rows?
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56216
|
|
|
The ones that don't come back are the unchecked rows.
|
 |
bubu lina
Greenhorn
Joined: Aug 11, 2008
Posts: 28
|
|
|
yes..but doesn't this make the recognizing the row that had the checkbox modified kinda difficult?
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9189
|
|
|
What you need to do is to disable textboxes whose checkbox is not checked (i.e. the checkbox in that row). This can be done using javascript and DOM. Also you can actually do this only on the server side. If my checkboxes are named "rowNo" having values 1 for the checkbox in first row, 2 for the checkbox in 2nd row and the textboxes are named name1, age1 for first row, name2, age2 for second row, then you can easily extract only the elements from the request parameters whose checkboxes were checked...
|
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
|
 |
 |
|
|
subject: saving multiple rows
|
|
|