Get object label and value - jQuery Tagit

Posted on 2012-09-14
Last Modified: 2012-09-14
I'm trying to put constraints around text that can be entered into text box to only allow certain values to be selected.  When selected, I want to extract the ID for the object to use later.  

My thought was to use two boxes- one for the label that is visible to everyone and another for the ID that is hidden.    

In short, how do I allow people to select "Pizza" in the text box and capture the value "1" in another field?  If there are multiple values, a delimter "," should be used.  

I'm open to suggestions as to how to make this work, but was trying to improve the UI by using TagIT (link below).

    <input id="my_food" disabled="true">
    <ul id="singleFieldTags"></ul>

var food = [{label:'Pizza', value:1},{label:'Burger',value:2},{label:'Salad',value:3}]; 

    tagSource: food, 
    singleField: true, 
    singleFieldNode: $("#single")

Open in new window

Question by:Latitudes
    1 Comment

    Accepted Solution



    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
    In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now