473,836 Members | 2,035 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

expandable divs question for lengthy page

8 New Member
I am using the following script for expandable divs but ...the focus is on the top of the page ie..the div id #quiz, and I am trying to use if for a lengthy FAQ page.
when you scroll to the bottom of the page and open a question, the focus pops back to the top of the page.
I thought of defining several sections, but when I do only one is collapsed, the others are open on page load

Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript" type="text/JavaScript"> 
  2. indent=5;//set here the left indent in pixels 
  3. iup='images/blueup.gif'//set here the up arrow relative location 
  4. idrop='images/bluedrop.gif'//set here the drop arrow relative location 
  5. //No need to modify below 
  6. function coll(){ 
  7. var dd=document.getElementById('quiz').getElementsByTagName('div'); 
  8. var aa=document.getElementById('quiz').getElementsByTagName('im'); 
  9. for (var i=1;i<dd.length;i=i+2){ 
  10. dd[i].style.position='relative'; 
  11. dd[i].style.display='none'; 
  12. dd[i].style.left=indent+'px'; 
  13. for (var j=0;j<aa.length;j++){ 
  14. im=aa[j].getAttribute('src'); 
  15. if(im==idrop){ 
  16. aa[j].setAttribute('src',iup);break 
  17. function activ(w){ 
  18. var d=w.parentNode.getElementsByTagName('div')[0]; 
  19. var a=w.firstChild; 
  20. if(d.style.display=='none'){ 
  21. coll(); 
  22. d.style.display='inline'; 
  23. a.setAttribute('src',idrop); 
  24. else{ 
  25. d.style.display='none'; 
  26. a.setAttribute('src',iup); 
  27. onload=coll; 
  28. </script>

http://www.nmprc.state.nm.us/ftalfaq2.htm
Feb 28 '07
16 2023
acoder
16,027 Recognized Expert Moderator MVP
Threads merged.
Mar 12 '07 #11
kdeguero
8 New Member
Thanks, but they are set to display none.
What I have found is that in a tabbed page, you must put the javascript at the beginning of the tab instead of the page to get the divs to collapse.
But when I have a set of divs on each tab, I can only get one set to collapse. I tried renaming the set to quiz2, I also tried renaming the function that is called, even renamed all the variables, but I can only get one set or the other to close on load, not both.
Mar 12 '07 #12
acoder
16,027 Recognized Expert Moderator MVP
No, I didn't mean close them. They shouldn't even be open in the first place.

Either set an inline style, e.g.
[HTML]<div id="..." style="display: none;" ...>[/HTML] or declare this in a style sheet using the class name.
Mar 12 '07 #13
kdeguero
8 New Member
I tried both but the effect of both is the same, all within the div tag is not displayed.
I am sorry, I just do not know how to fix this myself
Mar 12 '07 #14
acoder
16,027 Recognized Expert Moderator MVP
In your style1, you've set display to 'block'. Set it to 'none' and see if that works.
Mar 13 '07 #15
kdeguero
8 New Member
I even thought of that, and it does work to collapse the questions, in appearance, but when clicked no answers show either.
Mar 13 '07 #16
acoder
16,027 Recognized Expert Moderator MVP
In the onclick, just set the display to 'block' and it should show.
Mar 13 '07 #17

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

Similar topics

2
1920
by: Amir S. | last post by:
Hi guys... Does anyone know a tool (preferably free) that would generates code for the cute expandable navigation system that uses pluses and minuses? An example can be seen on the left nav bar of the following page: http://office.microsoft.com/training/training.aspx?AssetID=RC061050921033&CTT=6&Origin=RP062013981033 THanx for your help in advance!
12
6310
by: deko | last post by:
Is there any way to work around the blank space created by hidden divs? I'm trying to use a relatively postioned divs with show/hide behaviors to annotate an image. The divs show/hide onMouseOver/onMouseOut but leave a blank space on the page when hidden (the space where the divs would normally be). Is it possible to use z-indexing to put regular content where the hidden divs would be? When I try to do this, the layers don't unhide as...
3
13779
by: Marc | last post by:
Hi to all, I have several DIVs in a page, each has a unique name. I'd need a method to cycle through all DIVs so that I can change their style. For example, let's say I need to set a red background to DIVs whose name begins with "a". This is the pseudo code: For Each Div in The Page If Div's name starts with 'a' then set Div's background to Red Next
0
5570
by: Brian Young | last post by:
Hi all. I'm using the Property Grid control in a control to manage a windows service we have developed here. The windows service runs a set of other jobs that need to be managed. The control is used to view the state of the running jobs and schedule new jobs. The control also runs in the context of Internet Explorer (we do this so the administrators of the jobs can always receive the latest control). The property grid is used to...
5
2373
by: KitKat | last post by:
I've got two queries; one is a modification of an older query; the other I created from scratch. The old one is about 5 copies down the road from something that has been expandable when I'm in View mode--it showed the Points of Contact for records whose Begin Date was in a form-selected (or manually inputted) year. That used to be all it did. Then copied it, took out the year criterion, and changed "POC" to show the Director field...
1
9167
by: axlq | last post by:
I've seen a lot of examples of expandable/collapsable lists, such as these nice examples: http://www.karlnelson.net/nestedlists/ and http://dynamicdrive.com/dynamicindex1/navigate1.htm They use javascript of course, and that's the problem. There's no graceful degradation with javascript disabled. Any links in the hidden sub-items will become inaccessible.
2
8294
by: tasman.hayes | last post by:
I'm experimenting with converting a site from a table layout to CSS. I'm floating three DIVs in a row for the top of a website (a logo, navigation buttons and a email list signup box). The DIVs have a grey background. When I view the page in Firefox, I get what I hoped for: there is a solid grey rectangle at the top of the website. When I view the page in Internet Explorer 6 (WinXP), there is a gap between two right hand DIVs (i.e. a...
3
1831
by: Carl Gilbert | last post by:
Hi I am looking to convert a site from HTML to ASP.NET making use of CSS. I have tried various combinations but I can not seem to get the correct combination of div and CSS tag configurations. I have uploaded a screenshot (http://www.bwbfc.com/math/regions.jpg) of how the screen will be laid out. Firstly it is all cantered in the window. I plan to create a master page which would contain the header (in blue), the footer (in yellow)...
11
7851
by: dusk | last post by:
Hi, I'm very new to javascript, and I'm having trouble finding a way to display a string of divs without the code getting really messy. I have several different pages to write, each with about 15-20 divs, and I need users to be able to select a sequence of divs - basically like a series of yes/no questions that, when "yes" or "no" is selected, displays the appropriate div as well as what's come before it. I can hide all divs and display...
0
9670
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10844
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10548
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10591
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9374
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7792
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5826
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4452
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 we have to send another system
2
4016
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.