Forum Discussion
Copying a user entered text to a SL Variable using Java
Hello,
I want to copy text that is entered in a text entry field, call Input_Text_Here, to a variable called UserAns.
I have hit a roadblock, I cannot get the user-entered text to copy to the SL Variable. I have attached my SL file for people to have a look at. Can anyone help me?
I don't want to use the input entry from thing, as this is very restrictive and relies on upon submit buttons, etc. My plan is to use this copy text to the variable and then compare this variable to a text in a trigger, which will then move to the next slide.
Thanks
- WaltHamiltonSuper Hero
I believe SL has quit using jquery.
- SandeepGadamCommunity Member
Hi there, if my understanding is correct, when user enters text within the provided text input field labeled as "enter text here", that value should reflect to the variable "UserAns" next to Project Var: UserAns. Am I on the right path? If yes, then add the following trigger:
Adjust variable,
UserAns to variable TextEntry
When object loses focus on "Input_text_here".As soon as user enters the specific value that value will be reflected to this variable. Please let me know if this helps.
- MathNotermans-9Community Member
As Sandeep states... this fixes it... However you still have to loose focus on the textfield...so click out of the textfield to activate the trigger, change the variable and go to the next page.
I do remember a question on the forum on adding entered data in an input field to a variable upon typing... so it is possible too... - FionaOSullivan-Community Member
Hello Math, do you know where this post is? I have tried looking for it, and this would be better, as relying on people to click 'out of the box' to confirm the entry is not the best way. I don't like the SL way of text entry checking, as it relies on the user entering the text correctly at first, and we all know we make mistakes. I am trying to do it so the user can have a natural, straightforward text entry that doesn't require them to do something abnormal in the process I am trying to teach them.
Thank you everyone else, I will try the fix shortly and see if it works
- FionaOSullivan-Community Member
Walt JSquery was removed as an automatic thing in SL, if you load it in the Javascript it should work, or at least that is what I have been told
- MathNotermans-9Community Member
I will see if i can find the sample mentioned... and indeed if you load jQuery you can use it...in your sample however the jQuery load line was commented so it couldnot work.
- FionaOSullivan-Community Member
I know, I was trying to see if it was needed or not. I was trying so many script ideas. JS is not my strongest skill, and it resulted in a lot of trial and error.