Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:

THEMA: Help! Javascript syntax for definitions

Help! Javascript syntax for definitions 1 Jahr 5 Monate her #93391

  • rodriguezm1
  • rodriguezm1s Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 10
  • Karma: 0
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.
Letzte Änderung: 1 Jahr 5 Monate her von rodriguezm1.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Help! Javascript syntax for definitions 1 Jahr 4 Monate her #94551

  • kubaj
  • kubajs Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 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
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Help! Javascript syntax for definitions 1 Jahr 4 Monate her #94592

  • DenisChenu
  • DenisChenus Avatar
  • ONLINE
  • Moderator Lime
  • Beiträge: 6272
  • Dank erhalten: 800
  • Karma: 240
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
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Moderatoren: ITEd
Ladezeit der Seite: 0.259 Sekunden
Donation Image