473,503 Members | 12,383 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

collapsing and expanding data present in the div tag using javascript

54 New Member
Hi All,


I have two tables the top table displays the Name and one .gif file (- which is used for minimize).and the table below this is having data to be displayed.
When i click on this .gif(- which is used for minimize) i need to hide the data present in the second table.and then the .gif file must be changed to (+ which is used for maximize). when u click this the data should be present.Can anyone help me to write the code???I tried so many ways but i'm not able to get the output.I'm using myeclipse 6.0.
Jul 25 '07 #1
3 2593
gits
5,390 Recognized Expert Moderator Expert
hi ...

can you please post some example-code? that would make it easier to show you what to do exactly. generally you have to use the onclick-handler of your +/- image to catch the event and set the src of it according to your needs and then set the style.display of your 'content-table' to none or block ...

kind regards
Jul 25 '07 #2
ramadeviirrigireddy
54 New Member
Hi,

Here is the sample code:

Expand|Select|Wrap|Line Numbers
  1. <tr>
  2.      <td id="ofReg1" class="ofGridWidth5Col1">
  3.      <a name="content"></a>
  4.      <div class="ofTable">
  5.       <div class="ofAlt4BorderThick ofAltBorderColorB5">
  6.        <div class="ofWrapper">
  7.         <div class="ofDataDisplay">
  8.          <table class="ofxexpcoll" summary="This table displays general background information for this bond." >
  9.           <tr class="ofH3" onmouseover="geninfobgovr()" onmouseout="geninfobgout()">
  10.            <td colspan="2" bgcolor="#f2f2f0" id="geninfo"><h3>General Information</h3><a href="javascript:collapse()" tabindex="2"><img 
  11.  
  12. src="images/button_collapse.gif" width="14" height="14" alt="Collapse the General Information section" id="btn_collapse" class="ofxCollapsexpand" 
  13.  
  14. style="display:inline"  /><span class="ofOffScreen">Collapse the General Information section.</span></a><a href="javascript:expand()" tabindex="3"><img 
  15.  
  16. src="images/button_expand.gif" id="btn_expand" width="14" height="14" alt="Expand the General Information section." class="ofxCollapsexpand" 
  17.  
  18. style="display:none" /><span class="ofOffScreen">Expand the General Information section.</span></a></td>
  19.           </tr>
  20.           </table>          
  21.           <div id="geninfotabledata">
  22.           <table summary="This table displays general background information for this bond.">
  23.           <tr>
  24.            <th scope="row">Use of Proceeds</th>
  25.            <td>Private Higher<br />Education</td>
  26.           </tr>
  27.           <tr>
  28.            <th scope="row">State</th>
  29.            <td>Massachusetts</td>
  30.           </tr>
  31.           <tr>
  32.            <th scope="row">Min. Investment Qty</th>
  33.            <td>1000</td>
  34.           </tr>
  35.           <tr>
  36.            <th scope="row">Incremental Investment Qty</th>
  37.            <td>&ndash;&ndash;</td>
  38.           </tr>
  39.           <tr>
  40.            <th scope="row">Original Size</th>
  41.            <td>99,000,000,000</td>
  42.           </tr>
  43.           <tr>
  44.            <th scope="row">Outstanding Size</th>
  45.            <td>99,000,000,000</td>
  46.           </tr>
  47.           <tr>
  48.            <th scope="row">Marginable</th>
  49.            <td>Yes</td>
  50.           </tr>
  51.           <tr>
  52.            <th scope="row">&nbsp;Original&nbsp;Issue&nbsp;Discount</th>
  53.            <td>Long Term</td>
  54.           </tr>
  55.           <tr>
  56.            <th scope="row">Delivery</th>
  57.            <td>Book Entry</td>
  58.           </tr>
  59.           <tr>
  60.            <th scope="row">Bank Qualified</th>
  61.            <td>No</td>
  62.           </tr>
  63.           <tr>
  64.            <th scope="row">Day Count Basis</th>
  65.            <td>&ndash;&ndash;</td>
  66.           </tr>
  67.           <tr class="ofLastChild">
  68.            <th scope="row">Pre-Refunded</th>
  69.            <td>No</td>
  70.           </tr>
  71.          </table>
  72.          </div>
  73.         </div>
  74.        </div>
  75.       </div>
  76.      </div>
  77.  
Jul 25 '07 #3
gits
5,390 Recognized Expert Moderator Expert
hi ...

thank you ;) ... so now replace your two calls to collapse() and expand() with toggle() and use the following function:

Expand|Select|Wrap|Line Numbers
  1. function toggle() {
  2.     var t_container = document.getElementById('geninfotabledata');
  3.     var is_hidden   = t_container.style.display == 'none';
  4.  
  5.     t_container.style.display = is_hidden ? 'block' : 'none';
  6.  
  7.     var img = document.getElementById('btn_collapse');
  8.  
  9.     img.src = is_hidden ? 'images/button_collapse.gif' : 'images/button_expand.gif';
  10. }
  11.  
that should do the job ...

kind regards
Jul 25 '07 #4

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

Similar topics

4
10182
by: David | last post by:
It's sad to say, but when using the AOL web site, like to send an email, they have a nifty capability such that when a window is resized, the textarea where the message is input expands not only...
3
1938
by: MrKillington | last post by:
I'm having a problem with a script I'm writing. It's designed to expan a menu using the div tag and some scripting. Basically, there's division for the "upper level" menus and a division for the...
1
2184
by: Bhiksha Raj | last post by:
Hi, I created an expanding menu on one of the frames in my webpage using code I got from http://www.dynamicdrive.com/dynamicindex1/navigate1.htm I have embedded the code (with minor...
6
7329
by: Jack | last post by:
Hello, I would like some advice on how to disable the behavior of treeviews to expand and collapse when double clicked upon, but still allow the user to use the plus and minus on each node. ...
3
3274
by: Simon Harvey | last post by:
Hi all, Can anyone tell me what the easiest way to achieve a collapsable panel area in a datagrid is? Do I need to find a third party panel control or does the datagrid/gridview somehow support...
13
2720
Chrisjc
by: Chrisjc | last post by:
I am in need of an expanding and collapsing code… The goal is To be able to click a PICTURE IMAGE and expand to show information Reason for this is I have 3 TABLES of information of about ...
1
3370
by: Rahsaan Page | last post by:
Hello Everybody, I am trying to write a file Explorer program in Java, i go the Frame, Basic Menu and Tree going. But now i have the C: listed and i need some help expanding and collaping the...
1
5298
by: Jahedx99 | last post by:
Check out the site: www.progtalk.com. They have a great article to expand and collapse rows of a grid. The cool part it, that the expanding and collapsing happens using Javascript. I think the...
4
6375
by: Sean | last post by:
Hi, all, In a table I can easily get those expanding nodes (+ and - signs) to expand/collapse subdatasheets. How can I get those in forms? Thanks, Sean
0
7296
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,...
1
7017
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
7470
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
5604
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,...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3174
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1524
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
751
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
405
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.