Why can't I get a textbox's value to simply show in another textbox?

I have textbox 1 labled txt1. I have it say “Hello World”

In another textbox, I select txt1 in dynamic data, but then there is not an option to simply select txt1’s value.

This couldn’t be more basic.

What am I not understanding about bubble?

Hi there, @bryan.holmes… what you are not understanding in this particular case is that a text element is only used to display text… it does not provide a value that can be used somewhere else. If you have two text elements that need to display the same thing, you would put the same static text in each element or build the same dynamic expression in each element.

Hope this helps.

Best…
Mike

2 Likes

That’s helpful to know. Thank you.

Weird. So I can access it’s properties for width, but not its property for value.

I’m struggling to “get” bubble.

You can’t get its property for value because it simply doesn’t have a value… it is for display purposes only.

But it does. Bubble has just decided to not give you access to that objects property.

Here’s another one. I add an expression element (exp1). Put in a number. Then try to reference that number in a text element. Now in dynamic data I can get exp1’s value, but then it is asking for more. I don’t understand this. And here’s a kicker, I can’t search the manual or anywhere to find details about the Expression Element because search results turn up results related to dynamic data expression builder versus the element and it’s purpose and how to use it.

How can I do something as simple as multiply two values coming from two different locations and display the result?

Okay, I guess I stand corrected then (but I don’t).

Here is an example where I have an input element (integer) called first input and another input element (integer) called second input. Here is the text element that displays the product of those two inputs.

multiply

1 Like

Here’s something I figured out. In an expression element, you must have filled in the result type. If I do and put in a number and pick the result type to be number it shows up in my text box when it is connected. However, and this is insane, if I choose Text in the expression builder element, then nothing shows up in the text box. This makes no sense to me at all.

No, text elements do not have a value property.

If you have some long, crazy, carpal-tunnel-inducing expression that you don’t want to construct over and over, you can

(1) copy it by right clicking and then paste it into another expression in some other text field [what I usually do is copy the expression in question, go to where I need it to go, right click and insert dynamic data and just pick the top-most expression (e.g., Current User), then right click Current User and paste

(2) create a custom state anywhere in your page (like on the page object itself - click the (i) icon to expose the inspector on an element and you’ll see you can create a custom state on that element). And then, on an event like Page Load, you set the state of that custom state to whatever your expression should be. (You can also dynamically create a custom state on some element while in the Workflow view and inserting the Set State action.)

What even is that? Are you referring to the Expression element from Toolbox? (If so, the value returned by the eval()'ed expression is available at the Expression Blah's value output.) Note that Bubble is strongly typed. All expressions have a type and can only be inserted into input fields of that same type (this is pretty much the only feature of the issue checker - it lets you know there’s a type mismatch). Most expressions (but not all) have textual representations and can be converted to text via some :operator on the expression and can hence be used in text elements.

2 Likes

The above being said: Would it at times be useful if text elements had an exposed state that echoed the text type expression found within the element to some exposed state? Yes, it would.

But if a Bubble element does not expose a certain property it does not have that property.

In the case of text elements, the choice not to expose a value or similar exposed state is probably a wise one. Publishing states takes time and it doesn’t make sense generally for text elements (the function of which is to create a <div> containing the enclosed text in the DOM) to offer such a feature.

Note that there are lots of other things besides vanilla Bubble’s custom states that can act like (or similar to) custom states, including my plugins such as List Shifter, the Floppy and Floppy Expression Watcher elements from Floppy, and the humble Input element (which is often abused as a way of taking some expression and echoing it to a value output, but I find special-purpose plugins better for such use cases).

2 Likes

Thank you. This helps. One of my areas of technical ignorance is html and css. I assume an element I’m using is like an object. I see how the text element is not. That now makes sense for so many experiences I’ve had.

A quick question, is a Custom State essentially a variable? So I can use them like a variable who’s scope is to the page?

Hey @bryan.holmes, that is exactly what Custom States are. They are basically local variables. They only exist in the page and yes their scope is the page itself in most cases. (They are also used in reusable elements as a way for reusables to communicate with the host page. Any custom states on the outermost container of a reusable are readable/writable from both the host page and the reusable.)

But, further to my comments about text elements and the reasons they don’t have a value property:

One challenge that we have with Custom States (and even my own plugins) and storing large amounts of text is that most text type inputs are of the short variety, not the “long text” input with Rich Text Editing capabilities (like you find in the text element itself).

This has bugged me for a while, so I took the opportunity to update Floppy Expression Watcher element, available in my commercial plugin Floppy (plugin page here, Floppy thread here).

What this element does is just watch some expression (either a list expression, a scalar expression, or both) and optionally publish the evaluated expression value to its list or scalar outputs, as appropriate. It also throws an initialized/updated event whenever the expression value changes.

Now it has a long text field inside it that can be used if the element’s type is set to text. So now you can actually compose a big text just like you’d to in a text element and then use that text in multiple locations. Works like this:

And now can reference that text anywhere:


And then in the runtime:

Floppy has a bajillion other cool features (it is primarily about browser storage, but it does a lot more) and it’s the new home for most of my plugin projects, so it’s regularly getting more cool new features and, thus, is a bargain at $12 ($6/monthly).

2 Likes