Forum Discussion
Set value of a lookup field with Javascript - SharePoint 2013
I have a question about custom list in SharePoint 2013. I made custom list basically with html, css and javascript.
In my custom list I have 3 columns with lookup, the main column name is Vyber_Oblasti, child name is Produktova_Skupina_Sluzba and child of Produktova_Skupina_Sluzba is Pytam_Sa_Na. Depending on the parent, the data structure changes to child1. As soon as I set the type to child1, the data structure changes to child2. In javascript I set the value for main and also for child1, but I can't set it manually for child2.
If a person opens the list, main and child1 should be fixed - which is what I have set. Now I need to set it in javascript so that according to the fixed view child1, the behavior changes to child2 and can choose the option derived from child1.
function nastavSluzba(){
$('#Produktova_Skupina_Sluzba').find('select').val('Hypotekárne úvery');
$('#Vyber_Oblasti').find('select').val('Úverové produkty pre FO')
$('#tableNapoveda').remove();
$("#Vyber_Oblasti").find('select').attr("disabled", true);
$("#Produktova_Skupina_Sluzba").find('select').attr("disabled", true);
$("#Vyber_Oblasti").find('select').css({"background-color": "white","color": "black"});
$("#Produktova_Skupina_Sluzba").find('select').css({"background-color": "white","color": "black"});
function nastavPytam(){
$('#Pytam_Sa_Na').find('select').find('option').remove().end().append('<option value="0">(None)</option>').val(0);
$('#Produktova_Skupina_Sluzba').find('select').on('change', function() {
$('#Pytam_Sa_Na').find('select').find('option').remove().end().append('<option value="0">(None)</option>').val(0);
zmenDefaultHodnotySelectov();
hideDoplnujuce();
getSluzba(list_komponenty,$(this).find(":selected").text(),$("#Vyber_Oblasti").find(":selected").text(),function(id,psn,tim){
$("#Pytam_Sa_Na").find('select').append("<option value='"+id+"'>"+psn+"</option>");
});
var allOptions = document.querySelectorAll("[title=Vyber_Oblasti] option");
[].some.call(allOptions, function(option) {
if (option.innerHTML == "Úverové produkty pre FO") {
option.selected = "selected";
return true;
}
});