The LimeSurvey Fund-Raiser 2012 is complete. Thank you for donating a total of 25,000 USD!     List of donors »

Bienvenido, Invitado
Nombre de Usuario: Contraseña: Recordarme
  • Página:
  • 1

TEMA: How can I access to a checkboxx response value (javascript)

How can I access to a checkboxx response value (javascript) hace 3 meses 1 semana #92780

  • vbraque
  • Avatar de vbraque
  • DESCONECTADO
  • Junior Lime
  • Mensajes: 27
  • Karma: 0
Hi world!
I need to show a popup message when these conditions raise:
1) I show several questions on one page. Each question is checkbox type.
2) The popup message must be shown where NO checkbox has been checked.

I've been trying to emulate what conditions rules do, because the can access to the "checked" value for each checkbox. I must show the popup from a javascript code.

Something similar to this:

if (checkbox1.checked and checkbox2.checked and checkbox3.checked ...) then show popup

That's it: I need a javascript expression that let my access to the checked/non-checked value of a particular checkbox defined in my survey.

Tks in advance.
El administrador ha desactivado la escritura pública.

How can I access to a checkboxx response value (javascript) hace 3 meses 1 semana #92781

  • Ben_V
  • Avatar de Ben_V
  • DESCONECTADO
  • Platinum Lime
  • Mensajes: 735
  • Gracias recibidas 136
  • Karma: 44
Adapt SGQA code and try something like:
$(document).ready(function() {
   if (
   document.getElementById('java123X456X789cr1').value == 'Y' ) &&
   document.getElementById('java123X456X789cr2').value == 'Y' ) 
  /*
   or  for not checked:
   document.getElementById('java123X456X789cr1').value != 'Y' ) 
  */
...
Benoît

goo.gl/Bw5iM => Recherche GG dans le forum français (remplacer "exemple" dans la barre de recherche)
goo.gl/WX8PH => GG search for english forum (Replace "example" in the search bar)
goo.gl/IxiGu => Búsqueda en el foro en español (Cambiar "ejemplo" en la barra de...
Última Edición: hace 3 meses 1 semana por Ben_V.
El administrador ha desactivado la escritura pública.

How can I access to a checkboxx response value (javascript) hace 3 meses 6 días #92796

  • vbraque
  • Avatar de vbraque
  • DESCONECTADO
  • Junior Lime
  • Mensajes: 27
  • Karma: 0
Thanks Ben, but... must I assume the following syntax?

java - is fixed text?
123 - survey id
456 - section id
789 - question id
cr1 - subquestion id (checkbox)

Where must I run this script?
- At the beginning of the next section, so if I detect no checkboxes are checked I can force the user to return to checkboxes page
El administrador ha desactivado la escritura pública.

How can I access to a checkboxx response value (javascript) hace 3 meses 5 días #92833

  • vbraque
  • Avatar de vbraque
  • DESCONECTADO
  • Junior Lime
  • Mensajes: 27
  • Karma: 0
Hi Ben_V
I've just open a thread in spanish forum, perhaps you'd like to speak spanish about that bug.
Tks.
El administrador ha desactivado la escritura pública.

How can I access to a checkboxx response value (javascript) hace 3 meses 5 días #92836

  • Ben_V
  • Avatar de Ben_V
  • DESCONECTADO
  • Platinum Lime
  • Mensajes: 735
  • Gracias recibidas 136
  • Karma: 44
Hi,
java - is fixed text?
123 - survey id
....
You're right (better to look at source code to get exact id's)

I gave you a base of javascript snippet as asked in your title...because i supposed it was to display an alert or confirm message via the browser prompt box. In this case the JS code have to be on the same page. (if pop-up=external page, place your code at the next page but you have to set and test everything...)

Another approach is to use 'expression manager' and its powerful set of functions for validation.

Ben
Benoît

goo.gl/Bw5iM => Recherche GG dans le forum français (remplacer "exemple" dans la barre de recherche)
goo.gl/WX8PH => GG search for english forum (Replace "example" in the search bar)
goo.gl/IxiGu => Búsqueda en el foro en español (Cambiar "ejemplo" en la barra de...
El administrador ha desactivado la escritura pública.

How can I access to a checkboxx response value (javascript) hace 3 meses 4 días #92876

  • vbraque
  • Avatar de vbraque
  • DESCONECTADO
  • Junior Lime
  • Mensajes: 27
  • Karma: 0
Hi.
I'm getting crazy trying to show the Y value for a chebox field.
Let's see.
The code generated for a checkbox field includes the following tags (only checkbox field code):
.../...
<li id="javatbd45155X2007X27079F502">
<input class="checkbox" type="checkbox" name="45155X2007X27079F502" id="answer45155X2007X27079F502" value="Y" onclick=.../...">
<label .../...></label>
<input type="hidden" name="java45155X2007X27079F502" id="java45155X2007X27079F502" value="">
</li>
.../...
That's it: two input tags, the first checkbox type with id answer* and the second hidden type with id java*. When a user marks the checkbox, the Y value is stored in the hidden tag (java*).
But I'm not able to show this value from an alert javascript command.
Why? Perhaps because javascript code is incluede in the following section so I can't access the java* variable by its id (I'm in a doubt about this). So I decide to move backward, to see the referenced page and see the variable's value.
That's it, this is part of the javascript code:

.../...
document.limesurvey.move.value = 'moveprev';
document.limesurvey.submit();
alert(document.getElementById('java45155X2007X27079F502').value);

I spect to see a Y value on alert popup when the referenced checkbox is checked but script crashes. In fact, nothing is shown and script stops its execution.

any suggestion?

(I've been reading Expression Manager docs but I'd like to resolve this bug by javascript code)
Última Edición: hace 3 meses 4 días por vbraque.
El administrador ha desactivado la escritura pública.

How can I access to a checkboxx response value (javascript) hace 3 meses 3 días #92938

  • Ben_V
  • Avatar de Ben_V
  • DESCONECTADO
  • Platinum Lime
  • Mensajes: 735
  • Gracias recibidas 136
  • Karma: 44
I think you have to look at the expression manager available documentation & sample surveys and try to handle the related advanced settings of your question...
capt2_2013-02-22.gif

For that, the best is to follow the links indicated in the footer of all TMSWHite posts (for example here )
Benoît

goo.gl/Bw5iM => Recherche GG dans le forum français (remplacer "exemple" dans la barre de recherche)
goo.gl/WX8PH => GG search for english forum (Replace "example" in the search bar)
goo.gl/IxiGu => Búsqueda en el foro en español (Cambiar "ejemplo" en la barra de...
El administrador ha desactivado la escritura pública.

How can I access to a checkboxx response value (javascript) hace 3 meses 3 días #92939

  • vbraque
  • Avatar de vbraque
  • DESCONECTADO
  • Junior Lime
  • Mensajes: 27
  • Karma: 0
I'm afraid so.
Thanks for your time and patience.
See you.
El administrador ha desactivado la escritura pública.
  • Página:
  • 1
Moderadores: DenisChenu, ITEd
Tiempo de carga de la página: 0.298 segundos
Donation Image