TinyPortal

Development => Block Codes => Topic started by: G6Cad on February 04, 2006, 05:38:51 PM

Title: javascript Drop Down link table
Post by: G6Cad on February 04, 2006, 05:38:51 PM
For those who have lack of space in the sidebars.

Use this java/html code for a drop down link box that just take about no space at all :)
Add as many links to it as you want sor fast access to something within your own site, or to another site.

I use it at my hompage if anyone want to try it out


<Script language="JavaScript">
<!-- Script courtesy of http://www.web-source.net - Your Guide to Professional Web Site Design and Development
function goto(form) { var index=form.select.selectedIndex
if (form.select.options[index].value != "0") {
location=form.select.options[index].value;}}
//-->
</SCRIPT>
<FORM NAME="form1">
<SELECT NAME="select" ONCHANGE="goto(this.form)" SIZE="1">
<OPTION VALUE="">-------JUMP TO-------
<OPTION VALUE="http://www.bloczone.net">BlocZone
<OPTION VALUE="/forum/home">Home
<OPTION VALUE="URL GOES HERE">SITE
<OPTION VALUE="URL GOES HERE">SITE
<OPTION VALUE="URL GOES HERE">SITE
<OPTION VALUE="URL GOES HERE">SITE</SELECT>
</FORM>
Title: Re: java Drop Down link table
Post by: RoarinRow on February 04, 2006, 06:35:42 PM
Cool, thanks for the info  ;)
Title: Re: java Drop Down link table
Post by: crip on February 04, 2006, 06:54:56 PM
That's really helpful block snippet, thanks g6cad. :)

Later, crip
Title: Re: java Drop Down link table
Post by: G6Cad on February 04, 2006, 07:04:46 PM
 :laugh:
Title: Re: java Drop Down link table
Post by: Rasyr on February 05, 2006, 03:04:35 AM
I know this may sound a bit nitpicky, but what you have there is a javascript function, not java. The two are very different animals.

;D
I adjusted the thread title for you.

BTW - nicely done.... ;D

Title: Re: javascript Drop Down link table
Post by: superQ on February 05, 2006, 03:34:51 AM
I was just going to ask about this this morning. ;)

Incredibly useful. Love it !!!!!!!!
Title: Re: javascript Drop Down link table
Post by: IchBin on February 05, 2006, 04:12:10 AM
Very cool g6! I like that idea, I just might have to use it in my upcoming site update, if I ever get to it... :)
Title: Re: javascript Drop Down link table
Post by: rbh on April 10, 2006, 06:12:22 AM
what would you change to get the links to open in a new browser? i have tried various things but can't get them to work. ???
Title: Re: javascript Drop Down link table
Post by: G6Cad on April 10, 2006, 08:55:56 AM
You just type in the URL after the <OPTION VALUE=     
Like this <OPTION VALUE="http://www.bloczone.net">BlocZone
Title: Re: javascript Drop Down link table
Post by: rbh on April 10, 2006, 04:03:22 PM
G6, what i want it to do is open the links in a new window rather then the link opening in the current window taking users away from my site.
Title: Re: javascript Drop Down link table
Post by: qwe3 on April 11, 2006, 04:41:38 AM
Quote from: rbh on April 10, 2006, 04:03:22 PM
G6, what i want it to do is open the links in a new window rather then the link opening in the current window taking users away from my site.

Nice job and thanks,  I also want a new window any ideas?
Title: Re: javascript Drop Down link table
Post by: rbh on April 11, 2006, 05:43:28 AM
well, i played around for awhile and finally came out with this. it also includes a go button so the link doesn't load automatically in case people choose the wrong link accidentally.



<script>
<!--
function land(ref, target)
{
lowtarget=target.toLowerCase();
if (lowtarget=="_self") {window.location=loc;}
else {if (lowtarget=="_top") {top.location=loc;}
else {if (lowtarget=="_blank") {window.open(loc);}
else {if (lowtarget=="_parent") {parent.location=loc;}
else {parent.frames[target].location=loc;};
}}}
}
function jump(menu)
{
ref=menu.choice.options[menu.choice.selectedIndex].value;
splitc=ref.lastIndexOf("*");
target="";
if (splitc!=-1)
{loc=ref.substring(0,splitc);
target=ref.substring(splitc+1,1000);}
else {loc=ref; target="_blank";};
if (ref != "") {land(loc,target);}
}
//-->
</script>

<form action="dummy" method="post"><select name="choice" size="1">
<OPTION VALUE="URL">LINK NAME
<OPTION VALUE="URL">LINK NAME
<OPTION VALUE="URL">LINK NAME
<OPTION VALUE="URL">LINK NAME
<OPTION VALUE="URL">LINK NAME
<OPTION VALUE="URL">LINK NAME
<OPTION VALUE="URL">LINK NAME
<OPTION VALUE="URL">LINK NAME
<OPTION VALUE="URL">LINK NAME
<OPTION VALUE="URL">LINK NAME

</select><input TYPE="button" VALUE="GO!" onClick="jump(this.form)"></form>


if you don't want the go button just remove <input TYPE="button" VALUE="GO!" onClick="jump(this.form)">

if you want to have it open in the same window just change the target to self instead of blank in this line        else {loc=ref; target="_blank";};

and if you really want to customize each individual link just copy *_blank after each url changing blank to self or parent depending on how you want the specific links to open, for example, a link to open another part of your forum or webpage would have *_self after the url, while a link to another website would have *_blank after the url.

example <OPTION VALUE="http:///www.yahoo.com*_blank">Yahoo
            <OPTION VALUE="http://www.myforum.com/pictures.htm*_self">Pictures
Title: Re: javascript Drop Down link table
Post by: qwe3 on April 11, 2006, 02:12:47 PM
rbh,

Script would not work for me.  I got error on page message at bottom left of main window.
Title: Re: javascript Drop Down link table
Post by: rbh on April 11, 2006, 04:23:32 PM
    you might double check that you are copying everything correctly and that you are putting this code into a scriptbox. i just copied this code and tested it on my site to make sure i had it posted correctly, and it worked.
Title: Re: javascript Drop Down link table
Post by: G6Cad on April 11, 2006, 06:17:27 PM
Make sure you put it in a HTML/Javascript Block (script Block)
Title: Re: javascript Drop Down link table
Post by: qwe3 on April 11, 2006, 10:07:48 PM
All set thanks
Title: Re: javascript Drop Down link table
Post by: Sapphire on May 05, 2006, 02:38:15 AM
This is a great block!

And I realize this is probably "in your face" obvious, but I have a question -
I've tried every way I know of to manually set the width, and none seem to work once I input them into the block.  I want to use several of these drop-downs, but the link titles in each grouping are of varying widths - so they end up appearing staggered.

I'm playing with TP and this script on my test forum if you want to see what I mean:
http://www.soulofadoption.com/testforum/index.php

Thanks for any advice you might have for me.  :)
Title: Re: javascript Drop Down link table
Post by: CM-MN on October 27, 2006, 07:31:17 PM
Your post is still being found useful..... of course ;-)

Thanks for posting this........ it's just what I've been looking for!!!!