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: Default Answers with question type : array (texts?)

Default Answers with question type : array (texts?) hace 2 meses 5 días #93850

  • apalms
  • Avatar de apalms
  • DESCONECTADO
  • Fresh Lemon
  • Mensajes: 1
  • Karma: 0
Hi all!

I am working with version 2.0, and am trying to figure out if it is possible to add default answers in the question type array texts.

The below is how my array will be constructed.
H01 H02 H03 H04
B01 DEFAULT XXX XXX XXX
B02 DEFAULT XXX XXX XXX
B03 DEFAULT XXX XXX XXX

Thank you!!
El administrador ha desactivado la escritura pública.

Default Answers with question type : array (texts?) hace 2 meses 4 días #93870

  • tpartner
  • Avatar de tpartner
  • CONECTADO
  • LimeSurvey Team
  • Mensajes: 2857
  • Gracias recibidas 424
  • Karma: 244
There is no built-in setting for defaults in text arrays but you can do it with a little JavaScript.

Set up your survey to use JavaScript and add something like this to the question source.

<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
 
		var defaultText = 'My default';
		$('#question{QID} tr[id^="javatbd"]').each(function(i) {
			if($('input[type="text"]:eq(0)', this).val() == '') {
				$('input[type="text"]:eq(0)', this).val(defaultText)
			}
		});
	});
</script>
Cheers,
Tony

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Última Edición: hace 2 meses 4 días por tpartner.
El administrador ha desactivado la escritura pública.

Default Answers with question type : array (texts?) hace 2 meses 3 días #93883

  • sys_sby
  • Avatar de sys_sby
  • DESCONECTADO
  • Junior Lime
  • Mensajes: 22
  • Karma: 0
Hello tpartner,

I need hep and information,
where is the file located for reference function/class:
1. ('#question{QID} tr[id^="javatbd"]')
2. ('input[type="text"]:eq(0)

Hoping i can to use javaScript for others type question

Thank you

Regards
sys_sby
Última Edición: hace 2 meses 3 días por sys_sby.
El administrador ha desactivado la escritura pública.

Default Answers with question type : array (texts?) hace 2 meses 3 días #93904

  • tpartner
  • Avatar de tpartner
  • CONECTADO
  • LimeSurvey Team
  • Mensajes: 2857
  • Gracias recibidas 424
  • Karma: 244
I'm not sure I understand the question.

1. ('#question{QID} tr[id^="javatbd"]') - This refers to the array rows

2. ('input[type="text"]:eq(0) - This refers to the first text input in the rows

The easiest way to discover element classes and other attributes is with developer tools like Firebug for Firefox:

Capture_2013-03-18.JPG
Cheers,
Tony

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
El administrador ha desactivado la escritura pública.

Default Answers with question type : array (texts?) hace 2 meses 3 días #93911

  • sys_sby
  • Avatar de sys_sby
  • DESCONECTADO
  • Junior Lime
  • Mensajes: 22
  • Karma: 0
Hello Tony,

I mean that's it
Thank you very much

Regards
sys_sby
El administrador ha desactivado la escritura pública.
  • Página:
  • 1
Moderadores: DenisChenu, ITEd
Tiempo de carga de la página: 0.274 segundos
Donation Image