1
I have a script with functions to control what each button of an application does. I declared a global variable so that when all buttons are clicked, two actions are triggered: hide a div and show another.
//variável global
var completo = 0;
//funções para controlar 9 botões - em cada uma das funções incremento a variável:
function A()
{
faz qualquer coisa;
completo++
}
function B()
{
faz qualquer coisa;
completo++
}
function C()
{
faz qualquer coisa;
completo++
}
function D()
{
faz qualquer coisa;
completo++
}
function E()
{
faz qualquer coisa;
completo++
}
function F()
{
faz qualquer coisa;
completo++
}
function G()
{
faz qualquer coisa;
completo++
}
function H()
{
faz qualquer coisa;
completo++
}
function I()
{
faz qualquer coisa;
completo++
}
So far it should increment 9 times the complete variable, being complete=9, right?
Then it would trigger action - when the variable reaches 9, hide the general div and show final div.
if(completo==9)
{
$('div[id^="final"]').show();
$('div[id^="geral"]').hide();
}
this last part is not functional.
also tested with the following, but without success:
if(completo==9)
{
$("#final").show();
$("#geral").hide();
}
can help me?
In the html part I have declared both the general div and the final div:
<div id="geral">"conteudo blablabla"</div>
<div id="final">"conteudo blablabla"</div>
What is the code that calls these functions A, B, C, ...? I don’t see where these functions are called and the
completo
is always zero...– Sergio
The code of the button that calls the contents of the function is: <td><input type="button" class="astext" value="D" onclick="A()"/></td>
– lfprata
Okay, so within each function you have to call another function that has the
if
inside. If not thisif
is only checked when the page loads and never again. It makes sense?– Sergio
Aside from the problem @Sergio pointed out, this all assumes that each button can only be pressed once, right? Because if you allow more than one click per button, your logic will not work (for example, press 9 times a single button to meet the condition).
– bfavaretto
bfavaretto, correct, that part will still be evaluated below. For now I am committed to putting this functional! : ) Sergio, thanks for the tip, excellent!
– lfprata