Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Populate address in text box based upon drop-down list address selected.

  • samk9in
  • samk9in's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 1 month ago #194308 by samk9in
Hi all,

Fairly new to Limesurvey. I am setting up a form having following form fields:

Location: Location 1 till Location 200 (Dropdown list of 200 locations)

Location General Info: Multiple short text question type
Manager Name:
Location Phone:
Location Address:

When I select "Location 1" in Location dropdown, I would like its respective address and phone number filled in the respective Location Phone and Location Address text box.
To accomplish this, even if I need to split this in to separate text box question instead of Multiple short text question type, then that's fine too.

I am attaching a screenshot as well for your reference.

Attachment not found



Could someone please advise if this is doable.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 1 month ago #194321 by Joffm
Hi,
a easy solution without javascript is:
1. create a question of type "huge text" (I called it "Loc") , where you enter your details well defined (fixed width), like
Code:
001Location1           Mr. Adam Ant        (123) 432-1234      A-Road 123, Adamtown                    
002Location2           Mrs. Betty Beaver   (124) 532-2234      B-Road 222, Bettystown                  
003Location3           Mr. Carl Coala      (125) 632-3234      C-Road 333, Charlestown                 

Your dropdown (Q1) has the answer codes "001, "002", ... (you may adapt it to your wishes)
Then use a few string functions to
1. find the line that starts with your selected code {strpos(Loc,Q1)}
2. extract the line {substr(Loc,eq1,104)} (my lines have a length of 104 characters)
3. split this line into the several parts and fill the multiple short text question (Q2)
{Q2_SQ001=substr(eq2,23,20)}
{Q2_SQ002=substr(eq2,43,20)}
{Q2_SQ003=substr(eq2,63,30)}

Joffm

File Attachment:

File Name: limesurvey...5583.lss
File Size:23 KB

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose