samedi 28 mars 2015

count multiple selected in autocomplete field

In jquery's autocomplete multiple value, I try to add a counter for selected values. It also should get updated immediately, when I chose/add one more values.


Both codes of a workaround are not working.


1



function checkReceiver()
{
var str = document.forms[0].tags.value,
regex = /417/igm,
count = str.match(regex),
count = (count) ? count.length : 0;
console.log(count);
document.forms[0].receiver.value=count;
}


2



var str = document.forms[0].tags.value;
count = (str.match(/417/g) || []).length;
document.forms[0].receiver.value=count;


Is there an trigger, I can use in the autocomplete function directly?


Demo on jsfiddle


Aucun commentaire:

Enregistrer un commentaire