I am trying to make something hidden show when a selection tag is clicked.
This is the code I’m using:
export function ContempTag_click ( event ) {
$w ( ‘#optionThreePrice’ ). show ();
}
Is this not possible to do with selection tags? The code doesn’t work.
edit: I only have one tag inside the #ContempTag and its value is ‘Next’.
Edit two: I was thinking maybe I have to define the value of the tag but this code doesn’t work either:
export function ContempTag_click ( event ) {
if $w ( ‘#ContempTag’ ). value === “Next” {
$w ( ‘#optionThreePrice’ ). show ();
}
the error after if says : the condition will always return false since the types 'string ’ and ‘string’ have no overlap.
Little late on this, but thought I’d post for anyone having the same issue.
You would need to use onChange to access the selected tag.
Example code…
$w('#selectionTags').onChange((event) => {
const selectedTags = event.target.value;
});
Please note: If you have more than 1 selection tag, the value will show as an array for all of the tags that are selected. You can work around this by setting all the tags to deselected after your desired code has run.
Hope this helps.
1 Like
You can then run code using an if statement that queries the value of the selectedTags.
Something like this.
$w('#selectionTags').onChange((event) => {
const selectedTags = event.target.value;
if (selectedTags[0] === "exampleTagValue") {
//desired code would go here
}
});
Since the selectedTags returns an array, you need to select the first option. This is why [0] is necessary.
1 Like