Set the value of an asp.net dropdownlist with javascript in a content page

0

I have the following javascript function:

 function tipodepsolicitante_event() {
            var e = document.getElementById("ContentPlaceHolder1_cbotipodepositantes");
            var d = e.options[e.selectedIndex].value;
            if (d == "ER") {
                document.getElementById('<%= cbotipodocumentosolicitante.ClientID %>').selectedindex = 1;
                document.getElementById('<%= cbotipodocumentosolicitante.ClientID %>').disabled = true;
                document.getElementById('<%= cbopaisresidenciasolicitante.ClientID %>').disabled = true;
                
            } else {
                document.getElementById('<%= cbotipodocumentosolicitante.ClientID %>').disabled = false;
                document.getElementById('<%= cbopaisresidenciasolicitante.ClientID %>').disabled = false;
            }
        }

This is executed in the event: onchange of other dropdownlist , this works if the controls are disabled when executing the function: cbotipodocumentosolicitante and cbopaisresidenciasolicitante , but the .selectedindex in the first line does not work

I have tried many functions to set up data that I found on the internet but nothing works.

What am I doing wrong?

    
asked by Jeremy 27.01.2016 в 21:51
source

1 answer

3

You have it all in lowercase, the property selectedIndex takes the I in capital letters, try changing this and the value should go in double quotes.

document.getElementById('<%= cbotipodocumentosolicitante.ClientID %>').selectedIndex = "1";
    
answered by 28.01.2016 в 01:41