Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:

THEMA: Defaulting Multiple Short Text Answers based on Checkbox

Defaulting Multiple Short Text Answers based on Checkbox 11 Monate 2 Wochen her #98856

  • petert
  • peterts Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 11
  • Karma: 0
I have a survey which asks where you lived during different times of your life, age 18-25, 25-35 etc.

Some people never move. For those people, we would like to have a checkbox on the first screen which is labeled something like "I have lived here my whole life". If this checkbox is checked on the first screen, then additional screens would prefill or default to the City, State, Zip and Country values provided on the first screen.

I have seen numerous forum posts that dance all around this situation, but no direct answers. Any thoughts would be appreciated.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Defaulting Multiple Short Text Answers based on Checkbox 11 Monate 2 Wochen her #98877

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4049
  • Dank erhalten: 739
  • Karma: 341
Given the following question/answer codes:

1) "I have lived here my whole life"
- question code - "multiOpt1"
- answer code - "1"

2) "Address when 18-25"
- question code - "address1"
- answer codes - "city", "state", "zip"

3) "Address when 26-35"
- question code - "address2"
- answer codes - "city", "state", "zip"

You could set the default answers for "address2" to:
{if(multiOpt1_1, address1_city, "")}
{if(multiOpt1_1, address1_state, "")}
{if(multiOpt1_1, address1_zip, "")}
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Letzte Änderung: 11 Monate 2 Wochen her von tpartner.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Defaulting Multiple Short Text Answers based on Checkbox 10 Monate 4 Wochen her #99280

  • petert
  • peterts Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 11
  • Karma: 0
Thanks, that seemed to make sense. However, when I went to do it, the page blew code all over the place. I am using the latest version of 2.00 (130802). See attached screen shot.

Checking the database, the value is properly stored. See attachment.

Reviewing the source code from the page, it appears that Lime is dumping style infomation into the text field's value declaration. Like this:

<input class="text " type="text" size="20" name="39382X132X2265City" id="answer39382X132X2265City" value="<span style='background-color: #eee8aa;'><span title='Conditional processing; if(test,result_if_true,result_if_false)' style='color: blue; font-weight: bold'>if</span>(<span title='Undefined variable' style='border-style: solid; border-width: 2px; border-color: red;'><span title='Undefined variable' style='color: red; font-weight: bold'>RsA1auto_1</span></span>, <span title='[java39382X132X2265City][G:4][Q:23]: City/Town; value={ if(RsA1auto_1, RsB1_City, "") }' style='color: #996600; font-weight: bold' onclick='window.open("/s/index.php/admin/survey/sa/view/surveyid/39382/gid/132/qid/2265");'>RsB1_City</span>, <span title='' style='color: gray'>""</span>)</span>" onkeyup="checkconditions(this.value, this.name, this.type);" />

Thoughts?
Anhang:
Letzte Änderung: 10 Monate 4 Wochen her von petert. Begründung: Added db attachment
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Defaulting Multiple Short Text Answers based on Checkbox 10 Monate 3 Wochen her #99408

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4049
  • Dank erhalten: 739
  • Karma: 341
That generated code indicates that Expression Manager has a problem - probably with one or more of the variables.
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Defaulting Multiple Short Text Answers based on Checkbox 10 Monate 2 Wochen her #99550

  • petert
  • peterts Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 11
  • Karma: 0
Ok, I have studied my variables until my eyes are popping. I created a new, three question survey from scratch using precisely the codes and default invocation calls provided above. Same result, gibberish output. I must be missing something obvious.

No luck getting the xml file to attach, so it can be downloaded here:

www.advanced-design.com/limesurvey_survey_617976.lss.xml
Letzte Änderung: 10 Monate 2 Wochen her von petert. Begründung: no attachment.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Defaulting Multiple Short Text Answers based on Checkbox 10 Monate 2 Wochen her #99555

  • petert
  • peterts Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 11
  • Karma: 0
Ok, finally figured it out by reviewing the javascript source code for Expression Manager.

This code is incorrect and results in the EM throwing a unknown variable error:
{if(multiOpt1_1, address1_city, "")}
{if(multiOpt1_1, address1_state, "")}
{if(multiOpt1_1, address1_zip, "")}


This is the correct code:
{if(multiOpt1==1, address1_city, "")}
{if(multiOpt1==1, address1_state, "")}
{if(multiOpt1==1, address1_zip, "")}
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Moderatoren: ITEd
Ladezeit der Seite: 0.318 Sekunden
Donation Image