Collision between dynamically generated input element IDs?

2 years 11 months ago #107078 by mmatos
Hi guys. It's kind of a weird issue so I'll try to summarize as best as I can. A developer on my team ran in to a very strange issue where he was having trouble updating the value of a text element. After looking at it for a few, we discovered that there's a scenario where the dynamically generated element IDs can collide.


Scenario 0: When LS creates an input element, it does so in the following format.
Element ID = #answer[surveyID]X[GroupID]X[QuestionNumber]

Scenario 1: Furthermore, when this input element is of type radio button list, the answer elements are created as:
Element ID = #answer[surveyID]X[GroupID]X[QuestionNumber][AnswerNumber]

Scenario 2: When this input element is in a group, the answer elements are created as:
Element ID = #answer[surveyID]X[GroupID]X[QuestionNumber][QuestionInGroup]

So, assuming we have a radio button list question, the IDs would be something like:

#answer999999X1X51 for the first answer radio button id
#answer999999X1X52 for the second answer radio button id
and so on.

Now...on the same page we have a group of questions that has repeated 5 times. You might see where I'm going with this. We have a page with Scenario 1 and Scenario 2 happening together.

When each of the answer elements are generated in this 5th group, the IDs for the input elements are generated as such:

and so on.

So basically now the element ID has collided due to this situation. I was able to get my developer around this by specifying a more specific element id (including a class and input type in his selector) but what I don't know yet is whether this affects the collection of responses. I'm new to LS so I just haven't gotten there yet, but I wanted to post about this in case it was a bug that needed to be addressed or someone had some advice/thoughts on how to best avoid this situation.

Your thoughts appreciated!

Please Log in to join the conversation.

2 years 11 months ago #107086 by DenisChenu

I allways use alphabetic character for answer code and sub question code , then: no collision.

But i think we have a system to fix numbering when activate a survey, did you test to activate and deactivate and see if the question id was updated ?

PS: you can put a bug report, but i think it's a 'wont fix'

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).

Please Log in to join the conversation.