Accessing variables and adding new text fields

PennController for IBEX Forums Support Accessing variables and adding new text fields

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #9859
    prajeev
    Participant

    Hi! I’m currently working on a manual verification dashboard. I have a CSV file where rows consist of sentences and part-of-speech tagging. I would like participants to verify that each sentence segmented correctly, and that the part-of-speech tagging is correct. Here is my demonstration link: https://farm.pcibex.net/r/GztAsy/.

    My two questions are:

    1) In one part of a trial, I set a variable “segmentation” to be the input from a TextField.

    // Store the text from inputID into Var element
            newVar("segmentation")
                .global()
                .set(getTextInput("sentence_seg"))
                .log()

    When I want to access the variable again in the same trial, I get an error saying “TypeError: t.replace is not a function (newTrial: 3)” and “Command ‘replace’ unknown on Var element ‘segmentation’. (newTrial: 3)”. The variable is global, not that it should matter since I’m accessing it within the same trial, but I wasn’t sure how to go about this. I’m trying to create a new text using the inputted text (the segmentation variable).

    2) In the segmentation task, is there a way to allow users to add additional text input’s themselves? I wanted to see if it was possible to allow users to input one sentence in one text input.

    #9860
    Jeremy
    Keymaster

    Hi,

    1) You can not use getVar inside a newX command. Instead, you need to use it inside the Text element’s text command, like this: newText("sentence", "").text( getVar("segmentation") )

    2) The easiest solution would be to create as many TextInput elements that you will allow the user to add, and dynamically add/remove them to/from the page. Here is an example with the possibility of adding up to 5 extra input boxes: https://farm.pcibex.net/r/kZmhKa/

    Jeremy

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.