473,406 Members | 2,345 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Problem with selecting Check box in a jsp

I have a JSP page that dynamically lists records in a table from my database. At the left hand side of each row in the table, there are checkboxes for the user to select a particular record that he/she wants to do manipulation. Here we are showing 100 records per page and user can go to next page in which it will show one more hundred records(ie 101 to 200)..As now the problem is when user has select the particular record in Page 1 and when go to Page 2 and if he come back to page 1 the selected paritcular is not checked.... how make it to selected...
Jul 24 '07 #1
6 7497
sumittyagi
202 Expert 100+
I have a JSP page that dynamically lists records in a table from my database. At the left hand side of each row in the table, there are checkboxes for the user to select a particular record that he/she wants to do manipulation. Here we are showing 100 records per page and user can go to next page in which it will show one more hundred records(ie 101 to 200)..As now the problem is when user has select the particular record in Page 1 and when go to Page 2 and if he come back to page 1 the selected paritcular is not checked.... how make it to selected...
keep an array of selected checkbox ids, and other info if needed in the session. whenever you go to any page check for the checkbox id, if exists then check it else let it be unchecked.
Jul 25 '07 #2
I have a JSP page that dynamically lists records in a table from my database. At the left hand side of each row in the table, there are checkboxes for the user to select a particular record that he/she wants to do manipulation. Here we are showing 100 records per page and user can go to next page in which it will show one more hundred records(ie 101 to 200)..As now the problem is when user has select the particular record in Page 1 and when go to Page 2 and if he come back to page 1 the selected paritcular is not checked.... how make it to selected...

Hi,

You can do one thing also. Whnever you move from one page to another put ids of the selected checkboxes in a temp table and then everytime fetch the ids at every page to make checkboxes checked.

After finishing this operation delete data from that table.

Regards,
Jul 27 '07 #3
oyis
8
I have a JSP page that dynamically lists records in a table from my database. At the left hand side of each row in the table, there are checkboxes for the user to select a particular record that he/she wants to do manipulation. Here we are showing 100 records per page and user can go to next page in which it will show one more hundred records(ie 101 to 200)..As now the problem is when user has select the particular record in Page 1 and when go to Page 2 and if he come back to page 1 the selected paritcular is not checked.... how make it to selected...
Hi,
I have a JSP page same as yours.
I can select the checkbox but I can't get the values...
I want to select the checkbox and it gives me value of data.
all things must be dynamically.
please helppp me :(
Jul 27 '07 #4
r035198x
13,262 8TB
Hi,
I have a JSP page same as yours.
I can select the checkbox but I can't get the values...
I want to select the checkbox and it gives me value of data.
all things must be dynamically.
please helppp me :(
Can you be more specific about your problem? Where are you failing to get the value?
Jul 27 '07 #5
oyis
8
Can you be more specific about your problem? Where are you failing to get the value?
ı think , if I sent my code you can understand easily;

create table function;


var tbody = document.getElementById('t1').getElementsByTagName ('tbody')[0];
var row = document.createElement('TR');
var cell1 = document.createElement('TD');
cell1.innerHTML = myA[i];
var cell2 = document.createElement('TD');
cell2.innerHTML = myB[i];
var cell3 = document.createElement('TD');
var checkBox = document.createElement('INPUT');
checkBox.setAttribute("type", "checkbox");
cell3.appendChild(checkBox);
checkBox.checked = false;

row.appendChild(cell1);
row.appendChild(cell2);
row.appendChild(cell3);
tbody.appendChild(row);


i want to select one or more row to delete from table.
and i want to know which row is selected when i check the checkbox ...
may i explain now?
Jul 27 '07 #6
sumittyagi
202 Expert 100+
ı think , if I sent my code you can understand easily;

create table function;


var tbody = document.getElementById('t1').getElementsByTagName ('tbody')[0];
var row = document.createElement('TR');
var cell1 = document.createElement('TD');
cell1.innerHTML = myA[i];
var cell2 = document.createElement('TD');
cell2.innerHTML = myB[i];
var cell3 = document.createElement('TD');
var checkBox = document.createElement('INPUT');
checkBox.setAttribute("type", "checkbox");
cell3.appendChild(checkBox);
checkBox.checked = false;

row.appendChild(cell1);
row.appendChild(cell2);
row.appendChild(cell3);
tbody.appendChild(row);


i want to select one or more row to delete from table.
and i want to know which row is selected when i check the checkbox ...
may i explain now?

Your code is unmanaged.
Whether you code in any language, the rule is to first analyze your problem then go for coding.

The solution to your problem is to maintain a counter, and give name to your controls according to that counter.

If there are 4 rows already displayed(according to the records in the database), and according to some mainpulation more rows could be added. Then initialize your counter to 4. and with each manipulation increment the counter accordingly.

for eg. you are having a checkbox, a txtbox and a selectbox each row.
Then these could be named as chkABC0, chkABC1..., txtABC0, txtABC1,... , selABC0, selABC1....
here 0, 1, 2... are appended to the controls according to the counter.
so chkABC0, txtABC0, selABC0 belongs to the first row.

I think you would have got the point.

And remember, always keep in mind how you will extract an information before storing it. I noticed you havn't given any name or id to your checkboxes. How will you be able to get the reference of those checkboxes for manipulation.

Second thing is you should think of a better way of retriving information while checking for alternatives.
eg. you gave ID to your table, and then from that table extracted an array of tbody elements, and selected first element from that array.
You could have given id to tbody element itself.

So I would suggest you to reconsider your problem domain, think of how you will manage you objects then go for coding. I am saying this because there might be even better way of doing this thing. Projects that fail are 90% due to mismanagement, and 10% due to other reasons.
Jul 30 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Adam Toline | last post by:
In reference to the following: http://www.bellecose.com/form.htm At the top of each column there is a box for "All". When one is checked I need to check all of (and only) those boxes...
1
by: erkwong | last post by:
Hello, What would be the simplist way to get the current date to populate a text box upon the de-selecting of a check-box (aka making the check box field false?) This is basically what I had...
8
by: dixie | last post by:
I have a method of tagging people to put in a list box on a form by simply turning on a Yes/No field in the table of people. When the listbox is requeried, the right people are in the list box. ...
1
by: Tamir Gal | last post by:
Hi, I'm using the CheckedListBox control, and I'm wondering if there is a way to let the user check an item in the list without also selecting it... Any ideas? Thanks in advance, Tamir.
1
by: Jay | last post by:
Hi All, My users are complaining about the page refreshing when they are selecting multiple rows in a datagrid. Has anyone tried to manage this using javascript? I tried smartnavigation but that...
1
by: Dave | last post by:
Hello. I have DeropDownList control on my page and want to select some value by SelectedValue, but before selecting I want to ensure that the value exists in DeropDownList control's items. How...
6
by: Pat | last post by:
When selecting a DropDownlList to display some Data based on the ddl.SelectedItem.Value since a dropdownlist index starts from 0.. After selecting for example value1 and 2 which its ok but when...
6
by: @sh | last post by:
Guys, I've written an email sending script to mass send to our database - some of our subscribers are subscribed to multiple list, and so when selecting the entire database, I want to ensure I...
2
by: rocksoft | last post by:
Hi I am working in asp.net with C# web application, I have used visual studio 2003, i have used dropdownlist in my application to populate the data from mysql database, i have got problem while...
7
by: psybert | last post by:
Hello everyone, Long time lurker, first time poster. I'm a beginner coder, and I've taught myself everything with the help and expertise of users and websites like this one. I normally figure out...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.