• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Replacing one DIV with another

 
Greenhorn
Posts: 21
Oracle Chrome Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 479
1
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Oracle Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Raj,

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

Thanks,
Divya
 
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 | [email protected] | www.infocepts.com
-------------------------------------------------------------------------------------
reply
    Bookmark Topic Watch Topic
  • New Topic