Hi,
I want to make a text box to show if a specific value is found inside another text box. I use the following:
$w.onReady (function() {
if ($w("#counter").text === 448) {
$w("#text29").show();
}
else {
$w("#text26").show();
}
});
#counter text box gets dynamically its value from here:
export function table1_dataChange(event) {
let count = $w("#dataset1").getTotalCount();
$w("#counter").text = String(count);
}
Problem: text box #text29 never shows up, although #counter shows a value of 448. What am I doing wrong?
To complete this thread, I'd like to report that I solved my problems, most probably in a quite unorthodox way.
Since the export function to get me all items counted in my dataset1 was working, I thought just to try to embed my conditionals just below it and do not mess with the on.Ready(), due to problems found with the connection between my 2 datasets.
So I ended up with this:
export function table1_dataChange(event) { let count = $w("#dataset1").getTotalCount(); console.log(count) $w("#counter").text = String(count); if ($w("#counter").text === "1") { $w("#text25").show(); $w("#text12").hide(); } else {$w("#text12").show(); $w("#text25").hide(); } }
Smart or dumb, I don't know, but it finally works. Thanks J.D. and russian-dima for your efforts.
Can you make a pic of your database? Live and preview (just first 3-5 rows of data and the HEADER).
Can you show a pic of your dataset-options?
And your last used code (full code which is actually used for the simple example to solve the problem).
EDIT: already tried to run your code in another BROWSER ? Internet-Explorer / Edge / FireFox / Opera / Brave or something like that ?
Hello,
"counter" is a textfield?
Counter.text ---> what does it say? Isn't it a ---> STRING ? (.text)
But 448 is a NUMBER, right? --> could this be the problem ?
Try ---> "448" something changed?
Play around and convert from STRING into NUMBER, or NUMBER into STRING. Did you get your goal ?