Formatting text in a text box
August 14, 2015 12:00 AM
Hello
I have a textbox. The contents of the textbox are determined by setting a variable during a Change Content action. The text is displayed correctly. However, I would like part (or all) of the text to be in BOLD (or one of the other html formatting commands).
I do not seem to be able to do this. Any html command that I insert is interpreted as text e.g. it appears as undefined. Is there some way that I can control all or part of the formatting of text displayed in the text box?
I have looked in the help file but could not discover an answer for this (maybe I did not use the magic words during my search).
Thank you
Andrew
Discussion (13)
Thank you. I will have to find another solution. The only way I seem to be able to set up the text box to receive formatted text (e.g. all bold) is to "initialise" it with some text in the right format and when I send the variable, the entire box is filled with the same thing e.g. all text is bold. Is there some other way to set the text box format?
On a related question, is it possible to generate text boxes programmatically i.e. have Lectora produce a text box through an action (and presumably format it also, to the extent that it is possible)?
The only way I seem to be able to set up the text box to receive formatted text (e.g. all bold) is to “initialise” it with some text in the right format and when I send the variable, the entire box is filled with the same thing e.g. all text is bold. Is there some other way to set the text box format?This is the way to do it, yes.
On a related question, is it possible to generate text boxes programmatically i.e. have Lectora produce a text box through an action (and presumably format it also, to the extent that it is possible)?No, you cannot create objects via actions. At the end of the day, Lectora is a rapid authoring tool, not a HTML development IDE.
No, that's just not a feature in Lectora. You can set a whole textbox (formatted the way you want) to a variable value but not have partial formatting, unfortunately. If you REALLY want it, you can use JavaScript to add formatting to the textbox.
Thank you. I understand that it is a rapid authoring tool but it is sophisticated in many ways and we get to rely on that sophistication and the convenience of the system. For some reason that I do not understand, text manipulation through embedded strings seems to be problematic with tools like articulate and lectora (the ones I know best - very badly actually but I am learning) yet text manipulation can be so useful in giving feedback to learners (especially colour and font styles).
cheers
Darrel, here is your file which shows what I want to do. Does not work :(
Thank you so much Darrel. That's very interesting. Actually, I did try it in a browser served by an apache server. What I am actually building is a text variable and displaying it in a text block - not an alert box like the one which provides feedback in a quiz (like the one you created). That still does not work - even in a browser.
Hmm funny that the system appears to be inconsistent.
undefined
I know this is not exactly what you are looking for but you can dynamically change the contents in a text box, with html formatting, using javaScript (see attached). There could be a work around for what you are trying to ultimately accomplish using this method.
injecting styling code into a Lectora variable does not seem possible.
You could build the whole interaction in JavaScript/CSS and embed it into a Lecotra page.
I'll try more tomorrow.
Thank you Darrel :) - That is clearly a good possibility - in many contexts. In the application I have in mind, lectora would have to read the display string from a php script and then do some work to transform some of the words into hotwords (more JS - making it more difficult to manage inside Lectora which is really not equipped for long external scripts) and then communicate clicks etc. back to the script etc... It may be simpler and more effective to just embed the php script inside lectora (i-frame style) to keep a uniform appearance - then, in due course, the script would have to report results back to lectora for record-keeping purposes. Not impossible especially with lectora's built-in ability to post etc...
Any further ideas gratefully accepted. I very much appreciate the time that you are spending to help. Thank you! (klaatu barada nikto) :)
Hi, Andrew. Did you test your contents using preview in browser? I attached a sample question that uses html formatting in the feedback. It works fine when previewed in a browser, however, it shows the html tags in lectora's preview or run mode.
Can you attach an example of what you have built?
Darrel
Without knowing how many possible outcomes of your change contents actions there are, if only a few, you could add a text box with each variation of wording. Each text box would be initially hidden and use an action "on page show, show textbox X if variable =Y" It is a simplistic approach that is a bit tedious, but would allow you the versatility of formatting the text in each box uniquely.
Vicki
undefined
Using GSAP SplitText you could do what you want.
Steps to get it done would be:
- Get the source text from a textfield in Lectora
- Split the text in characters, words and/or lines- Each split element gets its own class.
- So when splitting check for the content you want formatted
- Set that content to another class
- Then all shows exactly as you want it.
Discussions have been disabled for this post