How to get text value?

Jaeba shared this question 4 years ago

Is it possible for a JavaScript function to get the value of a text object?

For example,


  1. mytext = "pizza"

Followed by JavaScript:

  1. alert(ggbApplet.getValue("mytext"));

And this would result in a popup that says "pizza". This doesn't work because the getValue() command only returns a number which is NaN for text objects and there is no getTextValue function.

Comments (1)


I found the answer to my own question. It's not obvious, so here it is for anyone else searching for this.


  1. var textValue = ggbApplet.getValueString("objectName")+"";

The trick is that getValueString() returns some sort of pointer so you have to add a string to it like +"" to actually get the string value.

© 2022 International GeoGebra Institute