jquery - Javascript Test for Multiple Selection Menu -


this edit check on multiple select field search form.

when selection made in multiple select field , form submitted, empty() function logs "user made selection", part works. however, if no selection made, empty() function not log "no selection made". if no selection made in field, won't variables cityselectedvalue , cityselectedhtml null and/or undefined? believe script found checks that? not sure if setup jsfiddle correctly. if not, let me know , i'll fix it:

https://jsfiddle.net/ibuprofen/077qxk01/

try code: https://jsfiddle.net/077qxk01/31/

this function rsponsible getting proper information selected options. extract values or text:

function getselectvalues(select) {   var result = [];   var options = select && select.options;   var opt;    (var i=0, ilen=options.length; i<ilen; i++) {     opt = options[i];      if (opt.selected) {       result.push(opt.value || opt.text);     }   }   return result; }     

as jsfiddle - recommend sticking this: javascript not running on jsfiddle.net guidelines when trying use "onclick" attribute :)


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -