[jQuery] Re: saving values from a multi select list.
With Pleasure. === first post Im using a plugin called selectchain by Remy Sharp and modified it a bit. Right now im trying to pass only selected values of a multi select list through ajax. The following function does a bit more but im concerned with the part that says cust_val: customer.val().join(",") This should return only selected values. This is what happens if i put it in an alert(). however when i check firebug to see what was posted it shows the entire list. I've tried alternatives like option:selected they all work for alet() .. but the info passed through ajax shows the entire list. please help. customer.selectChain({ target: market, url: callback_url, type: "POST", data: { ajax: true, multsel: market_selects, cust_val: customer.val ().join(",") } }).trigger('change'); = Second Post = Ok so i thought that maybe the problem had something to do with the ajax request so i tried adding the ajaxStart function. See below. $("#ddl_customer").change(function(){ $("#ddl_customer").ajaxStart(function() { cuslist = $(this).val().join(", "); }); alert(cuslist); }); $("#ddl_customer").selectChain({ target: market, url: callback_url, type: "POST", data: { ajax: true, multsel: market_selects, cust_val: cuslist } }).trigger('change'); So im trying to get all the selected values from ddl_customer in the first block of code. then pass it to cust_val in the second block of code. note that the alert(custlist) outputs what i expect. but when i check cust_val in firebug it outputs the entire list, not only selected values. Please Help!:(
[jQuery] Re: saving values from a multi select list.
I don't have the original message in my email any longer. Can you post the code involved? Rick -Original Message- From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On Behalf Of shaded Sent: Tuesday, September 15, 2009 9:42 AM To: jQuery (English) Subject: [jQuery] Re: saving values from a multi select list. Still stuck on this.no one has even a suggestion as to what maybe wrong?
[jQuery] Re: saving values from a multi select list.
Still stuck on this.no one has even a suggestion as to what maybe wrong?
[jQuery] Re: saving values from a multi select list.
Ok so i thought that maybe the problem had something to do with the ajax request so i tried adding the ajaxStart function. See below. $("#ddl_customer").change(function(){ $("#ddl_customer").ajaxStart(function() { cuslist = $(this).val().join(", "); }); alert(cuslist); }); $("#ddl_customer").selectChain({ target: market, url: callback_url, type: "POST", data: { ajax: true, multsel: market_selects, cust_val: cuslist } }).trigger('change'); So im trying to get all the selected values from ddl_customer in the first block of code. then pass it to cust_val in the second block of code. note that the alert(custlist) outputs what i expect. but when i check cust_val in firebug it outputs the entire list, not only selected values. Please Help!:(
[jQuery] Re: saving values from a multi select list.
Thanks for the reply. I'm not really too concerned about html and how its displayed right now. I'm just concerned that its not passing the right data to the ajax call. It's also part of a much larger mvc type program so its hard to show html. this is what the html for the drop down list looks like. It has some framework specific stuff in there. also in the javascript im setting ddl_customer to customer like the following. var customer = $('#ddl_customer'); also id I do the following.. the alert gives only selected values... which is what i want if i do the same thing in the ajax call i get the entire list. customer.change(function(){ cuslist = customer.val().join(", "); }); alert(cuslist);
[jQuery] Re: saving values from a multi select list.
Have some HTML to show with that? there is no reason why ".val()" would not bring back what it is supposed to: an array of values from selected unless you were using it wrong, your selectors are wrong, or your HTML is wrong So show more code and it'll be easier for others to help you :-) On Sep 10, 11:32 am, shaded wrote: > Im using a plugin called select chain and modified it a bit. Right now > im trying to pass only selected values of a multi select list through > ajax. The following function does a bit more but im concerned with the > part that says > > cust_val: customer.val().join(",") > > This should return only selected values. This is what happens if i put > it in an alert(). however when i check firebug to see what was > posted it shows the entire list. I've tried alternatives like > option:selected they all work for aler() .. the info passed > through ajax shows the entire list. > > please help. > > customer.selectChain({ > target: market, > url: callback_url, > type: "POST", > data: { ajax: true, multsel: > market_selects, cust_val: > customer.val().join(",") } > }).trigger('change');