2

I'm using jQuery multiSelect and want to pass the selections to my update script.

Here's my ajax call

var newnotesecurity = $("#nt_newnotesecurity").serializeArray();

$.ajax({
  url: 'notes-savenewnote.php',
  method: 'POST',
  data: {
    cache: false,
    companyid: companyid,
    entitytype: entitytype,
    entityid: entityid,
    noteinitials: newnoteinitials,
    notetext: newnotetext,
    notetags: newnotetags,
    notesecurity: newnotesecurity
  },
  success: function() {
    // blah
  },
  error: function(){
    // blah
  }
});

nt_newnotesecurity is the multiselect object. Obviously serializeArray is not working for me. It's just my latest attempt to get this working.

I end up passing in this:

notesecurity[0][name]=nt_newnotesecurity&
notesecurity[0][value]=2&
notesecurity[1][name]=nt_newnotesecurity&
notesecurity[1][value]=14

but I'd like to pass in this

nt_newnotesecurity=2&nt_newnotesecurity=14

or I'd be just as content to pass in a single value that I can explode later on, like this

notesecurity=2-14

1 Answer 1

1

According to the documentation for the multiselect plugin, just calling val() should get you all the values

var newnotesecurity = $("#nt_newnotesecurity").val();
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you. That works perfectly. I coulda swore I had tried that early on, but I must've had other problems with my code at that point. Now I feel silly.
Although this was five years ago, I'm pretty sure the reason it didn't work for me initially was because I neglected to add multiple='multiple' to the select tag. I know because it happened to me again this morning.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.