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 6737965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:18:41+00:00 2026-05-26T11:18:41+00:00

I m newbie in jquery space and hope to learn much through Stackoverflow. I

  • 0

I m newbie in jquery space and hope to learn much through Stackoverflow.

I have a Sharepoint 2010 list data item which has Choice data type allowing a user to checkbox more than one value. I m using SPService to get the list items. Below is the code:

    $().SPServices({
                  webURL: 'http://abc.def.com/Products',
                  operation: 'GetListItems',
                  listName: listName,
                  async: false,
                  CAMLQuery: query,
                  CAMLViewFields: fields,
                  CAMLRowLimit: 11,

                  completefunc:
                  function (xData, Status) 
    {        $(xData.responseXML).find("[nodeName=z:row]").each(function () 

    {
           $("#ProdList").val("-1");//Pre-filled with selected val.
           var myProd= $(this).attr("ows_Prod"); //displays in this format ;#myProd1;#myProd2;#

          //Here 1. i want to store myProd as an array.
                 2. eliminate ;#
                 3. store final array elements as myProd1, myProd2
                 4. Display myProd1
                            myProd2
                                    in the dropdown list.
           //


           $("#ProdList").append('<option>' + myProd+ '</option>');
      });   
    }

     });      

     });

    <body>
    <select class="Dropdowns" id="ProdList">
    <option value="-1">My ProdLists</option>
    </select>
    </body>
  Any pointers? 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-05-26T11:18:42+00:00Added an answer on May 26, 2026 at 11:18 am

    It’s a bit hard to figure out what the specifics are of your question. I’m guessing that the comments in your code are describing the question. Next time, I’d suggest you be a lot more specific with the details of your question in your text, not in the code. But, given that, here’s my guess at what you’re trying to do.

    You have a string that looks like this:

    ";#myProd1;#myProd2;#"
    

    And, you’d like to get myProd1 and myProd2 into an array and then from that array added to a drop-down list.

    // get product list
    var myProd = $(this).attr("ows_Prod");
    // clean up the ends
    myProd = myProd.replace(/^;#|;#$/g, "");
    // split into pieces
    var myProdArray = myProd.split(";#");
    // add each piece as an option to the drop-down
    for (var i = 0; i < myProdArray.length; i++) {
        $("#ProdList").append('<option>' + myProdArray[i] + '</option>')
    }
    

    You can sort the array in dictionary order with:

    myProdArray.sort();
    

    You can remove dups from a sorted array with this:

    var noDupArray = [];
    noDupArray.push(myProdArray[0]);
    for (var i = 1; i < myProdArray.length; i++) {
        if (myProdArray[i] != myProdArray[i-1]) {
            noDupArray.push(myProdArray[i]);
        }
    }
    

    So, if you wanted to both sort and remove dups, you could use this code:

    var myProd = $(this).attr("ows_Prod");
    myProd = myProd.replace(/^;#|;#$/g, "");
    var myProdArray = myProd.split(";#");
    // sort
    myProdArray.sort();
    // remove dups
    var noDupArray = [];
    noDupArray.push(myProdArray[0]);
    for (var i = 1; i < myProdArray.length; i++) {
        if (myProdArray[i] != myProdArray[i-1]) {
            noDupArray.push(myProdArray[i]);
        }
    }
    // add each piece as an option to the drop-down
    for (i = 0; i < noDupArray.length; i++) {
        $("#ProdList").append('<option>' + noDupArray[i] + '</option>')
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

am newbie to jquery..I have a three steps registration form in which the user
I am newbie to jQuery and javascript. In my application I have a list
I'm a jQuery newbie, and I have trouble with a little script I created.
I am newbie to jQuery , just trying to learn it since last couple
I am a jquery newbie and have been adding alert timestamps into my html
I'm a jQuery newbie, so be gentle! I have a loop that outputs extra
I'm a newbie in jQuery and don't understand how in jQuery Ajax returns data.
Greetings I am a jquery newbie and trying to fix an issue which uses
Forewarning: I'm a newbie to JQuery. I have a collection of links and lists
I am jQuery newbie and I have been trying to set up a file

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.