Copy link to clipboard
Copied
I am using Adobe Captivate 5.5.
I am having a Text Entry Box (say, "Text_Entry_Box_10"). I want to know the value entered in this field during runtime. Is it possible to retrieve its value through Javascript and what is the command to retrieve it in the Javascript. If yes please suggest how.
regards,
Krishna
Copy link to clipboard
Copied
Hello Krishna ,
Yes you can retrieve the value using a Text Caption.
You need to insert the text caption on the location where you want to place the value . Change the text of Text Caption to $$Text_Entry_Box_10$$ .
The value enterd in the Text entry box will be displayed in the text caption.
Hope this Helps!
Thanks
Copy link to clipboard
Copied
Krisha, it is captured in a user variable that has the same name (if you didn't change it) as the TEB itself.
Have a look at Jim Leichliter's blog, how to get that variable using JS. http://captivatedev.com/category/javascript/
Lilybiri
Copy link to clipboard
Copied
Hi Lilybiri,
Thanks for the link. Will check and get back with what I am able to do.
Krishna
Copy link to clipboard
Copied
Hi Lilybiri,
Thanks for that blog. It guided me in how to get the value from a captivate Text Entry Box.
My need is to retrieve the TEB value from one slide and check if it has the expected value and based on that make the concerned TEB show or hide in the next slide. Is it possible to make a TEB (or any button) to show / hide dynamically through Javascript? If yes please suggest how. I googled but could not get appropriate answer.
Krishna
Copy link to clipboard
Copied
Hello Krishna (sorry for the typo in your name),
I pointed you to Jim, because he is the Javascript guru (I'm not at all) and you asked explicitly for JS.
However if I understand your question well, personally I wouldn't use JS but advanced actions (Jim will disagree for sure, he doesn't trust advanced actions).
Each TEB can be validated (you have to define the correct value) even directly and based on Success/Failure you can trigger an advanced action or a simple action. Let me know if you want to try that approach, otherwise I leave you to Jim's expertise.
Lilybiri
Copy link to clipboard
Copied
Hi Lilybiri,
No issues about the type in my name!
Yes Jim's page are pretty useful. In my case, I have 10 Text Entry Boxes. In the first slide after user enters values in these fields, in the next slide, I have to check for their correctness and display only those text boxes that have invalid inputs. In other words,
1. If all have been correctly input, I need not show the boxes. Will show "congrats" message.
2. If all have been wrongly input I need to show them with correct answer for understanding.
3. If only few of the 10 have been wrongly input I need to show only them alone. In this case, the "few" wrong input could be 1 field or 9 out of 10 fields. So as per probability I need to give 10*9 combinations and their corresponding actions (if....actions) right in the Advanced Actions section? Wont' that be cumbersome (as per my approach).
Hence for the above reasons I want to know the quicker solution through JS. Being an CP expert you may have some good ideas on this front. Please suggest!
Krishna
Copy link to clipboard
Copied
Should need some reflection. Will be back. Of course, I'm on CP7.0.1 which has extended functionality for advanced actions, but will keep to what is available in your version. Will tell you how much time I needed, for your use case (but limit to 5 TEB's). What has to happen if the user fails again on the second slide? You didn't tell that.
Lilybiri
Copy link to clipboard
Copied
Done (about 15 minutes for 5 TEB's). I did it on one slide:
Copy link to clipboard
Copied
Hi Lilybiri,
Thanks for the efforts. Sorry for taking time to reply!
Let me give an outline of what I am trying.
1. I have a slide where there are 10 text entry boxes.
2. User enters in all these fields and clicks "Save".
3. Upon saving, the control moves to next slide where, upon entering, I need to check first how many correct answers/wrong answers.
4. If all are correct then I simply show "Congrats" and hide the fields.
5. If all are wrong then I show all the 10 fields with correct answers so that user can check and compare.
6. In this case, its possible that the user may have got 4 correct and 6 wrong then I need to find which 6 the user got wrong and show those six fields only for user checking.
7. Apart from this I have no other slide to move further. It stops at this evaluation slide itself. So I have just 2 slides with 10 text entry boxes.
Now, coming to the sample you have tried, its nice to note the expression usage (I have not used before) and its good for "Correct" option. In case of "Wrong" I think you have used "Show" for all the 5 TEBs. Here, in case user got 3 wrong how do you check and identify the 3 TEBs that went wrong. Because the counter may return "3" as wrongs but which 3 do you identify and how you make them alone show up?
Please help.
Copy link to clipboard
Copied
No, if all answers are wrong you show one (or a group of) text containers with the correct answers. I have hidden all the TEB's. And as I explained I use only one slide, not two.
If the user has some answers wrong, you told me to leave only the TEB's that have a wrong entry. That is why I asked what you wanted to do then? No answer from your part, so I realized only what you originally asked for and it works fine that way. Meanwhile I deleted that file... Just wanted to show you it is not that complicated at all.
Lilybiri
Copy link to clipboard
Copied
Hi,
Yes based on your samples, they are not complicated as expected. But in the scenario in which I have 4 answers wrong out of 10 questions, I need to find out which 4 are wrong and show that right? What I have to do to identify those 4? Is it possible to achieve with a single query? As I am not that well versed with queries wanted to know how to utilize queries in effective manner. Please suggest.
Krishna
Copy link to clipboard
Copied
Krishna
What do you want to do with that knowledge? Each answer is stored in the associated user variable. But if you don't tell me what has to happen, how can I advise? For the user the situation is clear: only the TEB's that were incorrectly answered remain on the slide. What do you want ?
Lilybiri
Copy link to clipboard
Copied
Hi Lilybiri,
I think I have not been fully clear with my requirement. Or what I expressed is not conveying the required question. Or I am not understanding your "container" idea to its full.
Here is what I am trying:
1. I have slide 1 which has 10 fields. Now, I am allowing user to enter in these 10 fields.
2. After entering the user clicks "Submit" button.
3. In the next slide, I check if all answers are right or all answers or wrong or how many of them are wrong.
4. If all are right, I simply show "Congrats".
5. If all are wrong, I display all the wrong values along with correct values for user understanding.
6. In case if user makes 6 wrongs and gets 4 correct, I have to display that 6 wrong answer alone (with correct answers for them) for user understanding.
Point 4 and Point 5, I am able to do as per your ideas. When it comes to Point 6, I am struck. Since I have to find which 6 are wrong and display the corresponding fields and their corresponding answers for user understanding.
This is just an instance of getting 6 wrongs. It is possible to get 1 wrong, 2 wrongs, 3 wrongs......out of 10 right? So how to identify the specific fields that are wrong and how to display them is what I am trying to do.
Hope I am clear with my question in this and please suggest!
Copy link to clipboard
Copied
Hi Lilybiri,
Thanks for directing me to Jim Lietcher blog! I got useful suggestions from him about scripting and implemented same on experiemental basis and getting useful results.
Have a great day!