Welcome to the LimeSurvey Community Forum

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

How to get current value of answer?

  • sodiumchl
  • sodiumchl's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
3 years 5 months ago - 3 years 5 months ago #207747 by sodiumchl
How to get current value of answer? was created by sodiumchl
I see some plugins use something like this:
Code:
$dom = new \toolsDomDocument\SmartDOMDocument();
$dom->loadPartialHTML($this->event->get('answers'));
$input=$dom->getElementById("answer{$sgq}");
$currentValue=$input->textContent;

Yet some other uses
Code:
$currentValue = $_SESSION['survey_'.$oEvent->get('surveyId')][$sgq]; // This can not broke : it's set in EM::_validateQuestion

Indeed, in some cases, I get an empty string with the first method but not the second. Why? What's the difference?
Last edit: 3 years 5 months ago by sodiumchl.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 5 months ago #207765 by DenisChenu
Replied by DenisChenu on topic How to get current value of answer?
When it's happen …

For the 1st must be used in beforeQuestionRender and get it by HTML already produced. Then need to be sure of {$sgq} .
the second can be used at more place.

If 1st is OK for the id (#answer{SGQ}) : it muts giove the same value.
BUT : there are no $input->textContent; for radio checkbox for example … ONLY for text input

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose