We help IT Professionals succeed at work.

JS error on Dialog List Selection

GaryZ asked
I have the following code for a dialog box, I keep getting an JS error: F0_Num_Locations is undefined.

This code is located in the onLoad command of a frame that contains the field.

var loc = document.forms[0].F0_Num_Locations.options[F0_Num_Locations.selectedIndex].value;
Watch Question

whenever you refer an object (say field) in web page, it should be always from parent and ur code will be like this

var loc = document.forms[0].F0_Num_Locations.options[document.forms[0].F0_Num_Locations.selectedIndex].value;


If the last hint doesn't work, it's because you have the form in a Frame. In this case Notes is loosing the relation to the underlying document.

Check your code in a simple Form first to see if it works.

The hint is : Load/create first the underlying document object first.



Hallo Gary,

every OPTION in a SELECT array can have both: value AND text

I assume you are getting for TEXT :-)

Try this:
var loc = document.forms[0].F0_Num_Locations[document.forms[0].F0_Num_Locations.selectedIndex].text;

or shorter:
 var form = document.forms[0];
 var loc = form.F0_Num_Locations[form.F0_Num_Locations.selectedIndex].text;

Interesting, that means the corrected formula that I provided din't work for you and the alias of my solution provided by Zvonko worked is it ???

Heman, you proposed: *.value;
I proposed: *.text;

This is not an alias, this a solution <|;-)

Explore More ContentExplore courses, solutions, and other research materials related to this topic.