autocomplete

autocomplete

ergunergun Posts: 12Questions: 3Answers: 0
edited January 2015 in Editor

Is it possible to display the variable " idaliSelectionner " I recovered from the autocomplete event and put it in my field label : "ID Aliment " parameter "def" :

{ 
label: "Aliment :", 
name: "ingesta.libali", 
type: "autoComplete", 
opts: { 
source: "./php/autocompleteAli.php", 
minLength: 3, 
select : function(event, ui) { var idaliSelectionner = ui.item.id ; } }, 
}, 

{ 
label: "ID aliment :", 
name: "ingesta.id_ali", 
//def: idaliSelectionner 
type: "readonly" 
},

If you can help me it would be cool ! Thank you

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    Hi,

    Yes, this should be quite possible using the field().label() method in your select function. For example you might use:

    select: function ( event, ui ) {
      var idaliSelectionner = ui.item.id;
    
      editor.field( 'ingesta.libali' ).label( 'Aliment '+idaliSelectionner+':' );
    }
    

    Allan

  • ergunergun Posts: 12Questions: 3Answers: 0

    I wish that the variable is displayed in the input and not the field label

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    I'm a bit confused I'm afraid - you asked above for the selected value to be displayed in the label, which I think the above does. However, you note now that you want the value to be displayed in the input. Is it not already there?

    Allan

  • ergunergun Posts: 12Questions: 3Answers: 0

    yes sorry

  • ergunergun Posts: 12Questions: 3Answers: 0

    the solution :
    editor.field('ingesta.id_ali').set(+idaliSelectionner) ;

This discussion has been closed.