yeah i need some help(such a common line) ,i have a menu and each link has its own div respectively and yeah obviously when u click the link the div shows, the problem is i would like each div to show no matter how many times you click the link for it and if you click on another one and when u go back to the original , the div would still show. at the moment i have partially done that, i click on item a ,that shows then when i click item b that shows and if i go back to item a it shows again, but i can only get it 2 wrk like that with 2 divs how do i do it so it wrks with multiple divs , so if user comes n clicks on item b it'll show, if it click on item a it'll show n if it clicks on item c it'll show and if it was to revisit item a ,b or c they all will still show.
i am i beginner so please if i have many mistakes do understand, feel free to make any corrections or if you have any better ideas,thank you
i did some testing with the swapsee bit of code by adding div 3 and 4 onto the existing code on the first line and adjusting the rest of the code accordingly but it didnt work .
here some code,
the code includes the menu code and the divs and how i have partially achieved wht i wanted as i mentioned before using the swapsee function or element: 21 2365 gits 5,390
Recognized Expert Moderator Expert
hi ...
as far as i understand you want to display a special div when clicking a link and hide all other divs then. so you could adapt your function the following way: - function toggle_div_visibility(id) {
-
var div_list = document.getElementsByTagName('div');
-
-
for (var i = 0, node; node = div_list[i]; i++) {
-
node.visibility = node.id == id ? 'visible' : 'hidden';
-
}
-
}
now simply pass the id of the div you want to show to that function ... all other divs will be toggled to hidden ...
kind regards
now simply pass the id of the div you want to show to that function ... all other divs will be toggled to hidden ..
wow never expected a reply so soon , thanks for the reply i have'nt tried it out yet but i will sure do ASAP, just one thing explain what u ment by the above quote ,i think i know what u mean but i thought i'd ask just in case , thanks.
gits 5,390
Recognized Expert Moderator Expert
you pass the id of the div that has to be displayed ... and the function sets its visibility to visible while all! other divs will be set to be hidden.
kind regards
you pass the id of the div that has to be displayed ... and the function sets its visibility to visible while all! other divs will be set to be hidden.
kind regards
ah i understand that now but how do i 'pass' the id of the div,sorry ,bit slow :)
sorry,can you show me where you would put that code you gave using my code given above,i know its kinda getting you to do the work for me , its just that i won't understand until i see it like that,would you have to then change the code in the links too? because its like this at the moment: - <li><a href="javascript:swapsee('metal','mydiv');"
-
onmousedown="slidedown ('mydiv');">Divans</a></li>
-
gits 5,390
Recognized Expert Moderator Expert
:) ok ... try this: - <a href="#" onclick="toggle_div_visibility('my_div');" onmousedown="slidedown ('mydiv');">Divans</a></li>
-
kind regards
hey thnks for replying, i tried the above ,it doesnt wrk,if i click on the links ,they all show the once but if i want to revisit them, they dnt show, it stays stuck on the last thing i clicked (confused!:( ).
gits 5,390
Recognized Expert Moderator Expert
aaargh ... sorry my bad ...
error is here (instead of node.visibility use the following): - node.style.visibility = ...
have a look at the following example:
[HTML]<html>
<head>
<script type="text/javascript">
function toggle_div_visi bility(id) {
var div_list = document.getEle mentsByTagName( 'div');
for (var i = 0, node; node = div_list[i]; i++) {
node.style.visi bility = node.id == id ? 'visible' : 'hidden';
}
}
</script>
</head>
<body>
<div id="my_div1" style="visibili ty: hidden;">test 1</div>
<div id="my_div2" style="visibili ty: hidden;">test 2</div>
<div id="my_div3" style="visibili ty: hidden;">test 3</div>
<div id="my_div4" style="visibili ty: hidden;">test 4</div>
<div id="my_div5" style="visibili ty: hidden;">test 5</div>
<a href="#" onclick="toggle _div_visibility ('my_div1');">t est1</a>
<a href="#" onclick="toggle _div_visibility ('my_div2');">t est2</a>
<a href="#" onclick="toggle _div_visibility ('my_div3');">t est3</a>
<a href="#" onclick="toggle _div_visibility ('my_div4');">t est4</a>
<a href="#" onclick="toggle _div_visibility ('my_div5');">t est5</a>
</body>
</html>
[/HTML]
kind regards
well the function works,only one problem it makes all the other divs that make up the layout of the page dissappear..... is there way so you can specifically tell the function to only hide the ones that are used as links im wondering...i tried adjusting the code my self but no success, actually thats no surprise considering im a beginner!
this is what i changed it to, it made sense to do it , i was looking at the div list bit so i thought if i give it a list, it might work, evidently it did not :(
i guess from a programming perspective , that code below wouldnt mean anything... - var div_list = document.getElementsById('mydiv','metal','pine','bunk');
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Phil N |
last post by:
Hi all.
I've been here before and got a lot of help with my neophyte troubles so I'm
back again.
This time I have a number of questions (if I can remember them all).
(I've pasted the code in question at the end of this message and installed it on
the web at http://www3.telus.net/bikim/test .)
|
by: Preston Crawford |
last post by:
I know this is probably a dumb question so please be patient with me. I've
been doing HTML since 1994, but mostly for projects that had to be as
completely compatible as possible and mostly existing projects. So that
meant dealing with the traditional table layouts (i.e. using tables for
the entire structure of a page). I'm just not getting to...
|
by: David |
last post by:
Hi everyone,
Hoping there are some .js/browser experts out there that can help with this
weird problem.
I have made a swap div routine and applied the events to menu buttons with a
closer layer behind the menus. The closer div has a lower index than the
submenu divs so it appears behind them. The closer div contains a
transparent gif...
|
by: David |
last post by:
Hi,
I am developing a NotifyIcon app with C#. I want to show the context menu
when user left-clicks on the icon, the same as he/she right-clicks on it. In
that event handler, myNotifyIcon_Click(), I call
myNotifyIcon.ContextMenu.Show method. But I am not sure what these two
parameters I should feed.
Thanks in advance.
|
by: PontiMax |
last post by:
Hi,
when I press the OK button of my dialog box a long-running task is
initiated. Therefore I would like to make visible a div section right after
clicking the button where a user-friendly message is displayed...
How can this be done? Can I make the section visible via server-side code?
Via Response.Write()?
Any examples would be...
| |
by: fizzyfozzy |
last post by:
Hi,
I am trying to figure out how to show or hide a selection of divs on my page depending on what is selected from a list/menu item, using css & javascript.
I have tried to use the script listed here: http://www.thescripts.com/forum/thread88791.html
but have been uable to customise it to my needs and could do with some help.
My form is...
|
by: dusk |
last post by:
Hi,
I have a page with lots of hidden divs which are revealed based on choices made at each 'layer'.
So I've used naming convention which represents the order in which each div becomes visible - 'a100', 'a200', 'a300' for the first 'layer'; 'b100', 'b200', 'b300' for the second; 'c100, 'c200', 'c300' for the third ... etc
I'm writing...
|
by: richard |
last post by:
I'm working on a menu system where I have a 3 column table affair.
On start, you see a menu list in column 1.
Column2 will have some general information.
Column3 is an iframe for final data input.
About every damn thing I've seen on how to do this is the pure bare
bones basics. That is, click button 1 to hide, click button 2 to show.
Not...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
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. ...
|
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...
| |
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...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |