0
How do I eliminate in FOR
the value that is coming in the result variable. For example if vim 8:00 expose only the hours without 8:00.
function buscarHorarios(dataConsu)
{
medico = $('#umedico').val();
$.ajax({
url: 'select2.php', // declarando o script que vai conter os dados
type: 'POST',
dataType: 'json', // o tipo de arquivo de cambio que vai ser na usado na requisição
data:{dataConsu: dataConsu, medico: medico},
success: function (resultado, xhr, status)
{
var campoSelect = document.getElementById("uhoraConsult"); // resgatando o campo select
campoSelect.innerHTML = ''; // limpando o campo select
for (var i = 8; i < 18; i++) // percorrendo o resultado da requisição
{
document.getElementById("uhoraConsult").innerHTML += '<option value="'+ i +'">' + i + ':00</option>';
}
$("#uhoraConsult").focus();
},
error: function (xhr, error, status)
{
alert (error + status);
}
});
}
If the variable you are accessing from for can be treated as a string you can use the substr method. Ex:
var x = '8.00';
console.log(x.substr(0,1));
Passing position 0 and 1 you will take only the first character, in case 8.– Lucas Brogni
@Lucasbrogni can tell me if he can exclude only one element of the vector without erasing the others ?
– Gabriel
If you have any conditions to treat, yes.
– Lucas Brogni
@Lucasbrogni bro unrolled an algorithm in JS and runs only on CHROME in Firefox does not run.. know why of this?
– Gabriel
It can be the browser version. Check out https://caniuse.com/ what can and cannot be used in each browser.
– Lucas Brogni
@Lucasbrogni did a repeat and at a certain point he starts to insert Undefined in the fields I need know tell me why ?
– Gabriel