Join the Webstudio community

Updated 2 months ago

Code logic on URL Query String

At a glance

The community member is interested in reading and using query string parameters in their code to conditionally show/hide elements, set text values, change background colors, and update image sources. Other community members suggest that the "system" variable can be used to access search parameters, and that the "show" setting and ternary operators can be used to conditionally act on the parameter values. However, there is no explicitly marked answer in the comments.

It would be highly useful to me if I could read a querystring param and use code logic with it.

For example, depending on the value...
Show or hide elements.
Set an element's text value
Change an element's background color
Change an img src
B
H
O
6 comments
Hey, you can already access search params with "system" variable
I saw that I can access them. I just haven't found any way to conditionally act on them. If p1 = x, do a; if p1=y, do b, if p2=m, do c, etc.
Hopefully I'm just missing something.
there is "show" setting in every instance you can bind condition with system variable to it
Or you can bind ternary operator with system variable to image src
Example expression that returns true or false and shows/hides the instance system.search.something == 'something'
Add a reply
Sign up and join the conversation on Discord