What is the best way to display a chosen item in a text input field?

https://i.stack.imgur.com/Qe5Ds.png

Looking to create a similar design, but lacking the necessary expertise. What steps should I take or what is the specific term for this style?

Seeking assistance in implementing this using jQuery, PHP, or JavaScript. Appreciate any help. Thank you.

Answer №1

For more information, please refer to the Documentation

//initiate chosen plugin
$(".chosen-select").chosen({no_results_text: "Oops, nothing found!"});


$('.chosen-select').on('change', function(evt, params) {
    alert($(".chosen-select").val());
  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="http://harvesthq.github.io/chosen/chosen.css">
 
<script src="http://harvesthq.github.io/chosen/chosen.jquery.js" type="text/javascript"></script>


<select id="searchBox" data-placeholder="Type &apos;C&apos; to view" style="width:350px;" multiple class="chosen-select chosen-select-no-results" tabindex="11">
            <option value=""></option>
            <option>Coffee</option>
            <option>Tea</option>
            <option>Milk</option>
            <option>Water</option>
            <option>Juice</option>
          </select>

Answer №2

Implement the jquery tagit plugin to enhance your website's functionality

Explore the capabilities of the tag-it plugin by visiting http://aehlke.github.io/tag-it/

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Can the client side version of expressjs routes be utilized?

Can you create client-side routes in the style of expressjs to trigger a callback function for specific routes? For example: app.get('/dogs', function(req, res, next) { // do stuff }); Is there a way to achieve this functionality on the cli ...

JavaScript function for automatic scrolling to the bottom of the page is not functioning as expected

I'm working on incorporating a terminal/console feature into my website. I came across the JavaScript functions for scrolling down a page, namely window.scrollTo(0,document.body.scrollHeight); and window.scrollTo(0,document.querySelector(".fakeSc ...

transform array elements into an object

I encountered the following code snippet: const calcRowCssClasses = (<string[]>context.dataItem.cssClasses).map( (cssClass) => { return { [cssClass]: true }; } ); This code block generates an array of objects like ...

Ending a Python Script from a PHP File: Best Practices

In the final stages of my IoT-based project, I am currently developing a website in php that interacts with sensors controlled by a raspberry pi board using a python script. One feature I am trying to implement is allowing users to turn these sensors on an ...

Updating website content dynamically using Javascript and JSON-encoded data

My programming code seems to be acting oddly. I have structured my data in a JSON object as follows: injectJson = { "title": "Champion Challenge Questions", "rules": [ { "idChrono": "chrono-minute", "text": "Top is missing!", ...

The route parameters seem to be malfunctioning when using the Google Maps Directions API

Currently, I am attempting to transfer the latitude and longitude of a location from one HTML file to another using the $routeParams feature. In the second HTML file, I utilized the Google Maps directions API to display the directions from the source lati ...

Is your Ajax jQuery live search not functioning properly with JSON data?

My programming code is not functioning properly. Here is the file I am working on. When it does work, it does not display the list and gives an error in the Json file. I am unsure of the reason behind this issue. You will be able to view the error in the C ...

Bootstrap4 does not support the <button> element

How can I achieve a 'collapse icon' floated to the left followed by Copyright © using Bootstrap 4? I've looked at similar questions on this topic, but none seem to provide a direct answer. Other questions contain different code with ob ...

What is the best way to align columns after adding or deleting columns in an el-table using Element UI in Vue.js?

Is there a way to develop a table/datagrid using Element UI that allows users to choose which columns are displayed? I've already made an attempt, and you can find it here. I'm also looking for a solution that enables users to adjust the width o ...

Calling a function within another function

In my code, I have a function that formats the price and retrieves the value needed for refactoring after upgrading our dependencies. I'm struggling with passing the form value to the amountOnBlur function because the blur function in the dependencie ...

how to use beautifulsoup to insert a new tag within a text block

When a browser encounters the text www.domain.com or http://domain.com/etc/ within an HTML text section, it automatically converts it into <a href="http://www.domain.com">www.domain.com</a> or <a href="http://domain.com/etc/">http://domai ...

Is it possible to resize the background-image style?

When using the regular img tag in HTML, you can specify the width and height, and the browser will scale the image. If the dimensions are not too different from the original, the result is usually decent. For example, you can scale the avatar image to 32x ...

Angular binding for selecting all data

Upon checking a checkbox for a single item, the bound data is retrieved and added to an array. However, this does not happen when using selectAll. Code snippet in Angular for obtaining the object of a checked item: $scope.selectedOrganisations = []; $sco ...

What is the process for creating custom command settings for each specific Discord server or guild?

If the server admin writes "!setprefix $" the bot will change its prefix from "!" to "$", but this change will only apply to that specific server. ...

Unable to extract query parameters from URL using Express JS as req.query returns an empty object

I came across discussions about this issue here and here, but unfortunately, the solutions provided didn't work for me. I'm attempting to extract parameters from the URL using req.query. In my server.js file, I've implemented the following: ...

Step-by-Step Guide for Uploading an Entire Folder and Its Contents

I have been working on a code to upload multiple files, but now I am facing the challenge of uploading an entire folder with multiple files and possibly subfolders containing even more files. Currently, I am utilizing JavaScript for obtaining the files and ...

What could be causing the issue with the 100% height and 100% width not functioning properly on my ASPX page?

The CSS and HTML code work perfectly in an isolated test environment: body, html { height: 100%; min-height:600px; min-width:800px; overflow:hidden; margin:0;padding:0; } html {overflow:auto;} .fill {height:100%; width:100%; backgro ...

Incorporating string input values into a function

I am currently working on a function that retrieves the value of an input upon clicking a button. My goal is to then have another event that will incorporate that value into a function when the button is clicked. var getInput = function() { $('#inpu ...

What causes the low Performance score of a default NextJS Application with no content?

Just started experimenting with my initial Next.js project. Upon generating a new project using create-next-app, I decided to test its performance with the web application 'Lighthouse'. Surprisingly, although most other metrics scored above 90, ...

What is the best way to handle cURL post data in PHP?

Is there a way to extract information from cURL posts using PHP? I have a PHP client that utilizes this cURL request: data1 = array( "email" => $email, "firstname" => $firstname, "lastname" => $lastname, "code" => $code ); $da ...