Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7933441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:20:05+00:00 2026-06-03T21:20:05+00:00

I have fields that a user would enter and i would pass it into

  • 0

I have fields that a user would enter and i would pass it into jQuery and pass to a web service.

I can get textboxes values by:

var name = $(“#MainContent_txtName”).val()

The problem I’m having is a multi-select that comprises of a list item collection.
If I was to do this server side, I would do something like:

foreach (ListItem li in listTitles)
{
   if (li.Selected)
   {
     selectedValue += li.Value + ",";
   }
}

And this would give me the string of selected values from the select list.
I’m having trouble getting it out from jQuery.
If I do

var titles = $("#MainContent_selectListTitles").val() 

That is obviously incorrect because it won’t bring back the selected list items.
I saw a post that suggested that I could retrieve it if I say option selected.
So I tried this:

var titles= $('#MainContent_selectListTitles option:selected');

The next thing I did was pop an alert to see what the titles were. It just said [object, object].

So my questions are:

  1. Is it possible to get the selected items from the list item collection concatenated into a string?

  2. Or is it better that I get all the form values from a postback even on my code behind and then call the jquery function? If this is an option, i’ve attempted to do this but have failed. It tells me that it can’t find the method. So i’m definitely not calling the jquery function correctly on postback of the button event.

THanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T21:20:07+00:00Added an answer on June 3, 2026 at 9:20 pm

    First, make sure your item id is correct on client side that is “MainContent_selectListTitles”. You can check it by “View Source”.

    If the ID is correct, follow this.

        $('#MainContent_selectListTitles').change(function () {
             var str = "";
             $('#MainContent_selectListTitles option:selected').each(function () {
                  str += $(this).text() + " ";
                  //pass str value to your web service here.
             });
        }).trigger('change');
    

    Every time there is changes, it will call this function which means it will make your web service busy. You can move the above code to button click event if you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to have a text field that a user can enter a
I have a query builder form that allows a user to enter values into
I have a list of textual entries that a user can enter into the
I have a form where users can enter data that ultimately would be used
I have a jQuery dialog that requires the user to enter certain information. In
I have a user table 'users' that has fields like: id first_name last_name ...
I have an application that allows the user to edit multiple text fields and
Supposing that I have millions of user profiles, with hundreds of fields (name, gender,
I hope I can explain this right I have two input fields that require
I have a View in my MVC 3 application that lets the user enter

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.