Javascript - How to hide a drop down control if it's empty

I have a cascade dropdown on a form. User selects Document Type and most of the document type has Category. However, if a doc type does not have category then I would like to hide the category drop down. Is there a way to see if category dropdown (calculate array or something) and hide category control (by default it always show Select a value even if the drop down does not have any value to select from)

So far I have following and wondering how to evaluate category drop down control based on what user selected in the doc type drop down control.

     var varDocType= NWF$('#' + jsDocTypes)// gets Doc Type control;
          if(this.value !== null){  
            var varCategory = NWF$('#' + jsCategory)// gets Category control;
            if(varCategory == ''){
              NWF$('#' + jsCategory).style.visibility = "hidden";





Test this:

select:empty {
    display: none;
Invisible: ||<select></select>--<br>
Visible (whitespace): ||<select> </select>--<br>
Visible (children): ||<select><option>Options!</option></select>--

I do not know what is NWF$ but if you want hide an element by javascript: = "none";


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.