target=_new in OPTION tag

They have: 122 posts

Joined: Jun 1999

sorry about my misunderstanding. There should be an easier way, but to me, this way makes the most sense and is the only way I could think of.

change the line of code I was talking about earlier to:

place=document.forms[0][n].options[document.forms[0][n].selectedIndex].value;
switch (place){
case "https://ssl.securesites.com/1724/order.html":
window.open(place)
break;
case "http://2kcut.com/ICQ/comm_center.html":
window.open(place)
break;
case "http://2kcut.zzn.com":
window.open(place)
break;
case "http://www.wunderground.com/US/TX/Fort_Worth.html":
window.open(place)
break;
default : top.location.href=place;
}

[This message has been edited by Arielladog (edited 21 June 2000).]

They have: 89 posts

Joined: Jul 1999

Obviously, this is a no-no, right?
Well, that's what the HTML Validator says.

Here's what I have:

<OPTION VALUE="https://ssl.securesites.com/1724/order.html" target="_new">Alternate Order Form

And this is what HTML Validator says:

The TARGET attribute is not valid for the OPTION tag. The valid attributes for this tag are: CLASS, DIR, DISABLED, ID, LABEL, LANG, LANGUAGE, onClick, onDblClick, onKeyDown, onKeyPress, onKeyUp, onMouseDown, onMouseMove, onMouseOut, onMouseOver, onMouseUp, SELECTED, STYLE, TITLE, and VALU

I'm sure one of the attributes listed is what
I should be using, but if I understood them
all, I wouldn't be here

...as always, appreciate your time.

~ Carole

http://KnifeDealer.net

[This message has been edited by tiny (edited 21 June 2000).]

Military & Combat Knives. Hunting & Fishing Knives. Pocket Knives.
Kitchen Cutlery. Sharpeners.

Enter our Monthly Drawing!!

They have: 122 posts

Joined: Jun 1999

I'm assuming you want the links to appear in a new window...correct? If so, just change this (with changes marked in bold):

function linkto(n) {
place=document.forms[0][n].options[document.forms[0][n].selectedIndex].value;
window.open(place);
}

They have: 89 posts

Joined: Jul 1999

Thanks, Arielladog.

Now, will this mean ALL links in the pulldown
menu will open in new windows? Because
that's not really the plan.

Take a look at the pulldown menu on my site.
(link on sig here)

There are over 40 items, but only two should
be open in a new window.

If this can't be done on the one line of code
then I'll just move them to another area.

~ Carole

------------------
Knives, cutlery & sharpeners: KnifeDealer.net
....always looking for related subject banner/link exchanges.

Military & Combat Knives. Hunting & Fishing Knives. Pocket Knives.
Kitchen Cutlery. Sharpeners.

Enter our Monthly Drawing!!

They have: 231 posts

Joined: Feb 2000

Arielladog, I don't see too many scripters out there that use switch statements. I wonder how many people know about them?

They have: 122 posts

Joined: Jun 1999

I am never good with if else statements especially when there are a bunch of else's, so I found this to be muhc less confusing for ppl like me (easily confused). Only thing is that it's only supported by JavaScript 1.2 and up or IE 4+ and NN 4+

Vincent Puglia's picture

They have: 634 posts

Joined: Dec 1999

Hi,

This is how I would code it:

<OPTION VALUE = " 'https://ssl.securesites.com/1724/order.html' target='_new' ">Alternate Order Form

<select ....onChange="doSel(this)">

function doSel(selObj)
{
for (i = 0; i < selObj.length; i++)
if (selObj.options[i].selected)
eval(selObj.options[i].value):
}

The beauty of such an approach is:
1) it will work with multiple as well as single selection lists
2) you can embed any valid statement within the value.

If you would like more explaination, see the "Select & Go Menus" script at my site (or any of the select list scripts for that matter)

Re the switch statement: I use it a lot; it comes in very handy for certain situations.

Vinny

------------------
my site:GrassBlade: cut&paste javascript
moderator at:The Javascript Place
Javascript City

Where the world once stood
the blades of grass cut me still

They have: 89 posts

Joined: Jul 1999

Vincent, thank you for your help here.
Do you mind if I break this down a little so I'm sure I understand?

I'm sorry to do this, but it's the only way I know how to insure that I don't mess it up and have to bug you again...

Here's my script, with yours where I think it goes, but I'm still a little confused. (Yours is in bold.)

<script language....blah blah...

</SCRIPT>

<FORM name="guideform">

<OPTION VALUE = " 'https://ssl.securesites.com/1724/order.html' target='_new' ">Alternate Order Form

<select ....onChange="doSel(this)">

function doSel(selObj)
{
for (i = 0; i < selObj.length; i++)
if (selObj.options[i].selected)
eval(selObj.options[i].value):
}

<SELECT NAME="guidelinks" SIZE="1" onChange="window.location=document.guideform.guidelinks.options[document.guideform.guidelinks.selectedIndex].value">

<OPTION VALUE="https://ssl.securesites.com/1724/order.html" target="_new">Alternate Order Form

<OPTION VALUE ="http://KnifeDealer.net/c2/company-info.shtml">Company Info
<OPTION VALUE="http://KnifeDealer.net/c2/knifemakers.shtml">Contact Manufacturers
<OPTION VALUE="http://KnifeDealer.net/c2/testimonials.shtml">Customer Comments
<OPTION VALUE ="http://2kcut.com/ICQ/comm_center.html" target="_new">ICQ Status / Communications
<OPTION VALUE="http://KnifeDealer.net/c2/links.shtml">Links Page One

<OPTION VALUE="http://www.wunderground.com/US/TX/Fort_Worth.html" target="_new">Weather
</SELECT>
</FORM>
<!--end pull down menu code-->

Now I realize you put the actual url as
' "http..." ' ~ that I get.

But where you have the option first, then select last, do I put ALL my options before this select?

2nd question: Does the select you gave me replace the select I already had?

3rd question: (Please don't flame me if this is the wrong forum.) Is the "go" button an absolute must? I mean, mine works without it, but does it work on all systems with all browsers? I want to make it as easy as possible for all visitors.

With that... thanks ever so much!

~ Carole

------------------
Knives, cutlery & sharpeners: KnifeDealer.net
....always looking for related subject banner/link exchanges.

Military & Combat Knives. Hunting & Fishing Knives. Pocket Knives.
Kitchen Cutlery. Sharpeners.

Enter our Monthly Drawing!!

Vincent Puglia's picture

They have: 634 posts

Joined: Dec 1999

Hi Carole,

No the select goes first the options second:

<select ...... onChange="doSel(this)">
<option ......> Order form</option>
<option....etc....
...etc...
</select>

Yes, replace your onChange with mine. place the doSel() function between <script> tags in between the <head> tags.

Did you read the "Select & Go Menus" script? It demonstrates & explains how to build 2 types of selection list menus ( with and without the 'go' button). The doSel() function is part of the non-go button solution.

Flame? Fire? Smoke? where?? or are you asking me to dye your hair red?

Vinny

------------------
my site:GrassBlade: cut&paste javascript
moderator at:The Javascript Place
Javascript City

Where the world once stood
the blades of grass cut me still

They have: 89 posts

Joined: Jul 1999

Vincent, you're so funny! Thanks for being so nice here. I catch on pretty quick, although it seems my questions come up LONG after everyone else has moved on to something else!

Here's the top of my script now:

<SCRIPT LANGUAGE="JavaScript">

<!-- Hide from old browsers
function linkto(n) {
window.location=document.forms[0][n].options[document.forms[0][n].selectedIndex].value;
}
// Stop hiding from old browsers -->

</SCRIPT>

<FORM name="guideform">
<select...
<option.... etc.

So, if I understand correctly it SHOULD look like this:

<SCRIPT LANGUAGE="JavaScript">

<!-- Hide from old browsers
function doSel(selObj)
{
for (i = 0; i < selObj.length; i++)
if (selObj.options[i].selected)
eval(selObj.options[i].value):
}
// Stop hiding from old browsers -->

</SCRIPT>

<FORM name="guideform">
<OPTION VALUE=" 'https://ssl.securesites.com/1724/order.html' target='_new' ">Alternate Order Form
<OPTION VALUE="http://KnifeDealer.net/c2/company-info.shtml">Company Info
<OPTION VALUE="http://KnifeDealer.net/c2/knifemakers.shtml">Contact Manufacturers
<OPTION VALUE="http://KnifeDealer.net/c2/testimonials.shtml">Customer Comments
<OPTION VALUE=" 'http://2kcut.com/ICQ/comm_center.html' target='_new' ">ICQ Status / Communications
<OPTION VALUE="http://KnifeDealer.net/c2/links.shtml">Links Page One
<OPTION VALUE=" 'http://www.wunderground.com/US/TX/Fort_Worth.html' target='_new' ">Weather
</SELECT>
</FORM>
<!--end pull down menu code-->

Is that right now? (obviously I have lots of
options on my pulldown, but only used a few for illustration purposes.)

Hope so...

~ Carole

Military & Combat Knives. Hunting & Fishing Knives. Pocket Knives.
Kitchen Cutlery. Sharpeners.

Enter our Monthly Drawing!!

Vincent Puglia's picture

They have: 634 posts

Joined: Dec 1999

Hi Carole,

That's it except for 2 things:

1) the opening select tag.

<FORM name="guideform">
<SELECT name="someName" size="1" onChange="doSel(this)">
<OPTION VALUE=" 'https://ssl.securesites.com/1724/order.html' target='_new' ">Alternate Order Form
<OPTION VALUE = ....etc...
...more options....
</SELECT>
</FORM>

2) The option values should look like the one below.

value = "location.href='https://ssl.securesites.com/1724/order.html target=_new'"

You need the "location.href=" so that the eval() method in the doSel() function has a command to execute. You need to put the url & target within single quotes because they should be a string for the location.href. Finally, you need double quotes around everything because you need a string for the option's value. Confused? Don't worry read it through again...and again.

btw: never thought of myself as funny. intimidating, yea; amusing definitely; funny, no.

Vinny

------------------
my site:GrassBlade: cut&paste javascript
moderator at:The Javascript Place
Javascript City

Where the world once stood
the blades of grass cut me still

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.