Jump to content

Help with code


Agent Moose

Recommended Posts

I am hoping you can help me with a code I am trying to make for ZetaBoards. It adds a drop-down menu with what ever links you want in it.

<script>function dropdown(sname,lurl){//Code Created by Agent Moose$(".drop_menu").before("<ul id='top_menu' class='drop_menu'><liid='menu_ucp'><a href='#'><img src='http://209.85.62.27/static/1/m_ucp.png' /> "+ mname +"</a><ul><li><a href='"+ lurl +"'>"+ sname +"</a></li></ul></li></ul>");}mname = "Pages"dropdown("Arcade","http://beta.zetaboards.com/MooseCreations/pages/arcade");</script>
I want it to make it so that when you make more of these:
It will add more links to the dropdown menu.Also, I would like it you added more of these:
mname = "Pages"
it will make a new whole new dropdown menu.and you will be able to add diffrent links to each drop-down menu.wanna help me?
Link to comment
Share on other sites

First off, your current function doesn't handle mname.

function dropdown(mname,sname,lurl) {	 if(mname != "") {		  output = "<select name='"+mname"' onchange='gotoURL()'>";	 else {		  alert("You didn't specify a Dropdown Menu name."); // Make sure we don't get JS Errors.	 }	 if(sname != "") {		  output += "<option name='"+ sname +"' value='"+ sname +"'>";	 }	 else {		  alert("You didn't specify an item to add to the dropdown menu."); // Make sure we don't get JS Errors.	 }}

Sorry if I can't be of more help though....

Link to comment
Share on other sites

Well, I don't think it needs to. I think I can do something like this:

var mname[]mname[0] = "Pages"//First Drop Down Menumname[1] = "Blah"//Seconde Drop Down Menu

And for the sname and url:

//Options for First Drop Down Menudropdown[0][0]("Arcade","http://beta.zetaboards.com/MooseCreations/pages/arcade");//This will be in the First Drop down menu because of the first [0] and it will be the first option in the drop down menu because of the second [0].dropdown[0][1]("Yahoo","http://www.yahoo.com");//This will be in the First Drop down menu because of the first [0] and it will be the second option in the drop down menu because of the [1].//Options for Second Drop Down Menudropdown[1][0]("Google","http://www.google.com");//This will be in the Second Drop down menu because of the first [1] and it will be the first option in the drop down menu because of the [0].dropdown[1][1]("Jquery","http://www.jquery.com");//This will be in the Second Drop down menu because of the first [1] and it will be the second option in the drop down menu because of the  second [1].

Thing is, I don't know how to make it accually work that way. I am able to show only part of it...so if anyone can help me accually making the rest or somthing...

Link to comment
Share on other sites

Dont think its even Javascript. //Code Created by Agent Moose$(".drop_menu").before("<ul id='top_menu' class='drop_menu'><liid='menu_ucp'>................[im a PHP novice, correct me if wrong]Looks like PHP, before(...) should be another function. Also do you get any error?

Link to comment
Share on other sites

Your right, this isn't javascript...well sorta is, it is Jquery. It is the same thing sorta but you write alot less.Anyway, I don't get an error, I am also having this disscusion on another forum and I found another way to do this code...

<script>$(document).ready(function() {//Created by Agent Moose and HolySaviorvar mname = new Array()mname[0] = "Pages"mname[1] = "Other"var dropdown = new Array()dropdown[0] = ["Pages","Arcade","http://beta.zetaboards.com/MooseCreations/pages/arcade/"]dropdown[1] = ["Other","Codes","http://beta.zetaboards.com/MooseCreations/pages/codes/"]for(q=0;q<mname.length;q++){for(y=0;y<dropdown.length;y++){$("#top_menu").append("<li id='"+ mname[q] +"1'><a href='#'><img src='http://209.85.62.27/static/1/m_ucp.png' /> "+ mname[q] +"</a><ul id='"+ dropdown[y][0] +"'></ul></li>");$("#"+ dropdown[y][0] +"").append("<li><a href='"+ dropdown[y][2] +"'>"+ dropdown[y][1] +"</a></li>");};};});</script>

There is a problem with this code, it creates two dropdown menus instead of one. I don't think if I should even explain anymore since some people don't nkow what this is...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...