PDA

View Full Version : Subnavigation.



Fehm
10-08-2009, 05:58 PM
Hey

I was wondering whether anyone could help me sorting my Sub navigation on my new site?

Basically I need it so that when the user clicks on one of the top menu items, links to seperate categories load in a bar that is premade for it..

Can anyone help? :)

kk.
10-08-2009, 06:01 PM
hm, the thing i could suggest is using iframes or other similar coding. But i cant help you sorry

Fehm
10-08-2009, 06:08 PM
I thought about iFrames. But I dunno.. I just dont like the idea of them :/

kk.
10-08-2009, 06:15 PM
yeh neither do i lol. im sure theres some php or java code you can use, or even an onclick div, but im not sure

BoyBetterKnow
10-08-2009, 06:20 PM
www.jquery.com

Fehm
10-08-2009, 06:26 PM
I looked into onclick divs. Im really unsure :(

Fehm
10-08-2009, 06:50 PM
Someone must be able to help me :(

BoyBetterKnow
10-08-2009, 07:25 PM
Someone must be able to help me :(

Outline javascript.

html file


<div id="monkey">
Text
</div>

<script src="jsfile.js" type="egtskfdlks"></script>


Then in js do like


('#money').click(function(){

alert('div has been clicked');


};

Dunno if ne of that works soz.

Fehm
10-08-2009, 07:33 PM
I've never used Javascript before :( Sorry. But thanks for your help. I found something to do with jQuery but it didnt work lol

Fehm
11-08-2009, 08:16 PM
Does anyone have any ideas on how to use jquery? Ive found a few tuts and they just dont seem to work to my advantage? :P

BoyBetterKnow
11-08-2009, 08:45 PM
Does anyone have any ideas on how to use jquery? Ive found a few tuts and they just dont seem to work to my advantage? :P

Read my sig :D

Fehm
11-08-2009, 08:51 PM
I'll give it a miss ;) Spent enough just lately :p

pepsi
11-08-2009, 10:06 PM
PHP includes or AJAX I'd say.

iDenning
12-08-2009, 11:44 AM
Iframes is your best best, or i suggest AJAX

Fehm
12-08-2009, 12:13 PM
iFrames are grotesque. No offence.

I'll just use jQuery, much easier I think.

Mickword
12-08-2009, 12:14 PM
Just use iframes, its much much easyer.

Fehm
12-08-2009, 12:17 PM
But they're horrible.
Honestly... Read the thread

BoyBetterKnow
12-08-2009, 12:29 PM
Just use iframes, its much much easyer.

Yeah they're easier but not as effective.

Fehm
12-08-2009, 01:36 PM
Really wish I understood this lol

Dentafrice
12-08-2009, 04:56 PM
Just use iframes, its much much easyer.
Coming from someone who can't spell easier.

Dentafrice
12-08-2009, 05:24 PM
See if this works for you, you need prototype.

Demo: http://calebmingle.com/subnav/

index.html:



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Subnavigation Test</title>

<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/scriptaculous.js"></script>

<script type="text/javascript">
function change_nav(nav) {
new Ajax.Updater('subnav', 'subnav.php?nav=' + nav);
}

change_nav('home');
</script>

</head>

<body>
<a href="#" onclick="javascript:change_nav('home');">Home</a> || <a href="#" onclick="javascript:change_nav('us');">About Us</a> || <a href="#" onclick="javascript:change_nav('habbo');">Habbo</a> <br /><hr /><br />
<div id="subnav"></div>
</body>

</html>


subnav.php



<?php
//
// subnav.php
// Subnavigation Script
//
// Created by Caleb Mingle on 2009-08-12.
// Copyright 2009 MacDowell Diesel Performance. All rights reserved.
//


// ================================================== =========
// = Switches the navigation based on what the user provides =
// ================================================== =========

switch($_GET["nav"]) {
case "home":
echo '<a href="home.php">Home</a> | <a href="home2.php">Other Home</a>';
break;

case "us":
echo '<a href="about.php">About Us</a> | <a href="contact.php">Contact Us</a>';
break;

case "habbo":
echo '<a href="guides.php">Guides</a> | <a href="badges.php">Badges</a>';
break;
}

BoyBetterKnow
12-08-2009, 07:17 PM
Caleb why do you use case switch etc.

if / else is faster lol.

But good job for helping.

Dentafrice
12-08-2009, 08:34 PM
Caleb why do you use case switch etc.

if / else is faster lol.

But good job for helping.
I love how you try and correct me, like you think you know better. I'm sorry, but you're wrong.

Thanks for the "good job for helping though".

http://img.skitch.com/20090812-qywfp7quwjf9g38ph28jgs83aa.png

BoyBetterKnow
12-08-2009, 08:40 PM
I love how you try and correct me, like you think you know better. I'm sorry, but you're wrong.

Thanks for the "good job for helping though".

http://img.skitch.com/20090812-qywfp7quwjf9g38ph28jgs83aa.png

Lmao I wasn't trying to correct you. I just read that if/else is faster.

I don't know better, you're a better coder than me by far lol.

You did switch($nav); without defining what $nav is. Please re run the tests for me..

Dentafrice
12-08-2009, 08:43 PM
Just because you read it, doesn't mean it's true. And going around telling someone, "if/else is faster", when you.. yourself.. haven't tried it.. is plain stupid.

http://img.skitch.com/20090812-d3dssk8kh1wqfhy7544r52db62.png

Fehm
12-08-2009, 08:59 PM
okay guys... Thanks for your help anyway :p

Dentafrice
12-08-2009, 09:01 PM
Is my script not what you wanted it to do? lol.

BoyBetterKnow
12-08-2009, 09:06 PM
Yeh. Neither if / else or case seem faster

IF (Just with ifs, no elses, works nicely)
http://www.youtubeuktop40.com/bench/Benchmark-1.2.7/if.php

Case
http://www.youtubeuktop40.com/bench/Benchmark-1.2.7/case.php

But if you go onto phpbench, apparantly case is faster. I don't see that :P But it's stopped me from saying that either are faster.

Want to hide these adverts? Register an account for free!