Explore the community Forums Lectora Lectora Questions & Answers Set Variable with contents of a Text Field

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #278542 Score: 0
    Profile photo of GeorgeCooper
    GeorgeCooper
    Member
    @GeorgeCooper

    How can I Set a Variable to the contents of a text field.

    What i want is for them to build up a sentence by clicking on a set of fields, which i could then output.

    Any ideas pleas?

    #298685 Score: 0
    Profile photo of KsElement
    KsElement
    Member
    beginner
    intermediate
    friend finder
    curious george
    contributor
    wise owl
    @KsElement

    Has anyone solved this challenge? I too would like to know 🙂

    • This reply was modified 4 years, 2 months ago by Profile photo of KsElement KsElement .
    #298849 Score: 0
    Profile photo of Darrel Somoza
    Darrel Somoza
    Member
    contributor
    friend finder
    beginner
    intermediate
    junior moderator
    advanced
    wise owl
    curious george
    profile
    199 pts
    @Klaatu

    I finally figured it out.

    1. set up a variable in Lectora (I’ll call it fromField)

    2. set up a text field in lecotra and put text in it and note its ID (mine is text38)

    2. on a trigger, such as a button click run the following JavaScript.

    3. x=document.getElementById(“text38”).textContent;
    VarfromField.set(x);

    You just set the Lectora variable fromField tot he contents of text38.

    Attachments:
    1. Field2Variable.zip
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.