In line variables

mlapl1
mlapl1 Community Member Posts: 349 ☆ Roadie ☆
Lectora has many good things - including managing the interface with the user. It can also connect with other systems and be augmented - that is a major strength. In Lectora16 we can embed variables in strings inside textboxes and control their displays through html tags. This is a significant addition to Lectora's capabilities - at least for me.

Now here is my question. Is there some way by which I can (easily) transform embedded variables into links or buttons which would open a Lectora object (e.g. make an invisible textbox visible) or simply run a Lectora action? Alternatively, can I do this through Javascript (I mean use Javascript to run a Lectora action or something like that - which could be triggered by clicking on an embedded variable)?

Thank you for any help.

Andrew

Comments

  • timk
    timk Community Member Posts: 1,207 ♦ Idol ♦
    If you have an inline variable in a textfield you can just turn it into a link the normal way. A link can do any action.

    Tim
  • mlapl1
    mlapl1 Community Member Posts: 349 ☆ Roadie ☆
    Thanks Tim. Yes. I can see how it might be done manually. I will follow up.
  • mlapl1
    mlapl1 Community Member Posts: 349 ☆ Roadie ☆
    Ok... as a followup - can I do the same thing programmatically by embedding linking instructions in the variable itself rather than creating a fixed link manually? That way the destination of the link itself will change. I am imagining that I may be able to change the destination through the action group and the conditional statements of the actions in the action group. Am I on the right track?

    Example: if the variable I am displaying is "Hello" clicking the word hello may display a message about Hello somewhere. But if the variable is "Goodbye" clicking the word Goodbye would display a message about "Goodbye".

    Hope that makes sense.

     
  • klaatu
    klaatu Community Member Posts: 988
    Andrew, you might also want to add a style sheet with the following:

    a span {

    text-decoration: none!important;

    }

    That will remove the underline from the link. You can do other things to it as well, such as changing the color (ex. color: red!important;) and/or weight (ex. font-weight: bold!important;). Just remember that because Lectora uses inline styling (uhg) you will need to use the override rule "!important" (no quotes).

    Keep in mind that, as Tim mentioned, you can add any action, including a run JavaScript.

    I'm not sure if this was part of your initial question but you can use JavaScript to run any Lectora action. Select the action and find its HTML Name like you would any other object (ex. action140). Then in a run JavaScript add:

    action140();

    Hope this helps.

    Darrel
  • mlapl1
    mlapl1 Community Member Posts: 349 ☆ Roadie ☆
    Ah... yes... just what I was looking for (in addition to the stuff Tim was talking about). Yes I did want to know how to use JS to run a Lectora action... Thanks Darrel.
  • klaatu
    klaatu Community Member Posts: 988
    Hmm, it seems that Lectora odd code strikes again. Although it SEEMS you can add a run JavaScript action using the link on a variable, it will not work. I think there is a work around, however. If you create an action group with the JavaScript you would have liked to run directly by clicking the variable(link) and then instead run the action group it so far seems to work.
  • klaatu
    klaatu Community Member Posts: 988
    Okay. Here is a sample that uses the JavaScript switch statement to display a picture depending on the current value of a variable. You can accomplish this without JavaScript, however, it will take many actions and the more options you want the more actions you need. Using the Switch statement adding additional options is as easy as adding additional cases.

    As I mentioned in a post above, while you can add a Run JavaScript action to a link, it will not function. The work-around is to instead add a Run Action Group that has the JavaScript the you want to execute when the variable is clicked.

    Hope this helps.

    Darrel
  • mnotermans5114
    mnotermans5114 Community Member Posts: 916
    This way you can call a group ( with or without actions inside Lectora )

    runGroup_og92415();// calls an action group inside Lectora

    If you want to show any specific group, use this trick.
    Cluster images, textfields and anything you need/want into a group in Lectora.
    Add an action to that group : Show -> Group, basically telling the group to show itself.

    Now if you run that group with the javascript above, it will show itself.
  • mlapl1
    mlapl1 Community Member Posts: 349 ☆ Roadie ☆
    Hi Darrel

    Thanks a lot... but the extern folder did not make it - could you send please - I think it contains some interesting things.

    cheers
  • klaatu
    klaatu Community Member Posts: 988
    Just the removeUnderline.css file is in the external folder. Here it is. What else are you looking for?

    The only JavaScript I added is in the group_1 Run JavaScript action.
  • mlapl1
    mlapl1 Community Member Posts: 349 ☆ Roadie ☆
    Thanks Darrel,

    still learning how to connect things together in Lectora - this will be very helpful.

     
  • mlapl1
    mlapl1 Community Member Posts: 349 ☆ Roadie ☆
    Thanks *very* much Darrel - great example - taught me lots.