Properties
Category
English
Similar Topics
Statistics
Comments
7
Participants
3
Subscribers
3
Votes
1
Views
2081
Share
Answered
After pressing a button, I want an input text field MyInput to get an initial text (respectively to be cleared). In the click routine of the button I tried the Java statements
ggbApplet.setValue("MyInput","New Text")resp.
ggbApplet.setValue("MyInput","")
but both statements don't change the value of MyInput at all (see attachment).
What's the correct way to change / to clear an input text field from a script?
Files:
setValue_newTex...
- GeoGebra
- Help
- Partners
-
Contact us
- Feedback & Questions
- This email address is being protected from spambots. You need JavaScript enabled to view it.
- +43 677 6137 2693
© 2023 International GeoGebra Institute
Why not use the simple GeoGebrascript with the command SetValue(text,"New Text" ) or SetValue(text,"" ) as command? start with defining the Inputfield as Inputfield(text) with text = "" instead of Inputfield().
So you already have got a text, and you can give it another value.
chris
The reason is that my script is pretty complex and needs java script functions to create the next question for the user (calculate next coordinate system, generate certain random numbers in a loop and so on). To prepare for the answer the input field needs to get cleared resp. to get an initial string to be manipulated by the user.
Isn't there a way to do it in a java script?
Using the escape sign ( \ ) of JavaScript I found a statement myself that works in JavaScript:
respectively
to clear the input text field.
It looks a bit ugly and I think, it would be clearer to use ggbApplet.setValue instead, but it works.
Try
setTextValue(String objName, String value)
It is clear, that you have to write to linked text variable (Test)?
ggbApplet.setTextValue("Test", "NewText4InputBox1")
Comments have been locked on this page!