I am trying to clear a multi value lookup field using javascript when an item is re-edited.
I have tried all the following combinations without success
$("input[id^='Test'").removeAttr();
$("input[id^='Test']").val(null);
$("input[id^='Test']").val([]);
$("input[id^='Test']").val('');
$("input[Title='Test']").val('');
$("select[title='Test']").val('');
$("input[id$='Test'").removeAttr();
$("input[id$='Test']").val(null);
$("input[id$='Test']").val([]);
$("input[id$='Test']").val('');
I have had limited success with the following:
var value = $("input[id$='Test']").val();
var regex = /\|t/g;
var value = value.replace(regex, ';#');
var vars = value.split(';#');
for (var i = 0; i < vars.length; i++) {
$("[id^='Test'] option[value='"+vars[i]+"']").remove();
i++
}
In this last one, it does clear all the values from the display box, but does not seem to change the underlying data as all the selected items still appear on the list after the close of the edit form.
The following link seems to be relevant - Clear Multiselect Lookup the only difference is that I don't want a button to initiate the Clear.
The other reference I found was: http://www.dotnetspark.com/kb/6185-set-defaulting-values--removal-multi-lookup.aspx
How can I clear the selected options using Jquery? Is there another easy way of doing this?