But my second question for today: I can`t find-out how to detect the names from this javascript.
I can detect the id " + itemId + " this is working normal
in this part it detect the names
add2Advanced("Current selected users: " + itemId + " " + titles.join(", "));
But I can not find out what to do to detect the names like I can detect the id.
Code: Select all
<script type="text/javascript">
$(function(){
/*
*
Simple
*
*/
$('#fbautocomplete_id').fbautocomplete();
/*
*
Advanced
*
*/
$('#fbautocomplete_id_advanced').fbautocomplete({
url: 'friends.php', // which url will provide json!
maxItems: 0, // only one item can be selected
// do not use caching, always calls server even for something you have already typed.
// Probably you want to leave this on true
useCache: true,
onItemSelected : function($obj, itemId, selected) {
if (selected) {
add2Advanced("User with id = <a href='/Jan-Molendijk/Member-Profile.php?id=" + itemId + "' title='' class='postlink' target='hoofd'>" + itemId + "</a> has been added");
var titles = [];
for (var i in selected) titles[i] = selected[i].title;
add2Advanced("Current selected users: " + itemId + " " + titles.join(", "));
}
},
onItemRemoved : function($obj, itemId) {
add2Advanced('User with id = ' + itemId + ' has been removed');
},
onAlreadySelected: function($obj) {
add2Advanced('That user is already selected');
}
});
function add2Advanced(str) {
$('#advanced_actions').html($('#advanced_actions').html() + '<br />' + str);
}
});
</script>