Coding a JS function

Help! (again)I have successfully used JS code to switch to other web pages but cannot get the same code to work within a function.

  1. Code that works

1.1 Code in JS Header

var sites=new Array()

sites[0]=“#”;

sites[1]= “http://www.bbc.co.uk/”;

sites[2]=“http://www.tf1.fr/”;

1.2 Code in >On Change > field named web_list and defined as dialogue box)

var chosen;

chosen=web_list.selectedIndex;

window.location=sites[chosen];

2 Code that does not work

2.1 Code in JS Header

var sites=new Array()

sites[0]=“#”;

sites[1]=“http://www.bbc.co.uk/”;

sites[2]=“http://www.tf1.fr/”;

function jump()

{

var chosen;

chosen=web_list.selectedIndex;

window.location=sites[chosen];

}

2.2 Code in >On Change > field named web_list and defined as dialogue box)

jump();

When I use the function the Netscape JS console tells me “web_list is not defined”

Subject: Coding a JS function

I am not sure but try this.

function jump()

{

var chosen;

chosen=document.forms[0].web_list.selectedIndex;

window.location=sites[chosen];

}

Subject: RE: Coding a JS function

Yes

That work perfectly!

Thanks

Mike