Thank you, the problem is solved. I had to alter the id. I was dynamically generating the multi select box, I had to rename the ID which was same as name of select box
On Nov 25, 7:05 pm, Sai Krishna <[EMAIL PROTECTED]> wrote: > Well that was an edited code. Infact, I was not returning any qty in > my original code. That was mistake. > > My Server side code seems to be not taking name parameters. When I > rename the parameters to parameters[], POST seems to get all selected > values other wise I get the last selected value. > > $(#parameters).change seems not getting recognized by Jquery. > > On Nov 25, 6:53 pm, MorningZ <[EMAIL PROTECTED]> wrote: > > > You're making it much more complex than it needs to be, besides the > > fact that your posted code doesn't make much sense as that "return > > qty" isn't returning the value anywhere > > > $("#parameters").change(function () { > > var values = $(this).val() || []; > > $("#qty").val(values.length; > > > }) > > > On Nov 25, 8:49 am, Sai Krishna <[EMAIL PROTECTED]> wrote: > > > > Hi, > > > > I'm a newbie to Jquery. I wrote the following function for multi > > > select > > > var quantity =0; > > > $("#parameters").click(function () { > > > var qty = 0; > > > $("#parameters option:selected").each(function () { > > > qty = qty+1; > > > }); > > > $("#qty").val(qty); > > > return qty; > > > > }) > > > > and the multi select list box with the following code > > > > <select name='parameters' id='parameters' multiple='multiple' > > > > <option value='2' >value2</option> > > > <option value='1' >value1</option> > > > <option value='3' >value3</option> > > > </select> > > > > This updates a hidden form variable quantity. Now I changed to name > > > "parameters" to "parameters[]". > > > > The function seems to be not working. Probably I need to length I > > > tried $("#parameters length()"). This seems to be not working. Can > > > somebody help me?