0

i use tokeinput "good plugin" with PHP and JSON work very good but now i need to take only 1 parameter from tokeinput form and use in JS. I need to take the parameter id the tokens are limit 1

    $('.tags').tokenInput("get"); // for take all parameters and now i want only id 
    // and?

Thank you so much :)

Fabrizio Fenoglio
  • 5,767
  • 14
  • 38
  • 75

1 Answers1

0

The above will return you an array of Javascript objects. If you're only allowing the selection of one item at a time, then just select the ID of the first object in your returned array

var objArr = $('.tags').tokenInput("get"); 
var objID = objArr[0].id;

You may also want to check that there IS an item selected, depending on how you're implementing.

Chris
  • 5,882
  • 2
  • 32
  • 57