LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-03-2004, 10:21 PM   #1
webwolf70
Member
 
Registered: Feb 2004
Distribution: Windows XP. I gave up with Linux & I left LQ.
Posts: 502

Rep: Reputation: 30
Javascript Menu help


I am trying to add this menu to my website. It will Have links across the top and when you click on each link it shows a list in the drop down box below for that link.

It works fine. But what I want to do is have each link that is clicked on in the drop down menu to open in a seperate window. I tried the classic target="_blank" but that didn't work, surprise lol. Just by looking at this can anyone give me any ideas? I know this may be a bit vague but I really don't know about programming in javascript. I am slowly teaching myself c++ and I don't want to get to involved with similiar things yet but I know how I want my website and I want these links to open in a seperate window, lol.


Here is the code in two parts. Head and body. Thanks.


<head>
<SCRIPT LANGUAGE=JavaScript>
<!--//

menu=new Array()
menu[0]=new Array()
menu[1]=new Array()
menu[2]=new Array()


menu[0][0]=new Option("Yahoo","http://www.yahoo.com" )
menu[0][1]=new Option("","")
menu[0][2]=new Option("","")
function fillList(z){

for (a=document.f.s.options.length-1;a>0;a--){document.f.s.options[a]=null}


for (a=0;a<menu[z].length;a++){document.f.s.options[a]=new
Option(menu[z][a].text,menu[z][a].value)
}

document.f.s.selectedIndex=0
}

//-->
</SCRIPT>
</head>

<body>

<FORM NAME=f>

<A HREF=Javascript:fillList(0)>One</A>
<A HREF=Javascript:fillList(1)>Two</A>
<A HREF=Javascript:fillList(2)>Three</A>
<BR>
<SELECT NAME=s style="width:225">
<OPTION VALUE="#">Where do you want to go?
</SELECT>
<!--// Clicking this button will take you to the url that corresponds to the choice you made from the drop down //-->
<INPUT TYPE=button onclick="location=document.f.s.options[document.f.s.selectedIndex].value" VALUE=">>">
</FORM></center>

</body>




Webwolf

Last edited by webwolf70; 10-03-2004 at 11:03 PM.
 
Old 10-03-2004, 10:53 PM   #2
mirradric
Member
 
Registered: May 2004
Location: Singapore
Distribution: Debian woody and debian sarge
Posts: 188

Rep: Reputation: 31
You are asking a question about javascript, not java. They are different. I've not done javascript for about 5 years so I can't help you.
 
Old 10-03-2004, 11:02 PM   #3
webwolf70
Member
 
Registered: Feb 2004
Distribution: Windows XP. I gave up with Linux & I left LQ.
Posts: 502

Original Poster
Rep: Reputation: 30
Quote:
Originally posted by mirradric
You are asking a question about javascript, not java. They are different. I've not done javascript for about 5 years so I can't help you.

Lol, oops. I thought I wrote Javascript, not java. I have been playing around with different menu's all day. Things are blurring together


Webwolf
 
Old 10-04-2004, 01:29 AM   #4
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
There's no 'target="_blank"' in your script, so no surprise it doesn't open a new window.
What you need to do is to open a new window in your onclick handler by calling a custom function.

Another problem, but it's not your fault, LQ Forums split "javascript" in "java script" in the A tag HREF, so a cut/paste breaks the code, even using the code tag doesn't help, but you should do it anyway as it improves code readability.
 
Old 10-30-2004, 02:27 AM   #5
syphoncode.32
Member
 
Registered: Oct 2004
Distribution: SuSE, Vector, Slackware
Posts: 48

Rep: Reputation: 15
i havent used javascript in a while, but try for each link's onClick() method new window("URL","width, height");

ex. <a href=javascriptnClick()=new window("URL","width, height");></a>

i dont remember if some of that needs quotes around it
 
Old 10-30-2004, 02:33 AM   #6
syphoncode.32
Member
 
Registered: Oct 2004
Distribution: SuSE, Vector, Slackware
Posts: 48

Rep: Reputation: 15
damn it, LQ put that smiley in after "javascript", its supposed to be a colon ( followed by onClick
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Java: floating menu ashirazi Programming 4 06-16-2005 08:51 PM
Question about drop down menu and Java Hockeyfan Programming 1 06-03-2005 11:11 PM
java-gnome Menu click event(nothing happens) rmanocha Programming 0 09-18-2004 03:15 PM
Java Menu Question rmartine Programming 7 02-18-2004 12:26 AM
java menu inside frame toovato Programming 1 11-05-2003 06:53 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration