Question T18235
Visible to All Users

form fields values

created a year ago

We have a scenerio where we have three fields ( 2 input fields and 1 boolean field) lets example

  1. Name: This is an input field where users can enter a name. For example, let's say the value entered is "Prince".
  2. IS Eligible: This is a boolean field where users can select either "IS Eligible" or "IS NOT Eligible" to indicate eligibilit
  3. Eligible Candidate: Another input field. When certain conditions are met, this field should display the value of "IS Eligible" (either "IS Eligible" or "IS NOT Eligible") along with the name entered in the first field.

For example, if "Prince" is entered in the first field and "IS Eligible" is selected in the second field, the third field should display "Prince IS ELIGIBLE".

Like this - {question 1 value}+ {question 2 value} + default value like (for next round).

so its possible how to set the value of 3rd question based upon selected questions when we are making the survey.

Answers approved by surveyjs Support

created a year ago

Hello,
You can use the setValueIf and setValueExpression properties to set the third field's text based on values entered within first two fields. Use question placeholders {questionName} to reference question values in expressions. To add some default value, you can simply add a string literal to the setValueExpression expression or use a calculated value to store the default value. Consider the following survey JSON definition:

JSON
{ "pages": [ { "name": "page1", "elements": [ { "type": "text", "name": "name", "title": "Name" }, { "type": "boolean", "name": "isEligible", "title": "Is Eligible" }, { "type": "text", "name": "eligibleCandidate", "title": "Eligible Candidate", "setValueIf": "{name} notempty and {isEligible} notempty", "setValueExpression": "iif({isEligible}, 'IS Eligible ', 'IS NOT Eligible ') + {name} + ' ' + {defaultValue}\n" } ] } ], "calculatedValues": [ { "name": "defaultValue", "expression": "'Some Default Value'" } ] }

I used a Boolean question to represent the 'Is Eligible' field. You may wish to use another question type depending on your requirements.

For more information about survey expression syntax, please visit Conditional Logic and Dynamic Texts

Please let me know if you have any further questions.

Thank you

    Comments (1)

      thanks

      Other Answers

      created a year ago (modified a year ago)

      That the json

      JSON
      { "logoPosition": "right", "pages": [ { "name": "page1", "elements": [ { "type": "qrcodeverification", "name": "Qr Code Verification", "validationCode": "L5IPVDFKFLUTUHDQDB46" }, { "type": "locationfetch", "name": "Fetch GPS Corrdination", "validationCode": "A5IPVDFKFLUTUHDQDB46" }, { "type": "facerecognition", "name": "Face Recognition", "validationCode": "FACE" }, { "type": "text", "name": "name", "title": "Name" }, { "type": "boolean", "name": "Would you like maths", "title": "Would you like maths" }, { "type": "text", "name": "final value", "title": "Final Value", "visibleIf": "{name} notempty and {Would you like maths} = true", "defaultValueExpression": "{name} + ' ' + ( {Would you like maths} ? 'likes match' : '') + ' like match'" } ] } ] }
        Comments (1)

          You're always welcome! Please feel free to contact us if you require further assistance.