Hello!
I have a dynamic page that includes 3 buttons for downloadable content (ex. PDFs, PowerPoints, etc). Depending on the entry, there could be anywhere from 0 - 3 downloads available.
Can someone help me write code for the 3 buttons so that they are hidden if there is no content in the database? This is what I have so far - but it doesnβt seem to want to work. It makes the buttons disappear, but does so regardless if there is content in the field or not.
*Note: I have a text box called βnoneAvailβ that shows up if there is no downloadable content.
Thanks,
Wanda
$w.onReady(function () {
$w("#dynamicDataset").onReady( () => {
if($w("#down1").link !==null){
$w("#down1").hide();
$w("#noneAvail").show();
}
if($w("#down2").link !==null){
$w("#down2").hide();
}
if($w("#down3").link !==null){
$w("#down3").hide();
}
if($w("#survey").link !==null){
$w("#survey").hide();
$w("#feedback").hide();
}
});
});
2 Likes
Can anyone help? Any suggestions are appreciated!
Well - once again, trial and error won out, and I finally got something to work.
In case anyone is looking here for a solution, this is what I ended up with:
if ($w(β#down2β).label ===ββ){
$w(β#down2β).hide();
}
Luckily, I had given each downloadable content a title in the database that I would then use as the label for the button - I was able to reference that to see if it was blank. Works like a charm.
Hey Wanda , thanks for sharing this! I was looking all around for this like a mad man I appreciate you even more for following up. Thanks again.
Hi everybody.
I am looking for a condition that will show a shop gallery on my cart page only if there is a minimum purchase sum. (The idea is that customers who purchases above a certain amount, will be able to choose a free product from a specific gallery)
Any ideas?
Thanks and take care!
This didnβt work for me unfortunately.
$w . onReady ( function () {
$w ( β#vendorDatasetβ ). onReady ( () => {
if ( $w ( β#emailβ ). label === ββ ){
$w ( β#emailβ ). hide ();
}
if ( $w ( β#socialMediaβ ). label === ββ ){
$w ( β#socialMediaβ ). hide ();
}
});
});
I still see all the buttons whether they have content in the database or not. You can tell because when you roll over the images you canβt see a link on some.
Dataset Name:
Button Names:
Anyone have a follow up for this.
Here is the reference page:
www.thequeensmarketshop . com/vendors
Here is an image of the database showing blank entries.
Do you use a β> normal or a β dynamic dataset?
Normal page, or dynamic pages?
The problem is that you are looking to the label.
The label of your buttons isnβt changing.
Email vendor and vendor Site are the labels of the button,
You should check if the link is ββ or null
Kind regards,
Kristof.
Hey Kristof,
Thanks for your help.
I changed it to link <βtotally makes sense (I did try link before but another example showed me label.
I tried both ββ and null, with not luck. I am probably writing it wrong. When trying either (ββ or null) I get the social button missing (from all) and the email one always present.
This is the latest attempt.
$w . onReady ( function () {
$w ( β#vendorDatasetβ ). onReady ( () => {
if ( $w ( β#emailβ ). link === ββ ){
$w ( β#emailβ ). hide ();
}
if ( $w ( β#socialMediaβ ). link === ββ ){
$w ( β#socialMediaβ ). hide ();
}
});
});
(above results)
Thanks again. Any help is appreciated. I am doing this website for free because the store is in need of desperate support. Covid stinks. I am sure you all get it
I think you are missing an important piece of information. These buttons are on a repeater based on your screen shot. To set up the buttons on a repeater you need to use $w(β#repeaterNameβ).onItemReady(($item, itemData) => {
β¦
}
Also the logic is easier if you flip your logic and showing the button when you have a link VS. The other way around. So your default is that the buttons are hidden.
Then test to see if you have a link with a value.
Lastly because you are using a repeater you need to use the element scope $item like thisβ¦
$w(β#repeaterNameβ).onItemReady(($item, itemData) => {
if ($item(β#emailβ).link) {
$item(β#emailβ).show();
}
β¦
}
Hey there β¦
This is an old post and will be closed. Please open up a new thread with your own questions/ideas.