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

  • Home
  • SEARCH
  • 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 223739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:15:00+00:00 2026-05-11T19:15:00+00:00

OK here goes: Need to filter out duplicates and the ability to remove added

  • 0

OK here goes: Need to filter out duplicates and the ability to remove added values to a SELECT box.

Number: <input type="text" name="number" />
<br />
<!-- Clicking the button should add an option w/ the value being the text displayed -->
<button type="button">Add</button>
<br />
<Select id="mySelect" size="9"></Select>
<br />
<!-- Display only if SELECT box has a value -->
<button type="button" hidden="hidden">Remove</button>

I have looked at this thread but still missing something.

  • 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-11T19:15:00+00:00Added an answer on May 11, 2026 at 7:15 pm

    I’m not quite sure what you’re asking, so clarification would be helpful. Here’s my crack at what your looking for:

    Javascript

    <script type="text/javascript" charset="utf-8">
     $( function() {       
       // Add number from <input> as an <option> to the <select>
       $('#add_number').click( function() {
         // Get Number from <input>
         var numberToAdd = $('#number_to_add').val();
    
         // Make sure it's not a duplicate; if so, don't add
         var match = false;
         $('#mySelect option').each( function() {
           if (numberToAdd == this.value) match = true;
         });
         if (match) return false;
    
         // Add the number to the <select>
         $('#mySelect').append(
           $('<option></option>').html(numberToAdd).val(numberToAdd)
         );
    
         // Show the remove button
         $('#remove_selected').show();
         return false;
       });
    
       // Remove the currently selected <option> in the <select>
       $('#remove_selected').click( function() {
         $('#mySelect option:selected').remove();
         return false;
       });
     })
    </script>   
    

    HTML

    <form action="#">
      <p>
        Number: <input type="text" name="number_to_add" id="number_to_add" />
        <button id="add_number" type="button">Add</button>
      </p>
      <p>
        <select id="mySelect" size="9"></select>
        <button id="remove_selected" type="button" style="display:none;">Remove</button>
      </p>
    </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry for a long question but here goes. I am trying to modify the
this may be a general question on sharing variables but here goes. I'm using
I've tried several ways to achieve this but here goes... I have the following
This may be a stupid question, but here goes. I've seen several projects using
I’m not sure this is the best example, but here goes. Let’s say I
This is a very wide-ranging/vague question, but here goes. Apologies in advance. The app
I'm trying to create a blurred drop shadow (similar to the CSS3 box-shadow) in
I have a table with the following values: ID NAME ADDRESS 1 Bob Super
ok there are several similar questions but not quite anything that I want. I
HI, this is my first time doing this. I've read The definitive guide to

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.