Gabriel Silva Gabriel Silva - 2 months ago 24
MySQL Question

Javascript append onblur.value mysql

I trying to get the value of an

input type="text"
and with it, check if it really exists at my database and, if true, append it with an
input type="hidden" value="value-of-last-input"
, but my code isn't working.

Here:

<input type="text" class="form-control" id="codigo" name="codigo" onblur="RetirarProduto(this)" />


and JS:

function RetirarProduto(campo) {
var codigo = campo.value;
alert(codigo);
});


I used
alert
to check the value, but it is not working.

Answer

Your function has one extra parenthesis at the end. Change your JavaScript to:

function RetirarProduto(campo) {
var codigo = campo.value;
alert(codigo);
}

And this should work. Here is a working JSFiddle. Let me know if I can help any further :)