once page loads
check if dataset1 field1 IsNot Null
make Button1 appear
else
keep Button1 hidden/make it disappear/print a message
The logic is to have a download button appear IFF the connected dataset’s field has indeed something to download and it’s not empty.
So how could I achieve something like this in Corvid/Javascript and more importantly, where would you be kind enough to redirect me for some solid and reputable/tested tutorials?
Print a message… (this message will be shown in the CONSOLE → Press F12, when you are using google-chrome-browser) also you will find the message in the console of “Preview-Mode”).
Thanks for the documenation. Thanks for the link to your site. Thanks for the code. Thanks for your time! I really appreciate it.
One small part left in question though: how to say, ’ if this dataset’s field is to be found empty, (hide the button, etc)'…
I know the answer/syntax is somewhere in the documentation and I’ve already started studying Javascript, but I’d appreciate a quick fix for my site, at the moment…
function getCurrentItem (): Object
getCurrentItem Parameters
This function does not take any parameters.
Returns
The current item, or null if there is no current item.
@russian-dima thank you for coming back, really. Well, I was trying to ‘digest’ all this information and to decide where/how to begin. Just visited your latest example and now browsing your source page. I guess I’m only missing the ’ if no file to download, then no download button ’ part of my code but I’m sure this is lurking somewhere in your examples.
(I come from Python. I have a good grasp on what’s going on but JS’s syntax is really all over me).
yes, just played with deleting the entries and re-entering new values, very nice, this is exactly what I was looking for but no time to test it yet. I’ll report back, you have many beautiful things in your tutorial site and I’m keep getting new ideas…
@gemats
Tell me your solution, when you have found it
This Download-List can be improved a lot !!!
Work on it, you have all the code for it, right now.
@yisrael-wix
Hello my friend, yes i was gone for a while, but now i try to come back.
Forgot a lot of Corvid-Programming in this time. I have to study it again a little bit .
@russian-dima This is what I came up with, still not good:
$w.onReady (function() {
//#text1 gets its values from a database collection
if( $w("#text1").isVisible ) { <--here, I want to say, if #text1 contains any value
$w("#button1").disable();
$w('#text2').text='No file to download. Button disabled!';
}
else {
$w("#button1").enable();
$w('#text2').text='Button functional! Proceed with download';
}
});
What I want to express is: if #text1 isEmpty/isNull/etc, then disable the button. I CAN disable the button by defining, for example, text1 visibility, but this is not what I want. Do you know how to build the expression above? How to check for #text1 (which is a simple text box (not input, like your example)) having any value or not?
@russian-dima No luck. This is the updated code. Doesn’t work. Doesn’t recognize the empty text box in order to disable the button. Button is always enabled, no matter if #text25 box loads empty or not empty in my page.
Hi, indeed I’m checking a dynamic page. I did the following and I get a lot of errors.
let current = $w("#dynamicDataset").getCurrentItem.comments();
if ( current === '' ) {
$w("#button1").disable();
$w('#text29').text='No file to download. Button disabled!';
}
else {
$w("#button1").enable();
$w('#text29').text='Button functional! Proceed with download';
}
@code-queen Still error: TypeError: Cannot read property ‘comments’ of undefined
let current = $w("#dynamicDataset").getCurrentItem.comments();
if (!current) {
$w("#button1").disable();
$w('#text29').text='No file to download. Button disabled!';
}
else {
$w("#button1").enable();
$w('#text29').text='Button functional! Proceed with download';
}