Load predefined data from columns and update field with possible selection with Javascript

Occasional Contributor

I am struggling with piece of code. I am working on SharePoint 2013 and I am trying to set 2 fields fixed when creating a new item in list. All 3 fields are lookup columns, but the red highlighted fields I want to set as fixed and the yellow highlighted field is conditioned by the field Vyberova_Skupina_Sluzba Also Vyberova_Skupina_Sluzba is conditioned by the field Vyber_Oblast




I used the part of the code below, the fields are fixed Vyber_Oblast and Vyberova_Skupina_Sluzba but third column is not updated.


function nastavSluzba(){
    $('#Produktova_Skupina_Sluzba').find('select').val('Hypotekárne úvery');    
    $('#Vyber_Oblasti').find('select').val('Úverové produkty pre FO')       
        $("#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"});

var allOptions = document.querySelectorAll("[title=Vyber_Oblasti] option");

[].some.call(allOptions, function(option) {
    if (option.innerHTML == "Úverové produkty pre FO") {
        option.selected = "Úverové produkty pre FO";
        return true;

var allOption = document.querySelectorAll("[title=Produktova_Skupina_Sluzba] option");

[].some.call(allOption, function(option) {
    if (option.innerHTML == "Hypotekárne úvery") {
        option.selected = "Hypotekárne úvery";
        return true;


Can you help me make sure that the third field is loaded automatically and that the user can select an option that falls under Produktova_Skupina_Sluzba ?

0 Replies