Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: IMPORTANT. For my job. lol. :C  (Read 2086 times)

0 Members and 1 Guest are viewing this topic.

Fox

Turnbeutelvergesser since 1988.
IMPORTANT. For my job. lol. :C
« on: October 09, 2007, 04:29:43 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Female
  • Posts: 4062
A sucky internship, won't get into details.

Basically, I need to make a website, and the customer wants this kind of menu. You click on a word in the menu-bar and then a sub-menu pops up, as in more links appear underneath the word you just clicked. See here:



If possible, tell me a code for HTML. I guess it's kinda hard, but I really damned need it.
Logged
  • Me on deviantART
Re: IMPORTANT. For my job. lol. :C
« Reply #1 on: October 09, 2007, 04:33:45 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6206
I think I have seen a tutorial for that! lemme search.

EDIT: Damnit! I can't seem to find it. >_>
« Last Edit: October 09, 2007, 04:37:04 pm by Hyrule_boy »
Logged
Re: IMPORTANT. For my job. lol. :C
« Reply #2 on: October 09, 2007, 05:01:32 pm »
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6629
Do you want a dynamic one (on where you don't need to reload the page) or one where you reload the page each click? I assume your probably after the first.
Logged

Fox

Turnbeutelvergesser since 1988.
Re: IMPORTANT. For my job. lol. :C
« Reply #3 on: October 09, 2007, 05:09:11 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Female
  • Posts: 4062
Actually, you should stay on the same site when the page opens.  So, Dynamic. :3
Logged
  • Me on deviantART
Re: IMPORTANT. For my job. lol. :C
« Reply #4 on: October 09, 2007, 05:21:26 pm »
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6629
Actually, you should stay on the same site when the page opens.  So, Dynamic. :3
This is pretty easy then (I think, haven't had a chance to check over). Basically you just need to enclose the sub-menu(s) in div tags that are set to be invisible, then when you click its parent menu you just need to set its tag to visible. All other parent menus will be moved down / up to make room for the new sub-menu(s).
Logged

Fox

Turnbeutelvergesser since 1988.
Re: IMPORTANT. For my job. lol. :C
« Reply #5 on: October 09, 2007, 05:39:56 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Female
  • Posts: 4062
Can you give an example-code? I have only very basic knowledge about HTML.
Logged
  • Me on deviantART
Re: IMPORTANT. For my job. lol. :C
« Reply #6 on: October 09, 2007, 05:48:57 pm »
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6629
Code: [Select]
<a onclick="document.all.submenu1.style.visibility = 'hidden';">Parent Menu Text</a>
<div id="submenu1" style="visibility: collapse;">
        Sub Menu Text
</div>
Probably something along those lines. I haven't had time to check it but that should give you an idea.
Logged

Fox

Turnbeutelvergesser since 1988.
Re: IMPORTANT. For my job. lol. :C
« Reply #7 on: October 09, 2007, 07:27:52 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Female
  • Posts: 4062
Didn't work.

I wrote this in a txt-file and saved it as an htm-file.

Code: [Select]
<html><body>

<a onclick="document.all.submenu1.style.visibility = 'hidden';">Parent Menu Text</a>
<div id="submenu1" style="visibility: collapse;">
        Sub Menu Text
</div>

</body></html>

Do I need to define something first or something? I have no idea, really.
Logged
  • Me on deviantART
Re: IMPORTANT. For my job. lol. :C
« Reply #8 on: October 09, 2007, 07:37:24 pm »
  • Oh.
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 579
Must it be in HTML?  Its extremely easy in Flash, you can figure it out yourself actully.
Logged
Hm.
Re: IMPORTANT. For my job. lol. :C
« Reply #9 on: October 09, 2007, 07:47:25 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1645
Code: [Select]
<html><body>

<a onclick="document.getElementByID['submenu1'].style.visibility = 'hidden';">Parent Menu Text</a>
<div id="submenu1" style="visibility: collapse;">
        Sub Menu Text
</div>

</body></html>
Perhaps something like this using HTMLDOM, I don't know :\ Never made this before.. What's your job anyways?
Logged
  • Virtual Security

mit

Re: IMPORTANT. For my job. lol. :C
« Reply #10 on: October 09, 2007, 08:15:44 pm »
  • QBASIC programmer since age 4. Take that, world.
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 1079
No, Helios just made a mistake, it should set to "visible" when you want it visible and "hidden" when you want it hidden.

Here's the first google result on the matter with a sample of code: http://www.devx.com/tips/Tip/13638
Logged
Programmer / Spriter / Level designer / Game Director / Web Designer / Music Sequencer for
Random Highscore table:

Play the Kousou Arcade today!
  • Kousou Games
Re: IMPORTANT. For my job. lol. :C
« Reply #11 on: October 09, 2007, 08:28:05 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1645
No, Helios just made a mistake, it should set to "visible" when you want it visible and "hidden" when you want it hidden.

Here's the first google result on the matter with a sample of code: http://www.devx.com/tips/Tip/13638
So it would be:
Code: [Select]
<html><body>

<a onclick="document.getElementByID['submenu1'].style.visibility = 'hidden';">Parent Menu Text</a>
<div id="submenu1" style="visibility: visible;">
        Sub Menu Text
</div>

</body></html>
Logged
  • Virtual Security
Re: IMPORTANT. For my job. lol. :C
« Reply #12 on: October 09, 2007, 09:15:42 pm »
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6629
I did say I didn't test it, It was only meant to point you in the right direction :P.

Quote
No, Helios just made a mistake, it should set to "visible" when you want it visible and "hidden" when you want it hidden.
Actually collapse is valid (Or maybe its CSS2 I'm thinking about), so it should work.
Logged

mit

Re: IMPORTANT. For my job. lol. :C
« Reply #13 on: October 09, 2007, 09:53:21 pm »
  • QBASIC programmer since age 4. Take that, world.
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 1079
I dunno, but what I meant was that you probably want it to start hidden, and appear when you click.
Code: [Select]
<script language="JavaScript">
function toggleVisibility(me){
if (me.style.visibility=="hidden"){
me.style.visibility="visible";
}
else {
me.style.visibility="hidden";
}
}
</script>


<a href="#" onclick="toggleVisibility(document.all.submenu1);">Parent Menu Text</a>
<div id="submenu1" style="visibility: hidden">
        Sub Menu Text
</div>

Using a function saves time if you need to use it more than once, just change the "submenu1" to something else. Also, it closes when you click it again.

More importantly though, is that when it's hidden, the text below doesn't move to compensate, so it leaves a gap, which I assume you don't want.

The solution in this case would be to use display:block and display:none instead of visibility. So the correct example is:
Code: [Select]
<html><body>

<script language="JavaScript">
function toggleVisibility(me){
if (me.style.display=="none"){
me.style.display="block";
}
else {
me.style.display="none";
}
}
</script>


<a href="#" onclick="toggleVisibility(document.all.submenu1);">Parent Menu Text</a>
<div id="submenu1" style="display: none">
        Sub Menu Text
</div>

</body></html>

which I actually tested, and it works.
Logged
Programmer / Spriter / Level designer / Game Director / Web Designer / Music Sequencer for
Random Highscore table:

Play the Kousou Arcade today!
  • Kousou Games

Fox

Turnbeutelvergesser since 1988.
Re: IMPORTANT. For my job. lol. :C
« Reply #14 on: October 10, 2007, 06:49:07 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Female
  • Posts: 4062
The thing is, this code only works with one point. If I add another one like this:

Code: [Select]

<a href="#" onclick="toggleVisibility(document.all.submenu1);">Mannschaft</a>
<div id="submenu1" style="display: none">
        Sub Menu Text<br>Sub Menu Text<br>Sub Menu Text</div><br>

<a href="#" onclick="toggleVisibility(document.all.submenu1);">Mannschaft</a>
<div id="submenu1" style="display: none">
        Sub Menu Text<br>Sub Menu Text<br>Sub Menu Text</div><br>

only the first one opens up, no matter which one I click. What am I doing wrong?

Edit: Nevermind, found it. Thanks a bunch, folks. x___x;
« Last Edit: October 10, 2007, 06:53:35 am by Fox »
Logged
  • Me on deviantART
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.255 seconds with 68 queries.

anything