for some reason the code:
if ($w("#checkbox1").checked === true && $w ("#checkbox2").checked === false) {...
it is not working inside a repeater.
“&&” prevents the code from being identified or executed
real code:
if ($w("#var1").checked === true && $w("#var2").checked === true ) {
$w("#textid1").text = "+" + var_n1 + var_n2
let result = itemprice + var_n1 + var_n2
let totalresult = parseFloat(result).toFixed(2);
$w("#textid2").text = totalresult
}
Every item in a repeater you have to call with —> $item
Every item outside of repeater you call with —> $w
$w.onReady(function () {
$w("#myDataset").onReady( () => {
$w("#myRepeater").forEachItem( ($item, itemData, index) => {
if ($item("#var1").checked && $item("#var2").checked) {
let result = itemprice + var_n1 + var_n2
let totalresult = parseFloat(result).toFixed(2)
//if OUTSIDE of REPEATER.......
$w("#textid1").text = "+" + result
$w("#textid2").text = totalresult
//if INSIDE of REPEATER....
$item("#textid1").text = "+" + result
$item("#textid2").text = totalresult
}
} );
} );
} );
Not tested!
But normaly this should work.
still dont work
if ($item("#var1").checked === true && $item("#var2").checked === true) {
console.log("work")
}
@p3tri1ell0
var1 is a checkbox / switch , or what is it?
Is this item inside a repeater?
@russian-dima var1 is a checkbox
its inside the repeater
it identifies itself, but with && it stops working
even if for variables like some1 and some2
if ($w("#var1").checked === true) {
some1 = 1
} else {
some1 = 0
}
if ($w("#var2").checked === true) {
some2 = 1
} else {
some2 = 0
}
if (some1 === 1 && some2 === 1) {
console.log('OKEY')
}
////////////////////////////////////
if (some === 1) {...} <- //working fine
if (some === 1 && some2 === 1) {...} <- //nothing happens