Here is My Problem:
I have a New Form in a list and I have added some custom JS code to it. In the form is a "Registration number" lookup field with more than 20 items in it. I need to populate it with data(the data is correct) and then hide it so that it is invisible.
Here is The Code(or part of it):
$().SPServices.SPComplexToSimpleDropdown({
columnName: "Registration number"
});
var RNField = getTagFromIdentifierAndTitle("select","","Registration number");
setSelectedOption(RNField,some_value);
function setSelectedOption(select, value){
var opts = select.options;
var l = opts.length;
if (select == null) return;
for (var i=0; i < l; i++)
if (opts[i].text.replace(/\s/g, "") == value.replace(/\s/g, "")){
select.selectedIndex = i;
$(select).closest('tr').hide();
return true;
}
return false;
}
This code seems to work: it populates the field and hides it(when inspected with firebug the values are correct).
However when I add all the data and save the list item, in the list the field "Registration Number" is empty. Why is that?
What I saw:
$().SPServices.SPComplexToSimpleDropdown
creates a new DropDown and hides the original Complex DropDown. When the data is changed in the new DropDown the data in the Complex DropDown is not changed.- The "Registration number" is not a required field on the form.
- I tried to implement my own version of the SPComplexToSimpleDropdown but it still works almost the same. The field is still blank in the end.