Forum Moderators: open

Message Too Old, No Replies

Passing Array Names

Passing Array Names Variable

         

malckam

8:21 pm on Dec 4, 2002 (gmt 0)

10+ Year Member



I am trying to get the piece of JScript below to run but having checked out numerous references I still cannot sort it out.

function fiddle()
{
var atlas= new Array("Physical World"," "," "," ","K2")
var secno = window.document.form1.Book_Label.selectedIndex;
var secna = window.document.form1.Book_Label.options(secno).value;
alert (secna);
alert (secna[0]);
}

The variable secna is successfully set to "atlas" (from the drop down list that calls the function), but then alert (secna[0]) is returned as undefined.

korkus2000

1:12 pm on Dec 9, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have you tried

var secna = window.document.form1.Book_Label.options[secno].value;

I always thought drop downs needed the square brackets, because essentially javascript treates them as arrays.

malckam

11:48 am on Dec 18, 2002 (gmt 0)

10+ Year Member



Hi Korkus,

Thanks, pretty sure I had [] around it but will check. Have managed to do it in a different way so I will
have to dig out the original versions.

Thanks again
Malc

RossWal

10:06 pm on Dec 18, 2002 (gmt 0)

10+ Year Member



This is probably water under the bridge by now. But it looks like the [] in the alert is the culprit. I don't think secna is an array, is it?

Ross