Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Maintain checked checkbox status  RSS feed

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone

In my JSP application, i have database table stored in mysql. when i display there recors using checkboxes and select multiple checkboxes, and after submitting button , it should display that "selected checked checkboxes" in same page but in another table.

and at same time, after "Refreshing " that page or after coming to that page using "Href link" , it should maintain previously selected checkboxes . So, my ultimate aim is to avoid "duplicate " selection of checkbox records .


i am stuck with this problem from 2 days . I tried a lot .But please give me example code, so that it helps me.

Please , help me out. Thank you in advance
 
Author and ninkuma
Marshal
Posts: 66783
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All you need to do is to set the checked attribute on the checkboxes that you would like to have checked.
 
rahulj rjagtap
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you Bear Bibeault for your reply

But could you please give me some example code, so that it is more helpful to me. OR i can send you my code so that you can make do some modifications. Please, waiting for your reply.
Thank you in advance
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66783
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post code in the forums please. Be sure to use code tags and be sure to show only the relevant portions.
 
rahulj rjagtap
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for yor reply. I am sending some code .

Domain.java


Category.java


DomainDAO.java


test1.jsp



test2.jsp



above, i have attached my code. So, please help me out.I am new to jsp and java. So, if there are any mistakes in code, please correct it n please guide me.

Thank you for your help in advance
 
author & internet detective
Marshal
Posts: 38502
653
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a lot of code. Are you able to reproduce the problem with less code?
 
rahulj rjagtap
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ..thanks for your reply
sorry , last time i have send a very long code. Sorry, i am new to java,jsp and this forum but this time ,I am sending my short code.Please, help me out.

test2.jsp


i am waiting for your reply.. please, help me out

Thanks for your help in advance.
 
rahulj rjagtap
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone....please help me someone to solve my code problem ...i am stuck this code from 4 days..

please, reply me .

Your any reply is appreciable and thanks in advance
 
Ranch Hand
Posts: 40
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rahul,

Assuming that String domainnames[] contains list of previously selected domain Ids, then to check the previously selected domain you have to try out

<c:forEach var="domain" items="${domainmap}">
<tr><td>
<input type=checkbox name=selecteddomains value="${domain.value.domainName}"

<c:forEach var="domainId" items="${domainnames}">
<c:if test="${domainId==domain.value.domainId}">
checked="checked"
</c:if>
</c:forEach>
/> //close of input

Please verify syntax from your side, its been long I have worked on JSTL, but you can follow the logic

<c: out value="${domain.value.domainName}" ></c: out>
<c: out value="${domain.value.domainId}"></c: out>
</td></tr>
</c:forEach>
 
rahulj rjagtap
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your reply.

I have checked following syntax:

<c: out value="${domain.value.domainName}" ></c: out>
<c: out value="${domain.value.domainId}"></c: out>


It is correct and it prints selected domainName & selected domainId.

I tried your code, but still it is not maintaing state of previously selected checkboxes after refreshing page or visited again.

please, reply me soon. I am waiting.
Thank you for your help in advance
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!