Dropdownlist is not passing the value in variable

Asked

Viewed 20 times

0

I’m trying to do a validation in javascript, but I’m not even able to pass what is inside a DROPDOWNLIST to the variable to make the comparison... The Nomeprojectofilho receives perfectly what has inside the variable, I believe because it is a Textbox. Already the projectName does not receive, it is a Dropdownlist...

Follow the codes below:

function validacaoCadastrarOS() {
    var NomeProjetoPai = document.getElementById("ProjetoId").value;
    var NomeProjetoFilho = document.getElementById("ProjetoNome").value;
    alert(NomeProjetoPai);
    alert(NomeProjetoFilho);
    if (NomeProjetoPai === NomeProjetoFilho) {
        alert("Nome da atividade não pode ser igual ao nome do Projeto");
        return false;
    }
    else {
        return true;
    }
}
  • Can you put the HTML of that dropdown? just as the question is incomplete.

1 answer

0


I solved with JQUERY, now it can take what is inside the Dropdownlist...

var NomeProjetoPai = $("#ProjetoId :selected").text();

Browser other questions tagged

You are not signed in. Login or sign up in order to post.