How can I set a variable value based on conditions and display an Alert in JavaScript?
Hello, I have a code that utilizes Alerts to display the results of evaluating the visibility status of two controls using jQuery.
If pnlResultados is visible, it will show: No Results or No hay Resultados. If PnlNoResultados is visible, it will show: Results Available or Si Hay Resultados.
This is the code:
Dim Banner As String = "setDDLday();
var HayDescargaSiONo = 's';
function setDDLday() {
setTimeout(VerificaResultados,100);
function VerificaResultados() {
if ($('#ctl00_MainContent_PnlNoResultados').css('display') != 'none') {
HayDescargaSiONo ='No Hay Resultados';
} else if ($('#ctl00_MainContent_PnlResultados').is(':visible')) {
HayDescargaSiONo ='Si Hay Resultados';
} else {
setTimeout(VerificaResultados,100);
};
};
alert (HayDescargaSiONo);
}"
When I put an Alert immediately after assigning a value, the result is displayed correctly: ex. "No Hay Resultados". However, when I try to get the value of the HayDescargaSiONo variable with an Alert, it shows "Undefined" and fires faster than expected.
What could be going wrong?
I need to properly assign a value to the HayDescargaSiONo variable.
If it satisfies the first condition, then should be assigned "No" Else If it satisfies the second condition, it should be assigned "Yes".