The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

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:

Reference to undefined property

Hi Vinny,

Originally Posted by Vincent Puglia

I tend to prefer having only 1 exit point and as few braces as possible:

It was hard to distinguish, though (for me) if the:

Code:

return (retVal);

was inside or outside the FOR loop, and especially with no indenting and no braces, I found I had to look at it for a lot longer to understand what it was doing. Finally it clicked though, true will always be returned, unless the IF condition is met.

was inside or outside the FOR loop, and especially with no indenting and no braces

Re the lack of indentation: I plead innocence!! When I wrote the code, it was indented. I evidently had some problems with the forum's quick reply; it even stuck my name within the 'code' elements.

Re the lack of braces: I learned javascript via C and a few other languages. Result: I always look for the semi-colon ";" I tend to use braces only when there is a chance for confusion (multiple embedded if/elses)

The dropdown selCategory had values in it, and the dropdown selsubCategory did not (empty). Therefore, the FOR loop in function XDEF wouldn't get executed, because the length was zero for selSubCategory.