Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. I need to add “Add new item” option in Select2

I need to add “Add new item” option in Select2

Scheduled Pinned Locked Moved JavaScript
5 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Shraddha_Patel
    wrote on last edited by
    #1

    I need to add “Add new item” option in Select2

    P Z S M 4 Replies Last reply
    0
    • S Shraddha_Patel

      I need to add “Add new item” option in Select2

      P Offline
      P Offline
      phil o
      wrote on last edited by
      #2

      Please proceed, you have our permission to do so.

      "Five fruits and vegetables a day? What a joke! Personally, after the third watermelon, I'm full."

      1 Reply Last reply
      0
      • S Shraddha_Patel

        I need to add “Add new item” option in Select2

        Z Offline
        Z Offline
        ZurdoDev
        wrote on last edited by
        #3

        This is a place to ask questions, not just tell us what you want to do. What did you expect us to tell you?

        Social Media - A platform that makes it easier for the crazies to find each other. Everyone is born right handed. Only the strongest overcome it. Fight for left-handed rights and hand equality.

        1 Reply Last reply
        0
        • S Shraddha_Patel

          I need to add “Add new item” option in Select2

          S Offline
          S Offline
          simpledeveloper
          wrote on last edited by
          #4

          Can you please put some code or something so that people can help you - if you say like I want to create a project - how would someone knows what should he create - just like that ask where are you stuck after attempting couple of times etc. Good luck.

          1 Reply Last reply
          0
          • S Shraddha_Patel

            I need to add “Add new item” option in Select2

            M Offline
            M Offline
            Member_14690874
            wrote on last edited by
            #5

            Add new type
            Car
            BUS
            TWO
            THREE

            <pre>$(function () { $(".select2") .select2({ placeholder: 'Select type', width: '50%', minimumResultsForSearch: Infinity }) .on('select2:close', function() { var el = $(this); if(el.val()==="NEW") { var newval = prompt("Enter new value: "); if(newval !== null) { el.append('<option>'+newval+'</option>') .val(newval); } } }); });</pre>

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups