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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:31:21+00:00 2026-06-18T12:31:21+00:00

I have this select; to select countries and add to a new select multiple

  • 0

I have this select; to select countries and add to a new select multiple with a limit of 5 countries, but I just want to add 1 country by select or more countries if i do a multiple select.
My mistake is in my function addC(), when I want to add more than 1 country in my select, it add the several countries in 1 option tag like this:

<option>South KoreaUSAJapan</option>

What I can modify to display the following way if i do a multiple select?:

<option>South Korea</option>
<option>USA</option>
<option>Japan</option>

My code:http://jsbin.com/osesem/4/edit

function addC() {
    if ($("#agregarProvincia option").length < 5) {
        var newC = ($("#countries option:selected").text());
        $("#addCountry").append("<option>" + newC + "</option>");
    }
}
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<label for="provincia2"><b>¿Country?</b></label><br>
<span>
    <select multiple="multiple" size="5" id="countries">
        <option value="1">South Korea</option>
        <option value="2">USA</option>
        <option value="2">Japan</option>
        <option value="3">Italy</option>
        <option value="4">Spain</option>
        <option value="5">Mexico</option>
        <option value="6">England</option>
        <option value="7">Phillipins</option>
        <option value="8">Portugal</option>
        <option value="9">France</option>
        <option value="10">Germany</option>
        <option value="11">Hong Kong</option>
        <option value="12">New Zeland</option>
        <option value="13">Ireland</option>
        <option value="14">Panama</option>
        <option value="15">Norwey</option>
        <option value="16">Sweeden</option>
        <option value="17">India</option>
        <option value="18">Morroco</option>
        <option value="19">Russia</option>
        <option value="20">China</option>
    </select>
</span>
<div class="addremover">
    <input class="add" type="button" onclick="addC()" value="Addd »" />
    <br/>
</div>
<span>
    <select id="addCountry" multiple="multiple" size="5">
    </select>
</span>
  • 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-18T12:31:23+00:00Added an answer on June 18, 2026 at 12:31 pm

    use each function to loop through the text and append it..
    try this

    function addC() {
        if ($("#agregarProvincia option").length < 5) {
            var newC = ($("#countries option:selected"));
          newC.each(function(){
            $("#addCountry").append("<option>" + $(this).text() + "</option>");
          })
        }
    }
    

    JSbin here

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

Sidebar

Related Questions

I have this drop-down list of countries: <select name=country> <option value=>Country...</option> <option value=Afganistan>Afghanistan</option> <option
I have this select input in my form that I want to access via
I have a form select statement, like this: = f.select :country_id, @countries.map{ |c| [c.name,
I have this MySQL query and the syntax is correct, but when I want
I have four <select> element. <div id=select-countries-container> <select name=countryId id=select-countries> <option value=>Choose Country &raquo;</option>
I'm running this query SELECT country, countries.code, countries.lat, countries.lng, countries.zoom, worldip.start, worldip.end FROM countries,
I have a query: SELECT DISTINCT countryName,countrySlug FROM countries AS Country INNER JOIN countries_networks
I have this select input with simple_form: <%= f.input :board, :collection => Board.where(:user_id =>
i have this SELECT COUNT(1) cnt, a.auther_id FROM `posts` a LEFT JOIN users u
I have this select insert into test(t_name) (select users.first_name || '_' || users.last_name ||

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.