Hello
I am sure this is a simple fix, although currently struggling to get the code below to return the correct values.
Essentially, the “ticker” is the dynamic page ID, and I want to simply change the state of a multi-state box based on the ticker ID, when the dynamic page is loaded.
Eg, three possible pages
wix.com/stocks/ticker1 >>> shows multi state 1 (AGL)
wix.com/stocks/ticker2 >>> shows multi state 2 (ALL)
wix.com/stocks/ticker3 >>> shows multi state 3 (ALQ)
Currently always just returning the first option - AGLstate
Much appreciated in advance.
$w . onReady ( function () {
if ( $w ( “#ticker” ). id = “agl” )
{ $w ( ‘#statebox8’ ). changeState ( “AGLstate” )}
else
if ( $w ( “#ticker” ). id = “all” )
{ $w ( ‘#statebox8’ ). changeState ( “AGLstate” )}
else
{ $w ( ‘#statebox8’ ). changeState ( “ALQstate” )}
});
Fortunately worked this out…
For anyone looking for a work around to having changing iframes on a dynamic page… the relevant html code needed can dropped in an iFrame on a multiframe box…
Then the code below can be used display the correct iFrame when the dynamic page loads, essentially checking one of the fields in the dynamic dataset (in this case “ticker”), then using that to set the multistate box with the if statements.
Yet to confirm how well it works with a big dataset.
$w . onReady ( function () {
// Write your JavaScript here
$w ( ‘#dynamicDataset’ ). onReady (()=>{
**let** currentItem = $w ( '#dynamicDataset' ). getCurrentItem ();
console . log ( currentItem )
**let** currentTicker = currentItem . ticker
console . log ( currentTicker )
if ( currentTicker === “AGL” )
{ $w ( ‘#statebox8’ ). changeState ( “AGLstate” )}
else
if ( currentTicker === “ALL” )
{ $w ( ‘#statebox8’ ). changeState ( “ALLstate” )}
else
{ $w ( ‘#statebox8’ ). changeState ( “ALSstate” )}
})});