Hi,

I'm getting the following messages from the (Mozilla) Javascript console.

Warning: reference to undefined property CategoryList[frm.selCategory.value]
Source File: http://sitename/rep/new.asp
Line: 209

Error: CategoryList[frm.selCategory.value] has no properties
Source File: http://sitename/rep/new.asp
Line: 209
Line 209 (shown in red)is in the following code:

Code:
function getSubCategories(categoryid)
  {
  var subcat = null;
  if ( frm.selCategory.value == null ) {
     subcat = "0";
     }
  else {
     subcat = CategoryList[frm.selCategory.value].categoryid;  // Line 209
     }
  var current = (frm.selSubCategory.value) ? SubCategoryList[frm.selSubCategory.value].subcatname : '';
	    
  for(z = frm.selSubCategory.length - 1; z >= 0; z--)
     {
     frm.selSubCategory.options[z] = null;
     }
  for(z = 0; z < SubCategoryList.length; z++)
     {
     var prod = SubCategoryList[z];
     if(prod.categoryid == subcat)
          { 
          frm.selSubCategory.options[frm.selSubCategory.options.length] = new Option(prod.subcatname, z, (prod.subcatname==current), (prod.subcatname==current));
          }
     }
  
  frm.category.value = CategoryList[frm.selCategory.value].categoryid;
  }
frm.selCategory.value is showing as null, when I do a 'Page Info' , and I would have thought that by doing:

Code:
if ( frm.selCategory.value == null ) {
to be suffient for a test. I have also tried:

Code:
if ( frm.selCategory.value = null ) {
// and ...
if ( frm.selCategory.value ) {
but still no luck. I _think_ the problem lies where the dropdown is "emptied":

Code:
frm.selSubCategory.options[z] = null;
which of course is followed by code to then "fill" the dropdown (there are 3 levels of dropdowns, a hiearchy). In some circumstances, the top level selection may not find any lower level values, and so, the subcategory dropdown list will remain empty (null ?),. How do I check if the list is null, is it:

Code:
If frm.selSubCategory.options.length ==0
One way or another the frm.selCategory.value is an "undefined property", and then later an error stating "has no properties". If I can check whether the property is undefined (or exists ??), then just one line of code:

Code:
frm.SelGroup.options[frm.SelGroup.options.length] = new Option('Unknown', '0');
with the default value for unknown/unused will suffice. I just don't know how to check for the property. (I guess it is part of an object ??).

Thanks,

Peter