Gerardo
Gerardo

Reputation: 369

Pass parameter from one select function to another using onchange event

I have two different select option:

Html:

<select id="lstProveedor" class="form-control select2 select2-accessible" aria-hidden="true"></select>
<select id="lstcuadrilla" class="form-control select2 select2-accessible" aria-hidden="true"></select>

Function:

function getCuadrilla(sender) {
    sender.addClass("changed");
    $("#lstcuadrilla")
        .getJSONCatalog({
            onSuccess: function(response) {
                console.log(response);
            },
            url: '/Agenda/GetCuadrillas/' + "?ProveedorID=" + ID,
            valueProperty: "ID",
            textProperty: "NombreComercial"
        });
}

$("#lstProveedor")
    .getJSONCatalog({
        url: '/Agenda/GetProveedores',
        valueProperty: "ID",
        textProperty: "NombreComercial",
        onChange: getCuadrilla()
    });

I want to know how to send valueProperty from $("#lstProveedor") to $("#lstcuadrilla") to get into url: '/Agenda/GetCuadrillas/' + "?ProveedorID=" + ID, on change event, how can I do that?

I try to access it sending into onChange event like:

onChange: getCuadrilla(valueProperty)

then call into function

function getCuadrilla(sender,valueProperty)

but it don´t works. Regards

Upvotes: 1

Views: 589

Answers (1)

REDEVI_
REDEVI_

Reputation: 684

First on the lstProveedor list add this onchange function

<select id="lstProveedor" class="form-control select2 select2-accessible" aria-hidden="true" onchange="getCuadrilla(this.value)"></select>

In your getCuadrilla(ID) have a parameter which will receive this selected ID

You can remove the onchange from the jsoncatalog attached to lstProveedor

Upvotes: 1

Related Questions