Welcome, Guest
Username: Password: Remember me

TOPIC: Help! Javascript syntax for definitions

Help! Javascript syntax for definitions 1 year 1 month ago #93391

I have a multi-text question, Q1. It has a subquestion, sq1. Q1 is hidden.

I want to use java to insert an answer to Q1_sq1.

What is the syntax?

I've tried
 
document.getElementById('{Q1_sq1}').value = 'new text';
$('#answer{Q1_sq1}').val() = 'new text';
$('#answer{Q1_sq1}').text() = 'new text';
$('#answer{Q1_sq1}').val('new text');
 

None of this works. I would really appreciate your help in telling me how to do something that should be so fundamentally simple, which is define a variable. I don't understand why this doesn't work in LimeSurvey easily.
Last Edit: 1 year 1 month ago by rodriguezm1.
The administrator has disabled public write access.

Help! Javascript syntax for definitions 1 year 1 week ago #94551

  • kubaj
  • kubaj's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 7
  • Karma: 0
Hi,

you can try document.getElementById('answer'+id_of_question_variable).value = 'whatever';

id_of_question_variable is for example 13453X34X34_abc for field in array question
The administrator has disabled public write access.

Help! Javascript syntax for definitions 1 year 1 week ago #94592

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 5830
  • Thank you received: 710
  • Karma: 219
Hello,

Try this:
$('#answer{Q1_sq1.SGQA}').val('new text');

And if you are on the question text:
$('#answer{SGQ}sq1').val('new text');
(if the code is sq1).


Denis
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.205 seconds
Donation Image