Explore the community Forums Lectora Lectora Questions & Answers Change null value on entry field

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #369565 Score: 0
    Profile photo of Jason Dalrymple
    Jason Dalrymple
    Member
    beginner
    intermediate
    profile
    wise owl
    curious george
    contributor
    friend finder
    advanced
    picture perfect
    54 pts
    @JasonADal

    I have a text block that updates based on the value of an entry field using onSelectChange. If you start entering data but then delete it all, the value becomes “null” and the text block displays “~~~null~~~”. I’m trying to figure out how to prevent the “null” value from appearing in the text block when you delete text previously entered.

    I tried a Modify Variable with the condition “contains null” before the action to change contents and as a condition of the change contents action to no avail. So the order of operations was either:

    onSelectChange: Set variable value empty IF variable contains “null”
    onSelectChange: Change contents to variable

    or

    onSelectChange: Change contents IF variable does not contain “null”

    I also tried the condition “not empty” on the change contents with the first set of actions, but this displayed the character you enter first. None worked, even with a delay on the Change Contents action. Suggestions are quite welcome. I can try and post a quick sample later if needed.

    • This topic was modified 2 years, 9 months ago by Profile photo of Jason Dalrymple Jason Dalrymple. Reason: added another attempted solution that failed
    #369571 Score: 0
    Profile photo of Stan Miller
    Stan Miller
    Member
    beginner
    intermediate
    LUC16 Attendee
    wise owl
    contributor
    curious george
    friend finder
    LUC17 Attendee
    37 pts
    @smiller7502

    A null variable doesn’t contain the string “null”; in Lectora, a null variable is empty. Set your condition to

    Set variable value empty IF variable Is Empty

    or

    Change contents IF variable Is Not Empty

    (In most programming languages, a null variable is not empty either; it’s nothing, and must be tested for with “Is Null” or “Is Not Null”. However, in Lectora, null variables are treated as empty.)

    #369573 Score: 0
    Profile photo of Jason Dalrymple
    Jason Dalrymple
    Member
    beginner
    intermediate
    profile
    wise owl
    curious george
    contributor
    friend finder
    advanced
    picture perfect
    54 pts
    @JasonADal

    That comes close, but still doesn’t work quite right.

    OnSelectChange: Set variable1 empty IF variable1 is empty
    OnSelectChange: Set text box variable1 if variable1 is NOT empty

    What happens here is that if I enter data in the entry field, then delete using backspace, it retains the first character I typed. It’s as if it’s not seeing that last backspace keystroke.

    Here’s an attachment with an editable entry field and both a read-only entry field and text block that get updated on SelectChange of the editable field.

    #369578 Score: 0
    Profile photo of Darrel Somoza
    Darrel Somoza
    Member
    contributor
    friend finder
    beginner
    intermediate
    junior moderator
    advanced
    wise owl
    curious george
    profile
    208 pts
    @Klaatu

    is Empty works for this Jason.

    Attachments:
    1. Title-14.zip
    #369581 Score: 0
    Profile photo of Jason Dalrymple
    Jason Dalrymple
    Member
    beginner
    intermediate
    profile
    wise owl
    curious george
    contributor
    friend finder
    advanced
    picture perfect
    54 pts
    @JasonADal

    It works if you have specific text or value you want to change it to, but not if you want to set it so that nothing displays. A workaround, I think, might be to just add a space to the “new value”, making the entry field effectively blank.

    Take “Jason” out of that field and you get that null text again.

    #369632 Score: 0
    Profile photo of Darrel Somoza
    Darrel Somoza
    Member
    contributor
    friend finder
    beginner
    intermediate
    junior moderator
    advanced
    wise owl
    curious george
    profile
    208 pts
    @Klaatu

    If you replace Jason with ‘&nbsp’ (no quotes) I think you’ll get what you want.

    #369646 Score: 0
    Profile photo of Darrel Somoza
    Darrel Somoza
    Member
    contributor
    friend finder
    beginner
    intermediate
    junior moderator
    advanced
    wise owl
    curious george
    profile
    208 pts
    @Klaatu

    Working example.

    Attachments:
    1. Title-14-1.zip
    #370251 Score: 0
    Profile photo of Darrel Somoza
    Darrel Somoza
    Member
    contributor
    friend finder
    beginner
    intermediate
    junior moderator
    advanced
    wise owl
    curious george
    profile
    208 pts
    @Klaatu

    Jason, did you try this?

    #370293 Score: 0
    Profile photo of Jason Dalrymple
    Jason Dalrymple
    Member
    beginner
    intermediate
    profile
    wise owl
    curious george
    contributor
    friend finder
    advanced
    picture perfect
    54 pts
    @JasonADal

    Hi Darrel – I haven’t yet. I got caught up in a simulation page that is really intense and triggers a ton of different branches, so have been focusing on that. I don’t want to lose my place, but will be going back to it before I go to QA. Hope you’re well!

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.