Click here to Skip to main content
16,022,752 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more: (untagged)
Hello,

I have a web page (in C#) that stores news and events. The data (news and events) is categorized by month. When the user visits the page, I would like to display the content of the existing month only. For example, the user will see.

August
event 1
news 2

July
June
May
April

I would like the user to be able to click on any other month to display the content of that respective month. Ideally, only one month should be expanded at a time (however this is not imperative).

Any help or assistance would be appreciated. If you need more information please let me know.

Thank you,

Allison
Posted

1 solution

why dont you use Javascript to display / hide content.

Say you have used the html code block as below :

<div onclick="javascript:expandCollapsePane(this, 'dvContainer');"><br />August<br /></div><br /><div id="dvContainer"><br />Event 1 <br />News 2<br /></div>



Now when user clicks on the Div Pane named august you can make the container div visible true or false :

function expandCollapsePane(obj, pane) {<br />   var containerPane = document.getElementByID(pane);<br />   var isCollapsed = (containerPane.style.display == 'none');<br />   if (isCollapsed) {<br />      containerPane.style.display = 'block';<br />   }<br />   else {<br />      containerPane.style.display = 'none';<br />   }<br />}


The javascript just hides the dvContainer on click. To make all of them invisible when one is open, just create an array of all such elements you create and before expanding anyone of them do a for loop and hide each other element in the block.

Hope you understand. [thumbs up][Rose]

 
Share this answer
 


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900