1
I have the code below and need to get several different values at once. One way I thought was array no longer works. After Ajax he brings me the result in id zpl, if the result comes empty it returns the warning that does not have the value in the bank. So far so good, only that I would also like if the result comes SD10 and SD11 and so on, also appear the same message of the empty condition, however I wish I could not put several ous || in condition and place the values inside an array variable and make the comparison in the
var variavel = new array('valor1','valor2');
document.getElementById('zpl').value == variavel;
Can someone help me?
I would like to take several values and put inside a variable and at the time of validating with the command document.getElementById('valor do campo').value == the variable that is with these values. I tried:
var arr = new array("s10","s11","s12","s13");
document.getElementById('valor do campo').value = arr
That is, it will compare the value of the page’s text field with the values of the variables stored in the variable arr .
Does anyone know how to do this in Javascript?
$.ajax({
type: "POST",
url: "label_query.php",
data: {
serial: $('#serial').val(),
combox: $("#combox").val()
},
success: function(data) {
$('#zpl').html(data);
var arr = new array('SD10', 'SD11', 'SD12');
if (document.getElementById('zpl').value == '' || document.getElementById('zpl').value == arr) {
alert('NÂO HÁ REGISTRO DESSE SERIAL NO BANCO DE DADOS!');
document.getElementById('serial').value = '';
document.getElementById("bSubmit").disabled = false;
document.getElementById("bSubmit").value = "Enviar";
document.getElementById("serial").focus();
return false;
} else {
criarArquivo();
document.getElementById("bSubmit").disabled = false;
document.getElementById("bSubmit").value = "Enviar";
document.getElementById("serial").focus();
}
use http://api.jquery.com/jquery.each/
– Thiago Friedman
What gives
console.log(data);in the first line ofsuccess: function(data) {?– Sergio