Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Replacing one DIV with another

 
Divya Chandrasekhar
Greenhorn
Posts: 21
Chrome Java Oracle
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am fairly new to Java script.
My problem is as follows:
I need to replace one DIV with another.
The first div, "div1", is shown on page entry; "div2" is initially hidden.
"div1" contains a small form. On click of the submit in "div1", the back-end is hit and we fetch some data which then needs to be populated in "div2" when we get redirected back to this page, so I want "div1" to be replaced by "div2".
Any help will be appreciated!
Thanks,
Divya
 
Rajkamal Pillai
Ranch Hand
Posts: 445
1
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Have an onload() function which hides/displays the corresponding DIV based on some parameter on the JSP.
 
Divya Chandrasekhar
Greenhorn
Posts: 21
Chrome Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Raj,

thanks for your reply. can you please show me an example?

Thanks,
Divya
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64715
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you doing this with JavaScript in the first place? If the decision regarding which section to show is made on the server, simply use a JSP conditional to include the section or not. Including both sections only to completely hide one of them after the page gets to the client makes no sense. Using JavaScript to do this only makes sense if the decision needs to be made on the client rather than the server.
 
Komal Renu
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, you could use the <logic:present> tag to check whether the data list for section two is null or not. if it is, display section one, else display section two.

Thanks and Regards,
-------------------------------------------------------------------------------------
Komal Renu | krenu@infocepts.com | www.infocepts.com
-------------------------------------------------------------------------------------
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic