I have the code below and I need to get several different values at once. One way I thought it was in array else does not work. After Ajax it brings me the results in id
zpl
, if the result comes empty it returns the warning that does not have the value in the bank. So that's fine, but I'd also like that if the result is SD10
and SD11
and so on, the same message of the empty condition also appears, but I wish I could not put several ous ||
in the condition and put the values inside a variable in array and make the comparison in
var variavel = new array('valor1','valor2');
document.getElementById('zpl').value == variavel;
Can anyone help me?
I would like to take several values and put inside a variable and at the time of doing the validation with the command document.getElementById('valor do campo').value ==
the variable that has these values. I've 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 text field of the page 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();
}