How do you expand/collapse boxes based on the tags selected?
I have a “Selection Tags” element, titled “boxTags” with 4 Choices of Tags defined as : Tag1, Tag2, Tag3, Tag4
I have 4 collapsed boxes defined as: collapsedBox1, collapsedBox2, collapsedBox3, collapsedBox4
I want when a user clicks on Tag1 that it will expand collapsedBox1 (and so on). I thought it would be a simple onChange event, but it’s not doing a thing. I’ve tried multiple variations with no result including a Submit button.
I’ve gone back to just trying to use an onChange event. I even just tried to put in 1 value just to get it to work. No success.
This is the code:
export function boxTags_change(event) {
if ($w( '#boxTags ).value === “Tag1” ){
$w( ‘#geofencingbox’ ).expand();
}}
BTW, I’m having to go this route, cuz the previous way I was trying to do things would input data in to my database. I initially set up buttons, that when you select Button 1 it will expand a collapsed box (easy), but then I wanted my database to have a field that shows the button(s) selected was Button 1.
I can get an input field to change the content in it via onChange but when I submit the form it doesn’t add that new content to the database.
So, I started this as a workaround because the tags record in the database (easy), but now I can’t expand collapsed boxes! UGH
Hi, $w( ’ #boxTags ).value returns an array of selected values. Hope this helps.
From the corvid API reference documentation:-
let myValue = $w(“#mySelectionTags”).value; // [“value1”, “value2”]
So like this? Doesn’t seem it would do anything.
export function displaytactictags_change(event) {
let myValue = $w( “#displaytactictags” ).value; // [“Geofencing”, “Site Retargeting”, “Search Retargeting”, “Event Fencing”]
if ($w( ‘#displaytactictags’ ).value === “Geofencing” ){
$w( ‘#geofencingbox’ ).expand();
}}
hmm… please lookup on how to process an array in javascript. In your case if the user selects “Geofencing” from the selection tag.
The $w( ’ #displaytactictags ’ ).value will be an array containing the selected value, not the value itself.