Forums

Autocompleter value back to empty

bcouvin 27 Dec, 2015
Hello,

I used a standard autocompleter. After chosing a value, the field is set with this value.

I would like to delete and let this field empty.
I was thinking a workaround by adding a blank character. But a blank is not empty.

How can I do to keep this field empty when I already had a value?

Thanks for your helps.
Bertrand
GreyHead 28 Dec, 2015
Hi Betrand,

I think that with the standard AutoCompleter the only real way to do with would be to add a 'Delete' link of button with a little JavaScript to reset the value.

Bob
bcouvin 29 Jan, 2016
Hello Bob,

I have time to come back to this topic.
I did try this. It did not work.

I think that the JS code I try is not the correct one. I think it could not be simply used as the code below:


function ResetMultiField() {
   JQuery(".ResetMF").val("");
}


In fact, I have a multi-field of 6 autocompleter fields, plus a button at the end of this multi-field, which calls a JS named ResetMultiField() function. Those fields have class "ResetMF". I would like to reset all the fields based on "ResetMF" class.

I also tried:

function ResetMultiField() {
   jQuery("#tag1").autocomplete({
     select: function(event,ui) {
       jQuery(".ResetMF").val("");
     }
   }
}


In Autocompleter feature, for the first field on the 6 fields, there are Field Selector (#Field1) and Field ID (tag1).
Do you know what is wrong in the JS code?

Thanks a lot for your help.
Bertrand
GreyHead 30 Jan, 2016
Hi

You could try
 jQuery(".ResetMF").each( function() {
  jQ(this).val("");
});

Bob
bcouvin 30 Jan, 2016
Hello Bob,

I tried your proposal. This work only for text fields but not for autocomplete field.

I saw with the browser debugger (please have a look on the image joined), there is something strange.

[attachment=1]Capture d’écran 2016-01-30 à 16.40.00.png[/attachment]

I join also the image of the MultiField at Front End.
[attachment=0]Capture d’écran 2016-01-30 à 16.40.00.png[/attachment]
The first field is autocomplete, labelled "text3" and its field id is "c3".

The autocomplete feature has added another id --> "select2-chosen-1", while my fied id is "c3". You will see this some lines below in the second image attached.

Even when I try to remove the value of "select2-chosen-1" with

jQuery("#select2-chosen-1").val("");
jQuery("#c3").val("");

this remove the text "SAP" at the Front End. So this field, viewed from the user, is empty. But the value related to the id="c3" is still there. It is not possible to remove it completely, so the DB Save action does not remove the value for this field.

The command jQuery("#c3").val("") has no effect on the line related to the <input id="c3" class=....></input>. Very strange.


Regards
Bertrand
bcouvin 30 Jan, 2016
Oops, sorry for the image joined.
[attachment=0]Capture d’écran 2016-01-30 à 16.56.16.png[/attachment]

Bertrand
bcouvin 02 Feb, 2016
Hello Bob,
Is there a solution for this?
Bertrand
This topic is locked and no more replies can be posted.