Hi! Thanks for guidance. I have changed JS code as follows. And now it is totally ignoring the check.
My listbox name is "zonelocation[]" . I have used name with/without DOT in JQUERY identifier placeholder. The result is same. /*************************/ var zonelocationVal; jQuery(.'zonelocation[]').each(function(){ if(jQuery('.zonelocation[]').attr('checked') == 'checked'){ zonelocationVal = true; } }); /*************************/ What Iam doing wrong? Thanks in advance. On Feb 25, 3:45 pm, Frederik Ring <frederik.r...@gmail.com> wrote: > Also remove the else-part of the attribute checking, this way it'll > only return true if the last element is checked. > > On Feb 25, 11:41 am, Frederik Ring <frederik.r...@gmail.com> wrote: > > > > > 2 things: you are referring to multiple checkboxes, but do that with > > an ID (#zonelocation). That will not work. Use a class instead. > > > Second: Depending on the type of your checkboxes and your DOCTYPE you > > might need to change the attr('checked') == 'checked' according to > > your needs. I only used this as a placeholder. > > > On Feb 25, 11:26 am, Bluesapphire <michealg...@gmail.com> wrote: > > > > Thanks for guidance. > > > > My JS code is as follows: > > > /****************************/ > > > var zonelocationVal; > > > > jQuery('#zonelocation').each(function(){ > > > if(jQuery('#zonelocation').attr('checked') == 'checked'){ > > > zonelocationVal = true; > > > } > > > else{ > > > zonelocationVal = false; > > > } > > > }); > > > > /***************************/ > > > > Problem is that, if I select atleast one record, even then > > > 'zonelocationVal' is always false. > > > > Can you guide me , how to solve this problem. > > > > Thanks in advance > > > > On Feb 25, 2:04 pm, Frederik Ring <frederik.r...@gmail.com> wrote: > > > > > You could do sth like: > > > > > var ok = false; > > > > > $('.elementInListbox').each(function(){ > > > > if ($(this).attr('checked') == checked){ok = true);} > > > > > }); > > > > > You will have to set your attributes according to the type of your > > > > elements though. > > > > > On Feb 25, 9:55 am, Bluesapphire <michealg...@gmail.com> wrote: > > > > > > Hi! > > > > > How can i check that atleast one option is selected in multiselect > > > > > listbox. How can this be done through JQUERY. > > > > > > Thanks in advance- Hide quoted text - > > > > > - Show quoted text -- Hide quoted text - > > - Show quoted text -