1. Fabrik 3.9 has been released. If you have updated Joomla to 3.9, this is a required update.
    Dismiss Notice

Populate dropdown options using javascript

Discussion in 'Community' started by mirceat, Sep 3, 2019.

  1. mirceat

    mirceat Member

    Level: Community
    Hello,

    I need a little help, please. I need to get the value written in a field and add it as an option in a dropdown list.
    The script below works fine using trigger: load, but i can't make it work for trigger:blur.

    For a new record, there is no value added to the dropdown when i write something in the field element, and for the existing records, the loaded values won't change if I modify the text in the field element.

    Please note: the field is in a repeat group.

    Code (Javascript):

    /*dropdown list*/
    var select = document.getElementById("contracts_tool_servicii___abonament");
    /*get value of the field element as array*/
    var options = [this.get('value')];
    /*loop*/
    for(var i = 0; i < options.length; i++) {
        var opt = options[i];
        var el = document.createElement("option");
        el.textContent = opt;
        el.value = opt;
        select.appendChild(el);
    }
     
    Thank you
     
  2. mirceat

    mirceat Member

    Level: Community
    anyone, please?
     

Share This Page