i have implemented pagination in jsp.these values will come from DB. checkboxes are there against each record.when user checks 3 records in 1st page and goes to 2nd pages and again comes back to 1st page whatever user checked previously it should be checked.how to maintain this state in javascript ?How to achieve this functionality.i need to maintain the checkbox state across multiple pages?

Chaituu,

The easiest (and arguably the most reliable) approach is not to allow your 1st page to be destroyed. You can do this by opening 2nd page in either a popup window or within a iframe on the same page.

Otherwise, the solution depends on how the user returns to the 1st page.

If they use "back" (either the browser's back button or its scripted version), then 1st page may redisplay the correct check marks automatically (in some browsers some of the time).

However, if the user clicks a link that causes the 1st page to be recomposed and re-served, then realistically, your best choice is to coordinate things server-side. To facilitate this, you will need to store values (eg. three item ids) either client-side in a cookie, or server-side in the "session". Either way, you will need to arrange for your jsp code to recreate the checkmarks in accordance with the saved values.

There are also Ajax techniques, but you need not really consider these unless you are already using Ajax for other reasons.

Hope this helps.

Airshow

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.