First, this is a mailing list. Not an IRC channel or Instant Messenger.
This means replies can take hours or even days sometimes. Patience is
the keyword here. If you need help with an issue that urgently, try the
##Javascript channel on IRC. The message I am replying to is
timestamped 12:56am. If I kept normal hours, I would not have even seen
your message for another few hours yet.
As for your question. the .val() will return the current value of the
form element. A multi-select list *may* return all the selected
elements, but that is not my experience in the few times I've tried this.
In the case of a multi-select list, I find it better to fall back to
some "old school" techniques and remember that the "selected" property
will be set to true on each of the selected options. So, I do something
like this:
var selectedArray = [];
$("#right option).attr("selected", true).each( function () {
selectedArray.push(this.val());
});
alert(selectedArray); - should result in the comma delimited string you
are looking for. IF and ONLY if there are selected items.
The gurus here will tell you my approach is probably overly long, but
it's worked for me. Your mileage may vary. Tweak it as needed.
Shawn
naz wrote:
i m w8ing for your reply
On Jul 1, 9:32 am, MorningZ <morni...@gmail.com> wrote:
Got some HTML to show of the <select> box?
if you have
<select id="right" mulitple="multiple">
<option value="1">One</option>
<option value="2" selected="selected">Two</option>
<option value="3" selected="selected">Three</option>
</select>
then
$("#right").val() will be an array that is "2,3"
if it's not like that, then (1) your selector doesn't work, (2)
there's nothing actually selected
On Jul 1, 12:18 am, naz <s.na...@gmail.com> wrote:
yes i have multiple value in that list box and i want to have all
values in the form of comma seperated list.
you are telling me to write some thing like this?var cources_matrix=$
('#right').options.val();
right is id of my listbox.i dont know how to do it and bcz of this my
work is stoppped. plz tel me what to do
On Jun 30, 3:12 pm, Charlie <charlie...@gmail.com> wrote:
do the options in select each have a value assigned? are you working with a
number value and need to parsInt()? Need more info to help
can you put an example of this not working in jsbin? or post link
naz wrote:i have a list box and i want to get its values in jquery please tel
me how can i do that i m writing $('#right').val(); but this is giving me null
plpease tell me how can i do that i need help as soon as possible thx to all
persons which reply to my questions- Hide quoted text -
- Show quoted text -