0
I created a function in javascript, but it returns me the following error:
Cannot read Property 'value' of null
Follow a piece of code:
function Distribuir(control) {
var tr = $(control).parents('tr');
var quantidade = $(tr).find("input[id*='txtQuantidade']").val();
var distribuir = document.getElementById("txtDistribuir").value;
if (document.getElementById("<%= txtDistribuir.ClientID %>") != null) {
var distribuir = document.getElementById("txtDistribuir").value;
resultado = distribuir - quantidade;
$(tr).find("input[id*='txtDisponivel']").text(resultado);
}
}
I am already doing the treatment to see if it is null, but still it returns the error. in the part var distribuir = document.getElementById("txtDistribuir").value
is always coming Undefined, I can’t get the value that is in this textbox.
You can post the HTML portion of the page?
– Paulo R. F. Amorim
are various inputs, know how to take the value of several and add them?
– Stand Alone
If you catch "Cannot read Property 'value' of null" on that line it is because the
id
there is no. If the html is generated by JSP which is what it looks like by the syntax, I advise you to view the generated source code on the page, as it may be different from what you imagine.– Isac