Copy link to clipboard
Copied
Hello,
I have a problem with changeState in Captivate and hope you can help me. I have 2 Images as buttons. Every button has 3 States, a normal, clicked, and done and I am trying to change the state of them.
When a button is clicked so it's variable gets +1 and when you click again it get's -1. The idea is when I click on button 1 I want to check via Javascript if button 2 == 1 if yes then it should change the state to Done. Unfortuantley, it doesnt work. Here my code:
if(zug_state_2== 1){
zug_state_2= 0;
cp.changeState("img_1_sifa","Done");
}
Is this JS being executed in the action that sets the variables?
I would log the value of zug_state_2, like so:
console.log(zug_state_2, zug_state_2== 1)
if(zug_state_2== 1){
zug_state_2= 0;
cp.changeState("img_1_sifa","Done");
}
It may be a string instead of a number so you could try:
if(Number(zug_state_2)== 1){
zug_state_2= 0;
cp.changeState("img_1_sifa","Done");
}
Copy link to clipboard
Copied
I think we would need to expand the view here.
The code you provided is fine as far as I can see.
Perhaps something is not named correctly. Remember that the names are case sensitive. (done vs Done)
Did you remember to assign the variable with a value of 1 when the button is clicked?
Copy link to clipboard
Copied
Is this JS being executed in the action that sets the variables?
I would log the value of zug_state_2, like so:
console.log(zug_state_2, zug_state_2== 1)
if(zug_state_2== 1){
zug_state_2= 0;
cp.changeState("img_1_sifa","Done");
}
It may be a string instead of a number so you could try:
if(Number(zug_state_2)== 1){
zug_state_2= 0;
cp.changeState("img_1_sifa","Done");
}
Copy link to clipboard
Copied
Thanks, I could use the console.log to check that the variable I used was wrong! After I changed it, it worked!