<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.limesurvey.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Holch</id>
	<title>LimeSurvey Manual - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://www.limesurvey.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Holch"/>
	<link rel="alternate" type="text/html" href="https://www.limesurvey.org/manual/Special:Contributions/Holch"/>
	<updated>2026-08-10T13:57:29Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.9</generator>
	<entry>
		<id>https://www.limesurvey.org/manual/index.php?title=Installation_-_LimeSurvey_CE&amp;diff=176537</id>
		<title>Installation - LimeSurvey CE</title>
		<link rel="alternate" type="text/html" href="https://www.limesurvey.org/manual/index.php?title=Installation_-_LimeSurvey_CE&amp;diff=176537"/>
		<updated>2023-05-16T12:57:55Z</updated>

		<summary type="html">&lt;p&gt;Holch: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages /&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:52--&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt; Note: These installation instructions are for version 2.0 or later. Older instructions for 1.92 can be found [[Installation Version 1.92 or older|here]] and update instructions can be found [[Upgrading from a previous version|here]]. &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==General== &amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
The LimeSurvey project provides two ways to install LimeSurvey:&lt;br /&gt;
*On your webserver:&amp;lt;br /&amp;gt;In this case, just follow the instructions on this page starting with step 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
*On your local Windows PC:&amp;lt;br /&amp;gt;You usually only want to install LimeSurvey on your local PC if you want to create surveys locally (mainly for speed or development/test reasons) and upload them later to your live LimeSurvey installation on a web server. For this purpose, we have prepared a special LimeSurvey package which includes the web server, the database, the LimeSurvey application, and [[Installation of the LimeSurvey XAMPP package|instructions how to install it]].&lt;br /&gt;
&lt;br /&gt;
==Make sure you can use LimeSurvey on your website== &amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
Make sure your server meets the following additional requirements.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:51--&amp;gt;&lt;br /&gt;
{{Note|The minimum set of requirements will also be checked during the installation process!}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
The minimum set of requirements for &#039;&#039;&#039;LimeSurvey 6.x&#039;&#039;&#039;:&lt;br /&gt;
* Minimum 250 MB disk space.&lt;br /&gt;
* MySQL 5.5.3 or later &#039;&#039;&#039;OR&#039;&#039;&#039; Microsoft SQL Server 2005 or later &#039;&#039;&#039;OR&#039;&#039;&#039; Postgres 9 or later.&lt;br /&gt;
* PHP version requirements: &lt;br /&gt;
** LS 6.x from PHP 7.4.x to 8.1.x &lt;br /&gt;
** LS 5.x from PHP 7.2.5 to 8.0.x &lt;br /&gt;
** LS 3.x from PHP 5.5.9 to 7.4.x&lt;br /&gt;
* php.ini `short_open_tag` setting should be set to `ON`&lt;br /&gt;
* The following PHP modules/libraries should be enabled:&lt;br /&gt;
** [[Installation FAQ#Requirements page#What is the mbstring (Multibyte String Functions) library|mbstring (Multibyte String Functions)]] extension library.&lt;br /&gt;
** PDO database driver for MySQL (pdo_mysql or pdo_mysqli) or Postgres (pdo_pgsql) or MSSQL ([https://php.net/manual/en/ref.pdo-sqlsrv.php pdo_sqlsrv] for Windows and [http://www.php.net/manual/en/ref.pdo-dblib.php pdo_dblib] for Linux).&lt;br /&gt;
** Also, we assume in general that all PHP default libraries are enabled &lt;br /&gt;
*** hash&lt;br /&gt;
*** session&lt;br /&gt;
*** openssl or mcrypt&lt;br /&gt;
*** fileinfo&lt;br /&gt;
*** SimpleXML&lt;br /&gt;
*** etc …&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:47--&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt; Note: If you are connecting from Linux to a MSSQL database on a Windows server using the dblib PDO driver, then the underlying FreeTDS needs to be set up correctly. Check out the [[Troubleshooting]] page for more information.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
Optional PHP Extensions:&lt;br /&gt;
* &#039;&#039;&#039;GD-Library&#039;&#039;&#039; &#039;&#039;&#039;with FreeType support&#039;&#039;&#039; installed is needed for captchas, nice charts in statistics or to upload images via the HTML editor - see [https://php.net/manual/image.setup.php PHP GD-Library Extension documentation]&lt;br /&gt;
* &#039;&#039;&#039;IMAP&#039;&#039;&#039; (pretty standard) is needed for the [[Email bounce tracking system|email bounce tracking system]] - see [https://php.net/manual/imap.setup.php PHP IMAP Extension documentation]&lt;br /&gt;
* &#039;&#039;&#039;LDAP&#039;&#039;&#039; installed is needed to import survey participants using LDAP - see [https://php.net/manual/en/book.ldap.php PHP LDAP Documentation]&lt;br /&gt;
* &#039;&#039;&#039;Zip&#039;&#039;&#039; (pretty standard) is needed for template upload, import of .zip archived resources, and excel export - see [https://php.net/manual/zip.setup.php PHP Zip Extension documentation]&lt;br /&gt;
* &#039;&#039;&#039;Zlib&#039;&#039;&#039; (pretty standard) is needed for the [[ComfortUpdate]] - see [https://php.net/manual/zlib.setup.php PHP Zlib Extension documentation]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:12--&amp;gt;&lt;br /&gt;
In most cases, your web server provider or system administrator will be able to help you out with these optional components.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:14--&amp;gt;&lt;br /&gt;
If you want to run Microsoft&#039;s IIS server, taking a look at [[Installation on XP with IIS]] might also help.&lt;br /&gt;
&lt;br /&gt;
===Browser compatibility=== &amp;lt;!--T:46--&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For the survey-taking side&#039;&#039;&#039;, we currently support IE11 (intranet-mode excluded) and all newer comparable browsers like Edge, FF, Chrome, Opera etc. with activated JavaScript. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:53--&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For the administration part&#039;&#039;&#039;, we currently support Edge and all newer comparable browsers like FF, Chrome, Opera etc. with activated JavaScript. &amp;lt;u&amp;gt;We do not support any Internet Explorer versions in the administration part anymore.&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Screen sizes==== &amp;lt;!--T:48--&amp;gt;&lt;br /&gt;
We support any reasonable screen size for survey taking (360px x 640px and up).&lt;br /&gt;
The minimum supported screen resolution for the LimeSurvey administration page is 1280px x 1024px.&lt;br /&gt;
&lt;br /&gt;
===Hosting for LimeSurvey=== &amp;lt;!--T:15--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:16--&amp;gt;&lt;br /&gt;
LimeSurvey should work with most hosting companies that provide PHP and MySQL. If you want a ready-installed version of LimeSurvey, you could try [https://www.limesurvey.org/editions-and-prices/limesurvey-pro/editions-and-prices-professional LimeSurvey Cloud], else check out our [[LimeSurvey-compatible hosting companies|list of LimeSurvey-compatible hosting companies]].&lt;br /&gt;
&lt;br /&gt;
==Download the LimeSurvey package== &amp;lt;!--T:17--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:18--&amp;gt;&lt;br /&gt;
[https://community.limesurvey.org/downloads/ Download] the latest stable LimeSurvey zip package (there are also gzip, bz2 and 7zip packages available for your convenience) and save it to your local disk.&lt;br /&gt;
&lt;br /&gt;
==Unpack the LimeSurvey package== &amp;lt;!--T:19--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:20--&amp;gt;&lt;br /&gt;
Uncompress the zip file into a dedicated directory/folder using your preferred compression software. When you uncompress the file make sure that you uncompress the directory structure with the files (this is default behavior for most compression programs). The path name for the installation directory should not include &#039;(&#039; or &#039;)&#039; special characters, but it may include the &#039;&#039;&#039;space&#039;&#039;&#039; character.&lt;br /&gt;
&lt;br /&gt;
==Collect information about your server== &amp;lt;!--T:21--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:22--&amp;gt;&lt;br /&gt;
You will need to know the following things to install LimeSurvey on your web server correctly:&lt;br /&gt;
*Your intended website URL where your scripts will reside (e.g. &#039;&#039;http://my.domain.com/limesurvey&#039;&#039;).&lt;br /&gt;
*The physical disk location on your server where your scripts will reside (e.g. &#039;&#039;/home/usr/htdocs/limesurvey&#039;&#039;).&lt;br /&gt;
*The IP/net location of your database server (i.e. &#039;&#039;localhost&#039;&#039;).&lt;br /&gt;
*If your database server uses a non-standard port, find out which port it is.&lt;br /&gt;
*Your user name and password for your database server.&lt;br /&gt;
*With most providers you can&#039;t let the script create the database, but have to do it yourself.  If you are using such a provider, please create a database (for example &#039;&#039;limesurvey&#039;&#039;) yourself.&lt;br /&gt;
&lt;br /&gt;
==Upload the files to your web server== &amp;lt;!--T:23--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:24--&amp;gt;&lt;br /&gt;
Using your FTP program (e.g. FileZilla), connect to your web server and create a directory to store your scripts. Then upload the files using the directory structure they are in. Make sure you &#039;&#039;&#039;upload the files in binary mode&#039;&#039;&#039; (check the settings of your FTP program). Please note that uploading in ASCII mode can lead to uncommon errors (e.g. &#039;class not found&#039; error during installation), also images may not be uploaded correctly.&lt;br /&gt;
&lt;br /&gt;
==Set directory permissions== &amp;lt;!--T:25--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:26--&amp;gt;&lt;br /&gt;
For the script to work properly it needs certain access to some directories - this applies especially to Linux/*nix systems.&lt;br /&gt;
*The &#039;&#039;&#039;&amp;quot;/limesurvey/tmp&amp;quot;&#039;&#039;&#039; directory (and all its subdirectories and files) are used for imports &amp;amp; uploads and should be set to &#039;&#039;Read &amp;amp; Write&#039;&#039; for your webserver.&lt;br /&gt;
*The &#039;&#039;&#039;&amp;quot;/limesurvey/upload/&amp;quot;&#039;&#039;&#039; directory (and all its subdirectories and files) must also have &#039;&#039;Read &amp;amp; Write&#039;&#039; for your webserver in order to enable picture and media files upload.&lt;br /&gt;
*The &#039;&#039;&#039;&amp;quot;/limesurvey/application/config/&amp;quot;&#039;&#039;&#039; directory also needs &#039;&#039;Read &amp;amp; Write&#039;&#039; permissions for your webserver.&lt;br /&gt;
*The other directories can be set to &#039;&#039;Read Only&#039;&#039;. You may wish in Linux/Unix to set the permissions on each file within the /limesurvey/admin directory to &#039;&#039;Read Only&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:27--&amp;gt;&lt;br /&gt;
{{Alert|If you are using Linux, then setting permissions depends on your webserver configuration. For example, if you use Apache HTTPD on CentOS, type &#039;&#039;&#039;chmod -R 755 &amp;lt;directory&amp;gt; ; chown -R apache &amp;lt;directory&amp;gt;&#039;&#039;&#039;. This will give everyone access to read, and your webserver will have the permission to write. Check the [https://www.linux.com/learn/tutorials/309527-understanding-linux-file-permissions following link] for more information on Linux permissions.}}&lt;br /&gt;
&lt;br /&gt;
==Create a database user== &amp;lt;!--T:28--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:29--&amp;gt;&lt;br /&gt;
LimeSurvey will create a database and the tables inside it. To be able to do this, it will need the user name and password of a database user. We generally recommend creating a database user with the following permissions:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:30--&amp;gt;&lt;br /&gt;
- MySQL: SELECT, CREATE, INSERT, UPDATE, DELETE, ALTER, DROP, INDEX&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:31--&amp;gt;&lt;br /&gt;
- PostgreSQL: SELECT, INSERT, UPDATE, DELETE, TRUNCATE, TRIGGER&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:32--&amp;gt;&lt;br /&gt;
- Microsoft SQL Server: &#039;&#039;Unknown - if you can find out this information, please complete it&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==Run the installation script== &amp;lt;!--T:33--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:34--&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Go to &amp;quot;example.org/limesurvey/admin&amp;quot;&#039;&#039;&#039;. If you configured everything correctly, the LimeSurvey installer should be starting - just follow the instructions. You will be asked whether you wish to create the database and/or create the tables inside the database. LimeSurvey will then create the needed tables in the database.&lt;br /&gt;
&lt;br /&gt;
==Connect to the administration script for the first time== &amp;lt;!--T:35--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:36--&amp;gt;&lt;br /&gt;
You are done when the installation finishes! Open your browser and enter the URL to the LimeSurvey administration. Assuming you used &#039;limesurvey&#039; as the directory name to store the files in, this will be something like &amp;quot;http://www.example.com/limesurvey/admin&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:37--&amp;gt;&lt;br /&gt;
You should get a login screen. The default login credentials (if they have not been changed during the installation) are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:38--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&#039;html&#039;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:49--&amp;gt;&lt;br /&gt;
User: admin&lt;br /&gt;
Password: password&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:50--&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:41--&amp;gt;&lt;br /&gt;
You will be prompted to change the default password after you logged in. Have fun!&lt;br /&gt;
&lt;br /&gt;
==Further configuration== &amp;lt;!--T:54--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Caching=== &amp;lt;!--T:55--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:56--&amp;gt;&lt;br /&gt;
LimeSurvey uses the Yii file cache by default, but it can be configured to use other cache engines. Possible other caches are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:57--&amp;gt;&lt;br /&gt;
* Memcached&lt;br /&gt;
* Redis&lt;br /&gt;
* WinCache&lt;br /&gt;
* XCache&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:58--&amp;gt;&lt;br /&gt;
Please see the [https://www.yiiframework.com/doc/api/1.1/CCache Yii documentation] for full description.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:59--&amp;gt;&lt;br /&gt;
Since LimeSurvey 4.0.0 you also have the possibility to cache calculations in the ExpressionScript. This can provide a significant speed-up depending on survey complexity. To enable the emcache, add this in your config.php file (components array):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:60--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&#039;emcache&#039; =&amp;gt; array(&#039;class&#039; =&amp;gt; &#039;CFileCache&#039;),&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:61--&amp;gt;&lt;br /&gt;
As with the main Yii cache, other cache systems can be used.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:62--&amp;gt;&lt;br /&gt;
{{Note| The emcache is not compatible with randomized surveys, and will be automatically turned off in such cases.}}&lt;br /&gt;
&lt;br /&gt;
==What if I have problems...== &amp;lt;!--T:42--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:43--&amp;gt;&lt;br /&gt;
Like all computer programs, most of the time things will work just like the instructions say, but sometimes they just won&#039;t. There are too many possible reasons for things not going according to plan to describe here. If you have trouble, first check out the [[Installation FAQ]]. If you don&#039;t find your answer there, please post your problem and any error messages in the [https://www.limesurvey.org/forum LimeSurvey forums], open a [https://www.limesurvey.org/contact-us support ticket] (only for customers using LimeSurvey Cloud), or join our [https://discord.gg/DEjguXn Discord channel].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;/div&gt;</summary>
		<author><name>Holch</name></author>
	</entry>
	<entry>
		<id>https://www.limesurvey.org/manual/index.php?title=Installation_-_LimeSurvey_CE&amp;diff=176536</id>
		<title>Installation - LimeSurvey CE</title>
		<link rel="alternate" type="text/html" href="https://www.limesurvey.org/manual/index.php?title=Installation_-_LimeSurvey_CE&amp;diff=176536"/>
		<updated>2023-05-16T12:57:20Z</updated>

		<summary type="html">&lt;p&gt;Holch: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages /&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:52--&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt; Note: These installation instructions are for version 2.0 or later. Older instructions for 1.92 can be found [[Installation Version 1.92 or older|here]] and update instructions can be found [[Upgrading from a previous version|here]]. &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==General== &amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
The LimeSurvey project provides two ways to install LimeSurvey:&lt;br /&gt;
*On your webserver:&amp;lt;br /&amp;gt;In this case, just follow the instructions on this page starting with step 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
*On your local Windows PC:&amp;lt;br /&amp;gt;You usually only want to install LimeSurvey on your local PC if you want to create surveys locally (mainly for speed or development/test reasons) and upload them later to your live LimeSurvey installation on a web server. For this purpose, we have prepared a special LimeSurvey package which includes the web server, the database, the LimeSurvey application, and [[Installation of the LimeSurvey XAMPP package|instructions how to install it]].&lt;br /&gt;
&lt;br /&gt;
==Make sure you can use LimeSurvey on your website== &amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
Make sure your server meets the following additional requirements.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:51--&amp;gt;&lt;br /&gt;
{{Note|The minimum set of requirements will also be checked during the installation process!}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
The minimum set of requirements for &#039;&#039;&#039;LimeSurvey 6.x&#039;&#039;&#039;:&lt;br /&gt;
* Minimum 250 MB disk space.&lt;br /&gt;
* MySQL 5.5.3 or later &#039;&#039;&#039;OR&#039;&#039;&#039; Microsoft SQL Server 2005 or later &#039;&#039;&#039;OR&#039;&#039;&#039; Postgres 9 or later.&lt;br /&gt;
* PHP version requirements: &lt;br /&gt;
** LS 6.x from 7.4.x to 8.1.x &lt;br /&gt;
** LS 5.x from 7.2.5 to 8.0.x &lt;br /&gt;
** LS 3.x from 5.5.9 to 7.4.x&lt;br /&gt;
* php.ini `short_open_tag` setting should be set to `ON`&lt;br /&gt;
* The following PHP modules/libraries should be enabled:&lt;br /&gt;
** [[Installation FAQ#Requirements page#What is the mbstring (Multibyte String Functions) library|mbstring (Multibyte String Functions)]] extension library.&lt;br /&gt;
** PDO database driver for MySQL (pdo_mysql or pdo_mysqli) or Postgres (pdo_pgsql) or MSSQL ([https://php.net/manual/en/ref.pdo-sqlsrv.php pdo_sqlsrv] for Windows and [http://www.php.net/manual/en/ref.pdo-dblib.php pdo_dblib] for Linux).&lt;br /&gt;
** Also, we assume in general that all PHP default libraries are enabled &lt;br /&gt;
*** hash&lt;br /&gt;
*** session&lt;br /&gt;
*** openssl or mcrypt&lt;br /&gt;
*** fileinfo&lt;br /&gt;
*** SimpleXML&lt;br /&gt;
*** etc …&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:47--&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt; Note: If you are connecting from Linux to a MSSQL database on a Windows server using the dblib PDO driver, then the underlying FreeTDS needs to be set up correctly. Check out the [[Troubleshooting]] page for more information.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
Optional PHP Extensions:&lt;br /&gt;
* &#039;&#039;&#039;GD-Library&#039;&#039;&#039; &#039;&#039;&#039;with FreeType support&#039;&#039;&#039; installed is needed for captchas, nice charts in statistics or to upload images via the HTML editor - see [https://php.net/manual/image.setup.php PHP GD-Library Extension documentation]&lt;br /&gt;
* &#039;&#039;&#039;IMAP&#039;&#039;&#039; (pretty standard) is needed for the [[Email bounce tracking system|email bounce tracking system]] - see [https://php.net/manual/imap.setup.php PHP IMAP Extension documentation]&lt;br /&gt;
* &#039;&#039;&#039;LDAP&#039;&#039;&#039; installed is needed to import survey participants using LDAP - see [https://php.net/manual/en/book.ldap.php PHP LDAP Documentation]&lt;br /&gt;
* &#039;&#039;&#039;Zip&#039;&#039;&#039; (pretty standard) is needed for template upload, import of .zip archived resources, and excel export - see [https://php.net/manual/zip.setup.php PHP Zip Extension documentation]&lt;br /&gt;
* &#039;&#039;&#039;Zlib&#039;&#039;&#039; (pretty standard) is needed for the [[ComfortUpdate]] - see [https://php.net/manual/zlib.setup.php PHP Zlib Extension documentation]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:12--&amp;gt;&lt;br /&gt;
In most cases, your web server provider or system administrator will be able to help you out with these optional components.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:14--&amp;gt;&lt;br /&gt;
If you want to run Microsoft&#039;s IIS server, taking a look at [[Installation on XP with IIS]] might also help.&lt;br /&gt;
&lt;br /&gt;
===Browser compatibility=== &amp;lt;!--T:46--&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For the survey-taking side&#039;&#039;&#039;, we currently support IE11 (intranet-mode excluded) and all newer comparable browsers like Edge, FF, Chrome, Opera etc. with activated JavaScript. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:53--&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For the administration part&#039;&#039;&#039;, we currently support Edge and all newer comparable browsers like FF, Chrome, Opera etc. with activated JavaScript. &amp;lt;u&amp;gt;We do not support any Internet Explorer versions in the administration part anymore.&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Screen sizes==== &amp;lt;!--T:48--&amp;gt;&lt;br /&gt;
We support any reasonable screen size for survey taking (360px x 640px and up).&lt;br /&gt;
The minimum supported screen resolution for the LimeSurvey administration page is 1280px x 1024px.&lt;br /&gt;
&lt;br /&gt;
===Hosting for LimeSurvey=== &amp;lt;!--T:15--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:16--&amp;gt;&lt;br /&gt;
LimeSurvey should work with most hosting companies that provide PHP and MySQL. If you want a ready-installed version of LimeSurvey, you could try [https://www.limesurvey.org/editions-and-prices/limesurvey-pro/editions-and-prices-professional LimeSurvey Cloud], else check out our [[LimeSurvey-compatible hosting companies|list of LimeSurvey-compatible hosting companies]].&lt;br /&gt;
&lt;br /&gt;
==Download the LimeSurvey package== &amp;lt;!--T:17--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:18--&amp;gt;&lt;br /&gt;
[https://community.limesurvey.org/downloads/ Download] the latest stable LimeSurvey zip package (there are also gzip, bz2 and 7zip packages available for your convenience) and save it to your local disk.&lt;br /&gt;
&lt;br /&gt;
==Unpack the LimeSurvey package== &amp;lt;!--T:19--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:20--&amp;gt;&lt;br /&gt;
Uncompress the zip file into a dedicated directory/folder using your preferred compression software. When you uncompress the file make sure that you uncompress the directory structure with the files (this is default behavior for most compression programs). The path name for the installation directory should not include &#039;(&#039; or &#039;)&#039; special characters, but it may include the &#039;&#039;&#039;space&#039;&#039;&#039; character.&lt;br /&gt;
&lt;br /&gt;
==Collect information about your server== &amp;lt;!--T:21--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:22--&amp;gt;&lt;br /&gt;
You will need to know the following things to install LimeSurvey on your web server correctly:&lt;br /&gt;
*Your intended website URL where your scripts will reside (e.g. &#039;&#039;http://my.domain.com/limesurvey&#039;&#039;).&lt;br /&gt;
*The physical disk location on your server where your scripts will reside (e.g. &#039;&#039;/home/usr/htdocs/limesurvey&#039;&#039;).&lt;br /&gt;
*The IP/net location of your database server (i.e. &#039;&#039;localhost&#039;&#039;).&lt;br /&gt;
*If your database server uses a non-standard port, find out which port it is.&lt;br /&gt;
*Your user name and password for your database server.&lt;br /&gt;
*With most providers you can&#039;t let the script create the database, but have to do it yourself.  If you are using such a provider, please create a database (for example &#039;&#039;limesurvey&#039;&#039;) yourself.&lt;br /&gt;
&lt;br /&gt;
==Upload the files to your web server== &amp;lt;!--T:23--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:24--&amp;gt;&lt;br /&gt;
Using your FTP program (e.g. FileZilla), connect to your web server and create a directory to store your scripts. Then upload the files using the directory structure they are in. Make sure you &#039;&#039;&#039;upload the files in binary mode&#039;&#039;&#039; (check the settings of your FTP program). Please note that uploading in ASCII mode can lead to uncommon errors (e.g. &#039;class not found&#039; error during installation), also images may not be uploaded correctly.&lt;br /&gt;
&lt;br /&gt;
==Set directory permissions== &amp;lt;!--T:25--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:26--&amp;gt;&lt;br /&gt;
For the script to work properly it needs certain access to some directories - this applies especially to Linux/*nix systems.&lt;br /&gt;
*The &#039;&#039;&#039;&amp;quot;/limesurvey/tmp&amp;quot;&#039;&#039;&#039; directory (and all its subdirectories and files) are used for imports &amp;amp; uploads and should be set to &#039;&#039;Read &amp;amp; Write&#039;&#039; for your webserver.&lt;br /&gt;
*The &#039;&#039;&#039;&amp;quot;/limesurvey/upload/&amp;quot;&#039;&#039;&#039; directory (and all its subdirectories and files) must also have &#039;&#039;Read &amp;amp; Write&#039;&#039; for your webserver in order to enable picture and media files upload.&lt;br /&gt;
*The &#039;&#039;&#039;&amp;quot;/limesurvey/application/config/&amp;quot;&#039;&#039;&#039; directory also needs &#039;&#039;Read &amp;amp; Write&#039;&#039; permissions for your webserver.&lt;br /&gt;
*The other directories can be set to &#039;&#039;Read Only&#039;&#039;. You may wish in Linux/Unix to set the permissions on each file within the /limesurvey/admin directory to &#039;&#039;Read Only&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:27--&amp;gt;&lt;br /&gt;
{{Alert|If you are using Linux, then setting permissions depends on your webserver configuration. For example, if you use Apache HTTPD on CentOS, type &#039;&#039;&#039;chmod -R 755 &amp;lt;directory&amp;gt; ; chown -R apache &amp;lt;directory&amp;gt;&#039;&#039;&#039;. This will give everyone access to read, and your webserver will have the permission to write. Check the [https://www.linux.com/learn/tutorials/309527-understanding-linux-file-permissions following link] for more information on Linux permissions.}}&lt;br /&gt;
&lt;br /&gt;
==Create a database user== &amp;lt;!--T:28--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:29--&amp;gt;&lt;br /&gt;
LimeSurvey will create a database and the tables inside it. To be able to do this, it will need the user name and password of a database user. We generally recommend creating a database user with the following permissions:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:30--&amp;gt;&lt;br /&gt;
- MySQL: SELECT, CREATE, INSERT, UPDATE, DELETE, ALTER, DROP, INDEX&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:31--&amp;gt;&lt;br /&gt;
- PostgreSQL: SELECT, INSERT, UPDATE, DELETE, TRUNCATE, TRIGGER&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:32--&amp;gt;&lt;br /&gt;
- Microsoft SQL Server: &#039;&#039;Unknown - if you can find out this information, please complete it&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==Run the installation script== &amp;lt;!--T:33--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:34--&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Go to &amp;quot;example.org/limesurvey/admin&amp;quot;&#039;&#039;&#039;. If you configured everything correctly, the LimeSurvey installer should be starting - just follow the instructions. You will be asked whether you wish to create the database and/or create the tables inside the database. LimeSurvey will then create the needed tables in the database.&lt;br /&gt;
&lt;br /&gt;
==Connect to the administration script for the first time== &amp;lt;!--T:35--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:36--&amp;gt;&lt;br /&gt;
You are done when the installation finishes! Open your browser and enter the URL to the LimeSurvey administration. Assuming you used &#039;limesurvey&#039; as the directory name to store the files in, this will be something like &amp;quot;http://www.example.com/limesurvey/admin&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:37--&amp;gt;&lt;br /&gt;
You should get a login screen. The default login credentials (if they have not been changed during the installation) are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:38--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&#039;html&#039;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:49--&amp;gt;&lt;br /&gt;
User: admin&lt;br /&gt;
Password: password&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:50--&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:41--&amp;gt;&lt;br /&gt;
You will be prompted to change the default password after you logged in. Have fun!&lt;br /&gt;
&lt;br /&gt;
==Further configuration== &amp;lt;!--T:54--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Caching=== &amp;lt;!--T:55--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:56--&amp;gt;&lt;br /&gt;
LimeSurvey uses the Yii file cache by default, but it can be configured to use other cache engines. Possible other caches are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:57--&amp;gt;&lt;br /&gt;
* Memcached&lt;br /&gt;
* Redis&lt;br /&gt;
* WinCache&lt;br /&gt;
* XCache&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:58--&amp;gt;&lt;br /&gt;
Please see the [https://www.yiiframework.com/doc/api/1.1/CCache Yii documentation] for full description.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:59--&amp;gt;&lt;br /&gt;
Since LimeSurvey 4.0.0 you also have the possibility to cache calculations in the ExpressionScript. This can provide a significant speed-up depending on survey complexity. To enable the emcache, add this in your config.php file (components array):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:60--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&#039;emcache&#039; =&amp;gt; array(&#039;class&#039; =&amp;gt; &#039;CFileCache&#039;),&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:61--&amp;gt;&lt;br /&gt;
As with the main Yii cache, other cache systems can be used.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:62--&amp;gt;&lt;br /&gt;
{{Note| The emcache is not compatible with randomized surveys, and will be automatically turned off in such cases.}}&lt;br /&gt;
&lt;br /&gt;
==What if I have problems...== &amp;lt;!--T:42--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:43--&amp;gt;&lt;br /&gt;
Like all computer programs, most of the time things will work just like the instructions say, but sometimes they just won&#039;t. There are too many possible reasons for things not going according to plan to describe here. If you have trouble, first check out the [[Installation FAQ]]. If you don&#039;t find your answer there, please post your problem and any error messages in the [https://www.limesurvey.org/forum LimeSurvey forums], open a [https://www.limesurvey.org/contact-us support ticket] (only for customers using LimeSurvey Cloud), or join our [https://discord.gg/DEjguXn Discord channel].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;/div&gt;</summary>
		<author><name>Holch</name></author>
	</entry>
	<entry>
		<id>https://www.limesurvey.org/manual/index.php?title=Installation_-_LimeSurvey_CE&amp;diff=176535</id>
		<title>Installation - LimeSurvey CE</title>
		<link rel="alternate" type="text/html" href="https://www.limesurvey.org/manual/index.php?title=Installation_-_LimeSurvey_CE&amp;diff=176535"/>
		<updated>2023-05-16T12:55:29Z</updated>

		<summary type="html">&lt;p&gt;Holch: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages /&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:52--&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt; Note: These installation instructions are for version 2.0 or later. Older instructions for 1.92 can be found [[Installation Version 1.92 or older|here]] and update instructions can be found [[Upgrading from a previous version|here]]. &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==General== &amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
The LimeSurvey project provides two ways to install LimeSurvey:&lt;br /&gt;
*On your webserver:&amp;lt;br /&amp;gt;In this case, just follow the instructions on this page starting with step 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
*On your local Windows PC:&amp;lt;br /&amp;gt;You usually only want to install LimeSurvey on your local PC if you want to create surveys locally (mainly for speed or development/test reasons) and upload them later to your live LimeSurvey installation on a web server. For this purpose, we have prepared a special LimeSurvey package which includes the web server, the database, the LimeSurvey application, and [[Installation of the LimeSurvey XAMPP package|instructions how to install it]].&lt;br /&gt;
&lt;br /&gt;
==Make sure you can use LimeSurvey on your website== &amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
Make sure your server meets the following additional requirements.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:51--&amp;gt;&lt;br /&gt;
{{Note|The minimum set of requirements will also be checked during the installation process!}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
The minimum set of requirements for LimeSurvey 6.x:&lt;br /&gt;
* Minimum 250 MB disk space.&lt;br /&gt;
* MySQL 5.5.3 or later &#039;&#039;&#039;OR&#039;&#039;&#039; Microsoft SQL Server 2005 or later &#039;&#039;&#039;OR&#039;&#039;&#039; Postgres 9 or later.&lt;br /&gt;
* PHP version requirments: &lt;br /&gt;
** LS 6.x from 7.4.x to 8.1.x &lt;br /&gt;
** LS 5.x from 7.2.5 to 8.0.x &lt;br /&gt;
** LS 3.x from 5.5.9 to 7.4.x&lt;br /&gt;
* php.ini `short_open_tag` setting should be set to `ON`&lt;br /&gt;
* The following PHP modules/libraries should be enabled:&lt;br /&gt;
** [[Installation FAQ#Requirements page#What is the mbstring (Multibyte String Functions) library|mbstring (Multibyte String Functions)]] extension library.&lt;br /&gt;
** PDO database driver for MySQL (pdo_mysql or pdo_mysqli) or Postgres (pdo_pgsql) or MSSQL ([https://php.net/manual/en/ref.pdo-sqlsrv.php pdo_sqlsrv] for Windows and [http://www.php.net/manual/en/ref.pdo-dblib.php pdo_dblib] for Linux).&lt;br /&gt;
** Also, we assume in general that all PHP default libraries are enabled &lt;br /&gt;
*** hash&lt;br /&gt;
*** session&lt;br /&gt;
*** openssl or mcrypt&lt;br /&gt;
*** fileinfo&lt;br /&gt;
*** SimpleXML&lt;br /&gt;
*** etc …&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:47--&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt; Note: If you are connecting from Linux to a MSSQL database on a Windows server using the dblib PDO driver, then the underlying FreeTDS needs to be set up correctly. Check out the [[Troubleshooting]] page for more information.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
Optional PHP Extensions:&lt;br /&gt;
* &#039;&#039;&#039;GD-Library&#039;&#039;&#039; &#039;&#039;&#039;with FreeType support&#039;&#039;&#039; installed is needed for captchas, nice charts in statistics or to upload images via the HTML editor - see [https://php.net/manual/image.setup.php PHP GD-Library Extension documentation]&lt;br /&gt;
* &#039;&#039;&#039;IMAP&#039;&#039;&#039; (pretty standard) is needed for the [[Email bounce tracking system|email bounce tracking system]] - see [https://php.net/manual/imap.setup.php PHP IMAP Extension documentation]&lt;br /&gt;
* &#039;&#039;&#039;LDAP&#039;&#039;&#039; installed is needed to import survey participants using LDAP - see [https://php.net/manual/en/book.ldap.php PHP LDAP Documentation]&lt;br /&gt;
* &#039;&#039;&#039;Zip&#039;&#039;&#039; (pretty standard) is needed for template upload, import of .zip archived resources, and excel export - see [https://php.net/manual/zip.setup.php PHP Zip Extension documentation]&lt;br /&gt;
* &#039;&#039;&#039;Zlib&#039;&#039;&#039; (pretty standard) is needed for the [[ComfortUpdate]] - see [https://php.net/manual/zlib.setup.php PHP Zlib Extension documentation]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:12--&amp;gt;&lt;br /&gt;
In most cases, your web server provider or system administrator will be able to help you out with these optional components.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:14--&amp;gt;&lt;br /&gt;
If you want to run Microsoft&#039;s IIS server, taking a look at [[Installation on XP with IIS]] might also help.&lt;br /&gt;
&lt;br /&gt;
===Browser compatibility=== &amp;lt;!--T:46--&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For the survey-taking side&#039;&#039;&#039;, we currently support IE11 (intranet-mode excluded) and all newer comparable browsers like Edge, FF, Chrome, Opera etc. with activated JavaScript. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:53--&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For the administration part&#039;&#039;&#039;, we currently support Edge and all newer comparable browsers like FF, Chrome, Opera etc. with activated JavaScript. &amp;lt;u&amp;gt;We do not support any Internet Explorer versions in the administration part anymore.&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Screen sizes==== &amp;lt;!--T:48--&amp;gt;&lt;br /&gt;
We support any reasonable screen size for survey taking (360px x 640px and up).&lt;br /&gt;
The minimum supported screen resolution for the LimeSurvey administration page is 1280px x 1024px.&lt;br /&gt;
&lt;br /&gt;
===Hosting for LimeSurvey=== &amp;lt;!--T:15--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:16--&amp;gt;&lt;br /&gt;
LimeSurvey should work with most hosting companies that provide PHP and MySQL. If you want a ready-installed version of LimeSurvey, you could try [https://www.limesurvey.org/editions-and-prices/limesurvey-pro/editions-and-prices-professional LimeSurvey Cloud], else check out our [[LimeSurvey-compatible hosting companies|list of LimeSurvey-compatible hosting companies]].&lt;br /&gt;
&lt;br /&gt;
==Download the LimeSurvey package== &amp;lt;!--T:17--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:18--&amp;gt;&lt;br /&gt;
[https://community.limesurvey.org/downloads/ Download] the latest stable LimeSurvey zip package (there are also gzip, bz2 and 7zip packages available for your convenience) and save it to your local disk.&lt;br /&gt;
&lt;br /&gt;
==Unpack the LimeSurvey package== &amp;lt;!--T:19--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:20--&amp;gt;&lt;br /&gt;
Uncompress the zip file into a dedicated directory/folder using your preferred compression software. When you uncompress the file make sure that you uncompress the directory structure with the files (this is default behavior for most compression programs). The path name for the installation directory should not include &#039;(&#039; or &#039;)&#039; special characters, but it may include the &#039;&#039;&#039;space&#039;&#039;&#039; character.&lt;br /&gt;
&lt;br /&gt;
==Collect information about your server== &amp;lt;!--T:21--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:22--&amp;gt;&lt;br /&gt;
You will need to know the following things to install LimeSurvey on your web server correctly:&lt;br /&gt;
*Your intended website URL where your scripts will reside (e.g. &#039;&#039;http://my.domain.com/limesurvey&#039;&#039;).&lt;br /&gt;
*The physical disk location on your server where your scripts will reside (e.g. &#039;&#039;/home/usr/htdocs/limesurvey&#039;&#039;).&lt;br /&gt;
*The IP/net location of your database server (i.e. &#039;&#039;localhost&#039;&#039;).&lt;br /&gt;
*If your database server uses a non-standard port, find out which port it is.&lt;br /&gt;
*Your user name and password for your database server.&lt;br /&gt;
*With most providers you can&#039;t let the script create the database, but have to do it yourself.  If you are using such a provider, please create a database (for example &#039;&#039;limesurvey&#039;&#039;) yourself.&lt;br /&gt;
&lt;br /&gt;
==Upload the files to your web server== &amp;lt;!--T:23--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:24--&amp;gt;&lt;br /&gt;
Using your FTP program (e.g. FileZilla), connect to your web server and create a directory to store your scripts. Then upload the files using the directory structure they are in. Make sure you &#039;&#039;&#039;upload the files in binary mode&#039;&#039;&#039; (check the settings of your FTP program). Please note that uploading in ASCII mode can lead to uncommon errors (e.g. &#039;class not found&#039; error during installation), also images may not be uploaded correctly.&lt;br /&gt;
&lt;br /&gt;
==Set directory permissions== &amp;lt;!--T:25--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:26--&amp;gt;&lt;br /&gt;
For the script to work properly it needs certain access to some directories - this applies especially to Linux/*nix systems.&lt;br /&gt;
*The &#039;&#039;&#039;&amp;quot;/limesurvey/tmp&amp;quot;&#039;&#039;&#039; directory (and all its subdirectories and files) are used for imports &amp;amp; uploads and should be set to &#039;&#039;Read &amp;amp; Write&#039;&#039; for your webserver.&lt;br /&gt;
*The &#039;&#039;&#039;&amp;quot;/limesurvey/upload/&amp;quot;&#039;&#039;&#039; directory (and all its subdirectories and files) must also have &#039;&#039;Read &amp;amp; Write&#039;&#039; for your webserver in order to enable picture and media files upload.&lt;br /&gt;
*The &#039;&#039;&#039;&amp;quot;/limesurvey/application/config/&amp;quot;&#039;&#039;&#039; directory also needs &#039;&#039;Read &amp;amp; Write&#039;&#039; permissions for your webserver.&lt;br /&gt;
*The other directories can be set to &#039;&#039;Read Only&#039;&#039;. You may wish in Linux/Unix to set the permissions on each file within the /limesurvey/admin directory to &#039;&#039;Read Only&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:27--&amp;gt;&lt;br /&gt;
{{Alert|If you are using Linux, then setting permissions depends on your webserver configuration. For example, if you use Apache HTTPD on CentOS, type &#039;&#039;&#039;chmod -R 755 &amp;lt;directory&amp;gt; ; chown -R apache &amp;lt;directory&amp;gt;&#039;&#039;&#039;. This will give everyone access to read, and your webserver will have the permission to write. Check the [https://www.linux.com/learn/tutorials/309527-understanding-linux-file-permissions following link] for more information on Linux permissions.}}&lt;br /&gt;
&lt;br /&gt;
==Create a database user== &amp;lt;!--T:28--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:29--&amp;gt;&lt;br /&gt;
LimeSurvey will create a database and the tables inside it. To be able to do this, it will need the user name and password of a database user. We generally recommend creating a database user with the following permissions:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:30--&amp;gt;&lt;br /&gt;
- MySQL: SELECT, CREATE, INSERT, UPDATE, DELETE, ALTER, DROP, INDEX&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:31--&amp;gt;&lt;br /&gt;
- PostgreSQL: SELECT, INSERT, UPDATE, DELETE, TRUNCATE, TRIGGER&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:32--&amp;gt;&lt;br /&gt;
- Microsoft SQL Server: &#039;&#039;Unknown - if you can find out this information, please complete it&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==Run the installation script== &amp;lt;!--T:33--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:34--&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Go to &amp;quot;example.org/limesurvey/admin&amp;quot;&#039;&#039;&#039;. If you configured everything correctly, the LimeSurvey installer should be starting - just follow the instructions. You will be asked whether you wish to create the database and/or create the tables inside the database. LimeSurvey will then create the needed tables in the database.&lt;br /&gt;
&lt;br /&gt;
==Connect to the administration script for the first time== &amp;lt;!--T:35--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:36--&amp;gt;&lt;br /&gt;
You are done when the installation finishes! Open your browser and enter the URL to the LimeSurvey administration. Assuming you used &#039;limesurvey&#039; as the directory name to store the files in, this will be something like &amp;quot;http://www.example.com/limesurvey/admin&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:37--&amp;gt;&lt;br /&gt;
You should get a login screen. The default login credentials (if they have not been changed during the installation) are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:38--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&#039;html&#039;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:49--&amp;gt;&lt;br /&gt;
User: admin&lt;br /&gt;
Password: password&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:50--&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:41--&amp;gt;&lt;br /&gt;
You will be prompted to change the default password after you logged in. Have fun!&lt;br /&gt;
&lt;br /&gt;
==Further configuration== &amp;lt;!--T:54--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Caching=== &amp;lt;!--T:55--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:56--&amp;gt;&lt;br /&gt;
LimeSurvey uses the Yii file cache by default, but it can be configured to use other cache engines. Possible other caches are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:57--&amp;gt;&lt;br /&gt;
* Memcached&lt;br /&gt;
* Redis&lt;br /&gt;
* WinCache&lt;br /&gt;
* XCache&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:58--&amp;gt;&lt;br /&gt;
Please see the [https://www.yiiframework.com/doc/api/1.1/CCache Yii documentation] for full description.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:59--&amp;gt;&lt;br /&gt;
Since LimeSurvey 4.0.0 you also have the possibility to cache calculations in the ExpressionScript. This can provide a significant speed-up depending on survey complexity. To enable the emcache, add this in your config.php file (components array):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:60--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&#039;emcache&#039; =&amp;gt; array(&#039;class&#039; =&amp;gt; &#039;CFileCache&#039;),&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:61--&amp;gt;&lt;br /&gt;
As with the main Yii cache, other cache systems can be used.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:62--&amp;gt;&lt;br /&gt;
{{Note| The emcache is not compatible with randomized surveys, and will be automatically turned off in such cases.}}&lt;br /&gt;
&lt;br /&gt;
==What if I have problems...== &amp;lt;!--T:42--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:43--&amp;gt;&lt;br /&gt;
Like all computer programs, most of the time things will work just like the instructions say, but sometimes they just won&#039;t. There are too many possible reasons for things not going according to plan to describe here. If you have trouble, first check out the [[Installation FAQ]]. If you don&#039;t find your answer there, please post your problem and any error messages in the [https://www.limesurvey.org/forum LimeSurvey forums], open a [https://www.limesurvey.org/contact-us support ticket] (only for customers using LimeSurvey Cloud), or join our [https://discord.gg/DEjguXn Discord channel].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;/div&gt;</summary>
		<author><name>Holch</name></author>
	</entry>
	<entry>
		<id>https://www.limesurvey.org/manual/index.php?title=REST_API&amp;diff=176391</id>
		<title>REST API</title>
		<link rel="alternate" type="text/html" href="https://www.limesurvey.org/manual/index.php?title=REST_API&amp;diff=176391"/>
		<updated>2023-05-03T14:59:35Z</updated>

		<summary type="html">&lt;p&gt;Holch: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;; TODO - Under development&lt;br /&gt;
: Available from version x (Version to be defined)&lt;br /&gt;
: Technical specification. UML.&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
LimeSurvey REST API (v1) is available from Version [TBD] and offers &#039;&#039;&#039;various [https://api.limesurvey.org/swagger API endpoints]&#039;&#039;&#039;. The initial v1 REST API provides a subset of the functionality provided by the existing [https://manual.limesurvey.org/RemoteControl_2_API Remote Control API] except via a REST interface rather than an RPC interface. &lt;br /&gt;
&lt;br /&gt;
=Setup=&lt;br /&gt;
&lt;br /&gt;
==Configure==&lt;br /&gt;
&lt;br /&gt;
In order to use REST API you must first enable the service, and then adjust the settings to suit your needs. To enable login to the LimeSurvey administration, go to [[Global settings]], choose the tab &#039;Interfaces&#039; and select &#039;Publish API on /rest&#039;. &lt;br /&gt;
&lt;br /&gt;
==Security==&lt;br /&gt;
&lt;br /&gt;
The REST API uses the same security measures as the normal administration login. That means that the permission set of the used username and password is the same as if you would login in the administration with that user/password. Also the REST API is protected against brute-force password cracking - like the normal administration login.&lt;br /&gt;
&lt;br /&gt;
=Usage=&lt;br /&gt;
&lt;br /&gt;
==Documentation==&lt;br /&gt;
&lt;br /&gt;
The available API endpoints are fully documented using swagger [https://api.limesurvey.org/swagger https://api.limesurvey.org/swagger].&lt;br /&gt;
&lt;br /&gt;
==API Location==&lt;br /&gt;
&lt;br /&gt;
The REST API URL is [http://www.yourdomain.com/rest/v1 http://www.yourdomain.com/rest/v1] .&lt;br /&gt;
&lt;br /&gt;
==Authorisation==&lt;br /&gt;
&lt;br /&gt;
Currently the REST API supports server side session authorisation. You use your standard admin username and password to gain API authorisation.&lt;br /&gt;
&lt;br /&gt;
===Login===&lt;br /&gt;
To login to the REST API, perform a POST request to &#039;&#039;/rest/v1/session&#039;&#039; with &#039;username&#039; and &#039;password&#039; post data. The API will returns a 200 response with a session id string body. &lt;br /&gt;
&lt;br /&gt;
===Bearer Authentication===&lt;br /&gt;
The session id string returned in the JSON response of &#039;&#039;/rest/v1/session&#039;&#039; can be used as authorisation in requests to other endpoints using bearer authentication (also called token authentication). &lt;br /&gt;
&lt;br /&gt;
Set HTTP header &#039;Authorization&#039; with the value &#039;Bearer my-session-id-string-returned-from-server&#039; in each request to endpoints  that require authorisation. &lt;br /&gt;
&lt;br /&gt;
===Logout===&lt;br /&gt;
To logout of the REST API perform an authorised DELETE request to the &#039;&#039;/rest/v1/session&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==Endpoints==&lt;br /&gt;
&lt;br /&gt;
See the  [https://api.limesurvey.org/swagger Swagger Documentation] for full details.&lt;br /&gt;
&lt;br /&gt;
; /rest/v1/&lt;br /&gt;
: session&lt;br /&gt;
: siteSettings&lt;br /&gt;
: siteSettings/&amp;lt;setting-name&amp;gt;&lt;br /&gt;
: survey&lt;br /&gt;
: survey/&amp;lt;id&amp;gt;&lt;br /&gt;
: questionGroup/&amp;lt;surveyId&amp;gt;&lt;br /&gt;
: questionGroup&lt;br /&gt;
: questionGroup/&amp;lt;groupId&amp;gt;&lt;br /&gt;
: questionGroupProperties/&amp;lt;groupId&amp;gt; &lt;br /&gt;
: questioGroupProperties/&amp;lt;groupId&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
&lt;br /&gt;
==PHP Example==&lt;br /&gt;
&lt;br /&gt;
This example uses Guzzle as a PHP REST client but you can use any REST client.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
composer require guzzlehttp/guzzle:^7.0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or by inclusion of the following lines in your composer.json file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;require&amp;quot;: {&lt;br /&gt;
        &amp;quot;guzzlehttp/guzzle&amp;quot;: &amp;quot;^7.0&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is an example how to connect to limesurvey REST API:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
require &#039;./vendor/autoload.php&#039;;&lt;br /&gt;
&lt;br /&gt;
use GuzzleHttp\Client;&lt;br /&gt;
&lt;br /&gt;
$baseUrl = &#039;https://www.mysurveysite.com/index.php/&#039;;&lt;br /&gt;
$api = &#039;rest/v1/&#039;;&lt;br /&gt;
$apiUrl = $baseUrl . $api;&lt;br /&gt;
$timeout = 60;&lt;br /&gt;
&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
// Login&lt;br /&gt;
&lt;br /&gt;
$loginClient = new Client([&lt;br /&gt;
    &#039;base_uri&#039; =&amp;gt; $apiUrl,&lt;br /&gt;
    &#039;timeout&#039;  =&amp;gt; $timeout&lt;br /&gt;
]);&lt;br /&gt;
&lt;br /&gt;
$loginResult = $loginClient-&amp;gt;request(&#039;POST&#039;, &#039;session&#039;, [&lt;br /&gt;
    &#039;form_params&#039; =&amp;gt; [&lt;br /&gt;
        &#039;username&#039; =&amp;gt; &#039;admin&#039;,&lt;br /&gt;
        &#039;password&#039; =&amp;gt; &#039;password&#039;&lt;br /&gt;
    ]&lt;br /&gt;
]);&lt;br /&gt;
$sessionId = null;&lt;br /&gt;
if ($loginResult-&amp;gt;getStatusCode() == 200) {&lt;br /&gt;
    $sessionId = json_decode(&lt;br /&gt;
        (string) $loginResult-&amp;gt;getBody(),&lt;br /&gt;
        true&lt;br /&gt;
    );&lt;br /&gt;
} else {&lt;br /&gt;
    throw new Exception(&#039;Login failed: &#039; . $result-&amp;gt;getStatusCode());&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
// Use the API with session id that we got from login&lt;br /&gt;
$client = new Client([&lt;br /&gt;
    &#039;base_uri&#039; =&amp;gt; $apiUrl,&lt;br /&gt;
    &#039;timeout&#039;  =&amp;gt; $timeout,&lt;br /&gt;
    &#039;headers&#039;  =&amp;gt; [&#039;Authorization&#039; =&amp;gt; &#039;Bearer &#039; . $sessionId]&lt;br /&gt;
]);&lt;br /&gt;
&lt;br /&gt;
$result = $client-&amp;gt;request(&#039;GET&#039;, &#039;siteSettings/sitename&#039;);&lt;br /&gt;
$siteName = null;&lt;br /&gt;
if ($result-&amp;gt;getStatusCode() == 200) {&lt;br /&gt;
    $siteName = json_decode(&lt;br /&gt;
        (string) $result-&amp;gt;getBody(),&lt;br /&gt;
        true&lt;br /&gt;
    );&lt;br /&gt;
} else {&lt;br /&gt;
    throw new Exception(&#039;Failed getting site name: &#039; . $result-&amp;gt;getStatusCode());&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
echo &#039;Site name: &#039; . $siteName;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
// Logout&lt;br /&gt;
// - This is important. If you create too many simultaneous login session&lt;br /&gt;
// - you may be temporarily blocked from creating more.&lt;br /&gt;
$result = $client-&amp;gt;request(&#039;DELETE&#039;, &#039;session&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Holch</name></author>
	</entry>
	<entry>
		<id>https://www.limesurvey.org/manual/index.php?title=Survey_quotas&amp;diff=174927</id>
		<title>Survey quotas</title>
		<link rel="alternate" type="text/html" href="https://www.limesurvey.org/manual/index.php?title=Survey_quotas&amp;diff=174927"/>
		<updated>2022-11-04T12:48:59Z</updated>

		<summary type="html">&lt;p&gt;Holch: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages /&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Introduction= &amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
A quota is used to set a limit on responses from defined groups of people on an active survey. Some common attributes used in defining quotas are gender, age, race, province/state, etc.  To access the survey quotas panel, from the &#039;&#039;&#039;Settings&#039;&#039;&#039; &#039;&#039;Survey menu&#039;&#039;, select the survey &#039;&#039;&#039;Quotas&#039;&#039;&#039; tab.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:32--&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;[[File:Survey menu - Survey quotas.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;!--T:31--&amp;gt;&lt;br /&gt;
{{Alert|title=Attention|text= You can only verify that Quotas have been set correctly when the survey is activated. So, if you set a quota with a limit of &amp;quot;0&amp;quot; and the survey is not activated, you will not be able to check whether it is working or not.}}&lt;br /&gt;
&lt;br /&gt;
=How do quotas work?= &amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
To understand how the LimeSurvey quota system works, think of a survey that contains a &amp;quot;Yes or No&amp;quot; question and an Array question, each of them belonging to two different question groups. You set a quota on this survey that contains a restriction of 20 users who have answered &amp;quot;Yes&amp;quot; to this question. The quota will be checked every time someone answers &amp;quot;Yes&amp;quot; to that question. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:33--&amp;gt;&lt;br /&gt;
Depending on [[General_settings#General_settings_panel|the format of your survey]] (how the questions are displayed to your participants), the &#039;&#039;&#039;check&#039;&#039;&#039; happens either when you submit:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:34--&amp;gt;&lt;br /&gt;
*&#039;&#039;&#039;the whole survey answers at once:&#039;&#039;&#039; If the format of the survey is &#039;&#039;all in one&#039;&#039;, the questions (regardless of the question group they belong to) will be displayed on the same page. Therefore, the user has to click the submit button in order to trigger the quota limit check;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:35--&amp;gt;&lt;br /&gt;
*&#039;&#039;&#039;the answers to a question group:&#039;&#039;&#039; If the format of the survey is group by group, then the quota is activated when the survey participant has responded to all the questions that belong to the question group where the answer that contains the quota system check is located.  Therefore, the quota may be triggered before the end of the survey if, for example, the question group is located in the beginning of the survey.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:36--&amp;gt;&lt;br /&gt;
*&#039;&#039;&#039;the answer to a question:&#039;&#039;&#039; If the format of the survey is question by question, each question will be displayed separately, each of them being allocated a page. In this case, if you select the answer that the quota is applied to, the quota system will be automatically triggered once you click the &#039;&#039;Next/Submit&#039;&#039; button. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:37--&amp;gt;&lt;br /&gt;
{{Note|To change the format of a survey, access the [[General settings|general settings of your survey]].}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
If &amp;quot;&#039;&#039;No&#039;&#039;&amp;quot; is chosen, the quota system is not triggered. Therefore, the survey will not restrict anyone from responding to the rest of the questions, unless otherwise specified. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
To set a limit on the number of &amp;quot;&#039;&#039;No&#039;&#039;&amp;quot; responses, you need to add an additional quota, restricting the number of participants who choose &amp;quot;&#039;&#039;No&#039;&#039;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:38--&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;[[File:help.png]] &#039;&#039;&#039;Note:&#039;&#039;&#039; If you would like your participants to answer certain survey questions according to a previous answer, use the LimeSurvey [[ExpressionScript - Presentation|ExpressionScript]].&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Using more answers and quotas== &amp;lt;!--T:12--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:13--&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example&#039;&#039;&#039;: You want to conduct a survey where you want to limit it to 25 male and 30 female participants. In this case, you will have to apply two quota limits: one on males and one on females. This will give you a maximum of 25 males who can complete the survey, and a maximum of 30 females who can complete the survey..&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:39--&amp;gt;&lt;br /&gt;
Let&#039;s suppose now that you want 50 answers from males and 50 answers from females. Please note that each answer that triggers the quota must be introduced in its own quota box. Adding the two answers in the same box will result in collecting 50 answers, regardless of the respondents&#039; gender distribution (e.g., the distribution can be 40 males and 10 females, or 20 males and 30 females, and so on). Continue reading this wiki page and see the [[Survey quotas#Examples|examples]] subsection get a grasp on the usage of the quota system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Activating the quota system while the survey responses table is not empty== &amp;lt;!--T:40--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:41--&amp;gt;&lt;br /&gt;
Note that a quota system does not necessarily have to be added before you activate your survey. If you decide to activate the quota system at a later date, it will start to check the survey responses table and look for those entries that are marked as &#039;&#039;complete&#039;&#039;. Then, it checks to determine if the quota condition has been met or not. If it has been met, the next survey responses/entries received will be marked as &#039;&#039;incomplete&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:42--&amp;gt;&lt;br /&gt;
For example, if you have previously gathered 1000 responses from women and you introduced after a couple of weeks the quota limit of 800 for women, the next responses that you receive from women will be marked &#039;&#039;incomplete&#039;&#039;. The other 200 answers will appear in the survey responses table as &#039;&#039;complete&#039;&#039; because the quota was applied after the answers were collected.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:43--&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;[[File:Survey_quotas_-_survey_responses_2.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:44--&amp;gt;&lt;br /&gt;
The quota system does not store any answers and it does not record the number of the submitted survey answers! Think of it as a filter that is applied on the survey responses table. Basically, it looks into the &#039;&#039;&#039;completed&#039;&#039;&#039; column and those question columns that contain the answers to which one or more quotas are applied to.&lt;br /&gt;
&lt;br /&gt;
=Supported question types= &amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
The quota system can be applied only to the following types of questions at the moment:&lt;br /&gt;
*Gender&lt;br /&gt;
*Multiple Choice&lt;br /&gt;
*Array - 5 Point Choice&lt;br /&gt;
*Array - 10 Point Choice&lt;br /&gt;
*Language Switch&lt;br /&gt;
*Yes/No&lt;br /&gt;
*List (Radio)&lt;br /&gt;
*List (Dropdown)&lt;br /&gt;
*List with comments&lt;br /&gt;
*Equation&lt;br /&gt;
&lt;br /&gt;
=Survey quotas panel= &amp;lt;!--T:45--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:46--&amp;gt;&lt;br /&gt;
Once you click the &#039;&#039;&#039;Survey quotas&#039;&#039;&#039; tab from the survey menu, the following page will be displayed:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:47--&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;[[FIle:Survey quotas - panel.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:48--&amp;gt;&lt;br /&gt;
To see the full set of options of this panel, add one survey quota. Then, the survey quota page will look like the following:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:49--&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;[[File:Survey quotas - image 2.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:50--&amp;gt;&lt;br /&gt;
The following options are available:&lt;br /&gt;
*&#039;&#039;&#039;[[Survey quotas#Quick CSV report|Add new quota]]:&#039;&#039;&#039; Located on the bottom right part of the survey quotas table, it allows users to add new quotas. Once quotas are displayed on the table, you can start implementing them to certain questions/subquestions answers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:51--&amp;gt;&lt;br /&gt;
*&#039;&#039;&#039;[[Survey quotas#Add an answer|Add an answer]]:&#039;&#039;&#039; Before adding an answer, you need to add a quota where the answer(s) will be stored in. The quota limit will be applied &amp;lt;u&amp;gt;only&amp;lt;/u&amp;gt; to those answers displayed in the quota box.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:52--&amp;gt;&lt;br /&gt;
*&#039;&#039;&#039;Edit quota:&#039;&#039;&#039; Click the green pencil located under the &#039;&#039;&#039;Action&#039;&#039;&#039; column of the survey quotas table to edit the fields of a quota&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:53--&amp;gt;&lt;br /&gt;
*&#039;&#039;&#039;Delete quota:&#039;&#039;&#039; Click the red trash button located under the &#039;&#039;&#039;Action&#039;&#039;&#039; column of the survey quotas table to delete the respective quota entry;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:54--&amp;gt;&lt;br /&gt;
*&#039;&#039;&#039;[[Survey quotas#Quota validation|Quota validation]]:&#039;&#039;&#039; Click the last button located under the &#039;&#039;&#039;Action&#039;&#039;&#039; column of the survey quotas table to quickly check the quota message displayed to the respondents, the URL (and/or a short description of it) where they will be redirected.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:55--&amp;gt;&lt;br /&gt;
*&#039;&#039;&#039;[[Survey quotas#Quick CSV report|Quick CSV report]]:&#039;&#039;&#039; Exports a summary of the quotas under the form of a comma-delimited CSV table.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:56--&amp;gt;&lt;br /&gt;
*&#039;&#039;&#039;Selected quota(s)...:&#039;&#039;&#039; Works like an aggregator. Select multiple quotas and use this button to apply one of the actions described below to the selected group of quotas.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:57--&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;[[File:Survey quotas - Selected quota(s).png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:58--&amp;gt;&lt;br /&gt;
**&#039;&#039;Activate:&#039;&#039; Use this button to activate a quota. The active ones have the quota name, action, and URL written in white font on a green background. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:59--&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;[[File:Active quota.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:60--&amp;gt;&lt;br /&gt;
**&#039;&#039;Deactivate:&#039;&#039; Use this button to deactivate a quota. The deactivated ones have the quota name, action, and URL written in black font on a grey background.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:61--&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;[[File:Deactivated quota.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:62--&amp;gt;&lt;br /&gt;
**&#039;&#039;Change texts:&#039;&#039; Use this button to quickly change the quota message, URL, and URL description of a group of a quotas. You may use this function to redirect respondents to a certain link once different quota conditions were met. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:63--&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;[[File:Survey quotas - change texts.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:64--&amp;gt;&lt;br /&gt;
**&#039;&#039;Delete:&#039;&#039; If you want to delete a group of quotas by a few clicks, tick the ones you want to delete, click the selected quota(s) button, and select the &#039;&#039;&#039;Delete&#039;&#039;&#039; option.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Add new quota== &amp;lt;!--T:65--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:16--&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For a fully working quota you must first &amp;quot;add a quota&amp;quot;, and then &amp;quot;add answers&amp;quot; to that quota.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:18--&amp;gt;&lt;br /&gt;
Once you click the &#039;&#039;&#039;Add new quota&#039;&#039;&#039; button, the following page will be displayed:  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:66--&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;[[File:Add_new_quota_panel.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:67--&amp;gt;&lt;br /&gt;
{{Note|The fields marked with a star are required fields.}} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:68--&amp;gt;&lt;br /&gt;
The following options are available:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:69--&amp;gt;&lt;br /&gt;
*&#039;&#039;&#039;Quota Name:&#039;&#039;&#039; The name of the quota that will be displayed on the survey quotas table. It should describe the quota it will represent.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:70--&amp;gt;&lt;br /&gt;
*&#039;&#039;&#039;Quota Limit:&#039;&#039;&#039; The maximum number of completed surveys that will be stored in the responses table and marked as &#039;&#039;complete&#039;&#039;. See above the wiki section on [[Survey_quotas#How do quotas work|how do quotas work]] to better understand the mechanism employed by LimeSurvey. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:71--&amp;gt;&lt;br /&gt;
*&#039;&#039;&#039;Quota Action:&#039;&#039;&#039; If the quota is triggered, then one of two actions will happen: &lt;br /&gt;
**&#039;&#039;Terminate survey:&#039;&#039; This action immediately terminates and closes the survey.&lt;br /&gt;
**&#039;&#039;Allow user to modify his last answers before terminate survey:&#039;&#039;  Useful action when you want your participants to choose different options. In this way, you can force some of them choose another solution or option. For example, when incentives are offered, you can use a quota on each option so that not everyone chooses the same incentive. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:72--&amp;gt;&lt;br /&gt;
*&#039;&#039;&#039;Autoload URL:&#039;&#039;&#039; This tells LimeSurvey to automatically redirect the participant to the URL when the quota action occurs. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:73--&amp;gt;&lt;br /&gt;
*&#039;&#039;&#039;Quota Message:&#039;&#039;&#039; Write the text you want to be displayed to participants if the quota action is triggered. The message will be displayed if the &#039;&#039;&#039;Autoload URL&#039;&#039;&#039; is disabled.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:74--&amp;gt;&lt;br /&gt;
*&#039;&#039;&#039;URL:&#039;&#039;&#039; The URL displayed to survey participants after the quota action is triggered. The users can also be automatically redirected to this URL if &amp;quot;Autoload URL&amp;quot; is enabled. You can use [[URL fields]] in this section.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:75--&amp;gt;&lt;br /&gt;
*&#039;&#039;&#039;URL Description:&#039;&#039;&#039; A short URL description can be added in order to show to the other survey administrators the purpose of the URL for example.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Add an answer=== &amp;lt;!--T:76--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:77--&amp;gt;&lt;br /&gt;
Once the quota has been created, you can start adding answers. To add answers, access the Survey quotas panel. Look into the survey quotas table and select the &#039;&#039;&#039;Add answer&#039;&#039;&#039; option from the quota box that you want to add the respective answer to.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:78--&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;[[File:Survey quotas table - add answer.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:79--&amp;gt;&lt;br /&gt;
A new page will be displayed asking you to select the question the quota will be applied to.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:80--&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;[[File:Add answer - part 1.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:81--&amp;gt;&lt;br /&gt;
{{Box|Please remember that only certain types of questions accept quotas. [[Survey quotas#Supported question types|Click here]] to revisit the supported question types list.}} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:82--&amp;gt;&lt;br /&gt;
Click &#039;&#039;&#039;Next&#039;&#039;&#039;.  The answers of the question you selected one step before will be displayed. Now, you have to choose which answer you want the quota to be applied to.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:83--&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;[[File:Add answer - part 2.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:84--&amp;gt;&lt;br /&gt;
In this example, the &amp;quot;&#039;&#039;Male&#039;&#039;&amp;quot; answer will have the quota applied to it. Whenever participants choose this option, the quota system registers the answer. Once the quota limit is reached, the stored survey answers will be saved in the survey responses table, but it will be marked &#039;incomplete&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==Quick CSV report== &amp;lt;!--T:85--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:86--&amp;gt;&lt;br /&gt;
The quick CSV report function is used to export the survey quotas table in a comma-delimited CSV file. It includes the following fields: &lt;br /&gt;
*&#039;&#039;&#039;Quota name:&#039;&#039;&#039; The name of the quotas;&lt;br /&gt;
*&#039;&#039;&#039;Limit&#039;&#039;&#039;: If the quota is active, it represents the maximum number of survey responses that can be marked as &#039;&#039;complete&#039;&#039; in the survey responses table;&lt;br /&gt;
*&#039;&#039;&#039;Completed:&#039;&#039;&#039; The number of survey answers marked as &#039;&#039;complete&#039;&#039; in the survey responses table. Please note that an answer is marked as &#039;&#039;incomplete&#039;&#039; if the quota is triggered.&lt;br /&gt;
*&#039;&#039;&#039;Remaining:&#039;&#039;&#039; The number of answers that can still be collected in the survey responses table and marked as &#039;&#039;complete&#039;&#039; there.&lt;br /&gt;
&lt;br /&gt;
=Quota and tokens= &amp;lt;!--T:29--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:30--&amp;gt;&lt;br /&gt;
When tokens are used in a survey and a participant is &#039;&#039;screened out&#039;&#039; due to a quota, then the respective token entry from the survey responses table is marked with the letter &amp;quot;Q&amp;quot; in the &#039;&#039;&#039;completed&#039;&#039;&#039; column from the survey responses table. The token is invalidated in this way and the survey participant cannot restart the survey.&lt;br /&gt;
&lt;br /&gt;
=Examples= &amp;lt;!--T:87--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:88--&amp;gt;&lt;br /&gt;
The following examples are used to better explain the role of quotas and their usage within the LimeSurvey environment. Before viewing the following examples, please take into account that:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:89--&amp;gt;&lt;br /&gt;
*Answers added in the same quota are summed up. For example, if answers A and B from the available responses of a survey question are added to quota Q1, the quota limit &#039;&#039;&#039;sums up&#039;&#039;&#039; the number of users who pick up A and B as their answers. Therefore, there is a high probability that the distribution of A and B answers will be uneven (dependent on the characteristics or preferences of your respondents). &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:90--&amp;gt;&lt;br /&gt;
*Answers added in different quotas act as if there is a logical operator &amp;quot;AND&amp;quot; between them. Let&#039;s suppose that A is added to Q1 and B to Q2. If A is chosen and Q1 is reached, then respondents won&#039;t get their answers marked &#039;&#039;complete&#039;&#039; in the survey responses table. However, the survey participants that choose B are still allowed to continue as long as Q2 is not reached. Once it is reached, participants who further choose A or B as answers to that specific question will have their answers marked &#039;&#039;incomplete&#039;&#039; in the survey responses table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:91--&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;[[File:Survey quotas - survey responses.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Adding more answers to different quotas== &amp;lt;!--T:92--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:93--&amp;gt;&lt;br /&gt;
Let&#039;s assume that you are doing a survey about LimeSurvey and you would like to receive feedback from your participants. You would like to receive 1000 answers from students (PhD student, graduate, undergraduate) and another 1000 from non-students (unemployed persons, full/part-time working persons or other). In order to do this, create two quotas: &#039;&#039;&#039;Students quota&#039;&#039;&#039; and &#039;&#039;&#039;Non-students quota&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:94--&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;[[File:Survey quotas - example - add survey quotas.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:95--&amp;gt;&lt;br /&gt;
Now, start adding answers to each quota box following the steps described above in the [[Survey quotas#Add an answer|wiki section]]. The quota boxes should look like this:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:96--&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;[[File:Survey quotas - example - add answers.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:97--&amp;gt;&lt;br /&gt;
By using this method, you limit the number of responses you receive from the two defined groups: students and non-student groups. Now, activate the survey and start testing the quotas. If you first reach 1000 answers from the &#039;&#039;&#039;non-students&#039;&#039;&#039; group, the next answers you receive from this category will be marked as &#039;incomplete&#039;&#039; in the survey responses table. Only answers that come from the students group will still be accepted. Once it also reaches 1000, no more answers will be registered as &#039;&#039;complete&#039;&#039; in the survey responses table. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:98--&amp;gt;&lt;br /&gt;
{{Box|However, the survey can still be accessed by the participants! Deactivate it once you see that the quota limit has been reached.}}&lt;br /&gt;
&lt;br /&gt;
==Adding a URL link== &amp;lt;!--T:99--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:100--&amp;gt;&lt;br /&gt;
To add a URL link to a quota, please continue reading the [[URL fields|URL fields]] wiki section.&lt;br /&gt;
&lt;br /&gt;
==Using of equation question for quota in other question type== &amp;lt;!--T:101--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:102--&amp;gt;&lt;br /&gt;
You can use [[Question_type_-_Equation|Equation Question]] to set a value to [[Survey_quotas#Supported_question_types|supported question types]] and [[Expression_Manager#Using_Assignment_Operator|assignment operator]]. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:103--&amp;gt;&lt;br /&gt;
The 2 question can be hidden, quota is checked if all question are hidden or when one question is in submitted page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:104--&amp;gt;&lt;br /&gt;
For example , to set a quota to a text question (user write ok or not) on a Y/N question: &amp;lt;code&amp;gt;{QuotaQuestion=if(strtolower(Q00.NAOK) == &#039;ok&#039;, &#039;Y&#039;, &#039;N&#039;)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:105--&amp;gt;&lt;br /&gt;
[[File:QuotaEquation.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:106--&amp;gt;&lt;br /&gt;
You can import and activate this sample survey [[File:Limesurvey_survey_quotaEquationAndOptOut.zip]] (remember to unzip the file and activate the survey).&lt;br /&gt;
&lt;br /&gt;
==Limiting max number of responses in survey using a hidden question== &amp;lt;!--T:107--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:108--&amp;gt;&lt;br /&gt;
Like using an equation to set a value to an answer, quota for default values are checked if a question is hidden. This allows you to set a maximum number of response in a specific survey. You put a quota on the default answer in a hidden question and put this question in a simple group.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:109--&amp;gt;&lt;br /&gt;
You can import and activate this sample survey [[File:Quota_by_default_value_sample_survey.zip]] (remember to unzip the file and activate the survey).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;/div&gt;</summary>
		<author><name>Holch</name></author>
	</entry>
	<entry>
		<id>https://www.limesurvey.org/manual/index.php?title=Available_third_party_plugins&amp;diff=174233</id>
		<title>Available third party plugins</title>
		<link rel="alternate" type="text/html" href="https://www.limesurvey.org/manual/index.php?title=Available_third_party_plugins&amp;diff=174233"/>
		<updated>2022-07-25T15:21:59Z</updated>

		<summary type="html">&lt;p&gt;Holch: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Some plugin are listed in the [https://account.limesurvey.org/limestore Limestore]. If you have a plugin you would like to share with the world, feel free to add it to this page.&lt;br /&gt;
&lt;br /&gt;
== Authentication plugins ==&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/technowhizz/LimeSurvey-RegDomainRestricter Registration Email Domain Restrictor] &lt;br /&gt;
* [https://github.com/pitbulk/limesurvey-saml SAML support (Only supports Limesurvey version 2.x and below not 3.x or 4.x)]&lt;br /&gt;
* [http://extensions.sondages.pro/authentification-by-wordpress/ Authentification by WordPress user]&lt;br /&gt;
* [https://github.com/univlorraine/limesurvey-cas CAS Authentication plugin for limesurvey]&lt;br /&gt;
* [https://github.com/atlet/LimeSurvey-ShibbolethAuth LimeSurvey Shibboleth auth plugin]&lt;br /&gt;
* [https://framagit.org/Animafac/limesurvey/limesurvey-rememberme LimeSurvey RememberMe plugin]&lt;br /&gt;
&lt;br /&gt;
== Export and statistics plugins ==&lt;br /&gt;
&lt;br /&gt;
* [http://extensions.sondages.pro/exportcompleteanswers/ exportCompleteAnswers : Complete New export system allowing export Answer code and answer text in CSV. Options is manageable by super admin.]&lt;br /&gt;
* [http://extensions.sondages.pro/triple-s-export/ exportTripleS : export in Triple-S XML2 or XML1.3 format survey structure and data.]&lt;br /&gt;
* [https://framagit.org/SondagePro-LimeSurvey-plugin/extendAdminStatitistics extendAdminStatitistics : rewriting of core statistics, actually put sub question in same table and graph]&lt;br /&gt;
* [https://github.com/reportico-web/limesurvey-reportico Reportico Reporting module for Limesurvey]: generate charts,tables and statistics from survey data&lt;br /&gt;
&lt;br /&gt;
== Public survey plugins ==&lt;br /&gt;
* [http://extensions.sondages.pro/hideemptycolumn-for-limesurvey/ hideEmptyColumn : A plugin to add a solution to hide column of array question type with ExpressionScript of LimeSurvey ]&lt;br /&gt;
* [http://extensions.sondages.pro/moreaccessibility/ moreAccessibility : some option to add accessibility to public survey] 2.6lts compatible onlmy, deprecated in 3.0&lt;br /&gt;
* [https://git.framasoft.org/Shnoulle/addQuestionCodeClass addQuestionCodeClass : add the question code at the question wrapper class]&lt;br /&gt;
* [https://framagit.org/SondagePro-LimeSurvey-plugin/radioToStarRating radioToStarRating : set any radio list to star rating system]&lt;br /&gt;
* [https://framagit.org/SondagePro-LimeSurvey-plugin/moveSomeAnswers moveSomeAnswers] : If using random_order attribute : allow to always move some answers at end.&lt;br /&gt;
&lt;br /&gt;
== Data editing plugins ==&lt;br /&gt;
* [https://manual.limesurvey.org/MassAction_Plugin MassAction] : A plugin for faster survey editing by loading questions details into editable cells. Includes a search and replace feature.&lt;br /&gt;
&lt;br /&gt;
== Email plugins ==&lt;br /&gt;
&lt;br /&gt;
* [https://gitlab.com/SondagesPro/mailing/noMailToExample noMailToExample]&lt;br /&gt;
* [https://github.com/LimeSurvey/LimeSurvey/blob/develop/plugins/mailSenderToFrom/mailSenderToFrom.php mailSenderToFrom]&lt;br /&gt;
* [https://github.com/Xites/LS_mailDKIM mailDKIM]&lt;br /&gt;
* [https://github.com/Xites/LS_mailEmbedImages mailEmbedImages]&lt;br /&gt;
&lt;br /&gt;
== Other plugins ==&lt;br /&gt;
&lt;br /&gt;
* [http://extensions.sondages.pro/recomputeexpression-for-limesurvey Recompute Expressions:] A Plugin for LimeSurvey to recompute expression in survey with already submitted survey. Allow to update some relevance too.&lt;br /&gt;
* [https://git.framasoft.org/SondagePro-LimeSurvey-plugin/showAdvancedSettings showAdvancedSettings:] Show advanced settings in question edit by default.&lt;br /&gt;
* [https://git.framasoft.org/SondagePro-LimeSurvey-plugin/replaceRegister  replaceRegisterː] Extra option for Register, starting point for other plugin. &lt;br /&gt;
* [http://extensions.sondages.pro/fixmaxstep-for-question-index/ fixMaxStep : Fix question index for token answer persistence survey:] Example of usage : get the complete index when user come back to the survey.&lt;br /&gt;
* [http://extensions.sondages.pro/sendmailajax-all-email-in-one/ sendMailAjax : Send token email one by one with ajaxː] Allow to send all email in one click without restriction.&lt;br /&gt;
* [http://extensions.sondages.pro/mailing-management/sendmailcron sendMailCron: Automatically send invitations and reminders using cronjobsː] Automatically sends invitations and reminders in custom intervals. Extensive configuration and debugging options&lt;br /&gt;
* [https://github.com/SteveCohen/Piwik-for-Limesurvey Piwik-for-Limesurvey Piwik for LImesurveyː] Plugs Piwik into Limesurvey, so you can track your survey admin users and respondents.&lt;br /&gt;
* [https://github.com/SondagesPro/surveysModel Mark surveys as &amp;quot;Survey Model/Template&amp;quot;ː] Allow admins to mark a survey as &amp;quot;Survey Model&amp;quot;, a kind of &amp;quot;master survey&amp;quot; or &amp;quot;survey template&amp;quot; which only users with appropriate rights are allowed to edit. The common user is only allowed to create copies based on such a survey template.&lt;br /&gt;
* [https://github.com/SondagesPro/LS-toolsDomDocument toolsDomDocumentː] a tools for anothers plugin&lt;br /&gt;
* [https://github.com/TonisOrmisson/limesurvey-url-templates UrlTemplateChangerː] Set respondent&#039;s interview template over an URL parameter.&lt;br /&gt;
* [https://github.com/evently-nl/zesthook  ZestHookː] Makes it possible to send a Post request on every response submission. You can set the URL to post to, as well as several other options.&lt;br /&gt;
* [https://github.com/CEric-fr/limesurvey-rgpd Extension RGPD pour LimeSurvey] Each questionnaire owner is able to interact with these conditions of use via a new submenu added in the &amp;quot;questionnaire parameters&amp;quot; entitled: GDPR configuration.&lt;br /&gt;
&lt;br /&gt;
== Example and demo plugins ==&lt;br /&gt;
* [https://framagit.org/SondagePro-LimeSurvey-plugin/extendRemoteControl extendRemoteControl] : Show how to add function to [[RemoteControl_2_API]], show how to create a new admin page too (usage of public function actionIndex() )&lt;br /&gt;
&lt;br /&gt;
[[Category:Plugins]]&lt;/div&gt;</summary>
		<author><name>Holch</name></author>
	</entry>
	<entry>
		<id>https://www.limesurvey.org/manual/index.php?title=Available_third_party_plugins&amp;diff=174232</id>
		<title>Available third party plugins</title>
		<link rel="alternate" type="text/html" href="https://www.limesurvey.org/manual/index.php?title=Available_third_party_plugins&amp;diff=174232"/>
		<updated>2022-07-25T15:21:28Z</updated>

		<summary type="html">&lt;p&gt;Holch: Link to the Extension page was broken, included the link to the Limestore.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Some plugin are listed in the [//https://account.limesurvey.org/limestore Limestore]. If you have a plugin you would like to share with the world, feel free to add it to this page.&lt;br /&gt;
&lt;br /&gt;
== Authentication plugins ==&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/technowhizz/LimeSurvey-RegDomainRestricter Registration Email Domain Restrictor] &lt;br /&gt;
* [https://github.com/pitbulk/limesurvey-saml SAML support (Only supports Limesurvey version 2.x and below not 3.x or 4.x)]&lt;br /&gt;
* [http://extensions.sondages.pro/authentification-by-wordpress/ Authentification by WordPress user]&lt;br /&gt;
* [https://github.com/univlorraine/limesurvey-cas CAS Authentication plugin for limesurvey]&lt;br /&gt;
* [https://github.com/atlet/LimeSurvey-ShibbolethAuth LimeSurvey Shibboleth auth plugin]&lt;br /&gt;
* [https://framagit.org/Animafac/limesurvey/limesurvey-rememberme LimeSurvey RememberMe plugin]&lt;br /&gt;
&lt;br /&gt;
== Export and statistics plugins ==&lt;br /&gt;
&lt;br /&gt;
* [http://extensions.sondages.pro/exportcompleteanswers/ exportCompleteAnswers : Complete New export system allowing export Answer code and answer text in CSV. Options is manageable by super admin.]&lt;br /&gt;
* [http://extensions.sondages.pro/triple-s-export/ exportTripleS : export in Triple-S XML2 or XML1.3 format survey structure and data.]&lt;br /&gt;
* [https://framagit.org/SondagePro-LimeSurvey-plugin/extendAdminStatitistics extendAdminStatitistics : rewriting of core statistics, actually put sub question in same table and graph]&lt;br /&gt;
* [https://github.com/reportico-web/limesurvey-reportico Reportico Reporting module for Limesurvey]: generate charts,tables and statistics from survey data&lt;br /&gt;
&lt;br /&gt;
== Public survey plugins ==&lt;br /&gt;
* [http://extensions.sondages.pro/hideemptycolumn-for-limesurvey/ hideEmptyColumn : A plugin to add a solution to hide column of array question type with ExpressionScript of LimeSurvey ]&lt;br /&gt;
* [http://extensions.sondages.pro/moreaccessibility/ moreAccessibility : some option to add accessibility to public survey] 2.6lts compatible onlmy, deprecated in 3.0&lt;br /&gt;
* [https://git.framasoft.org/Shnoulle/addQuestionCodeClass addQuestionCodeClass : add the question code at the question wrapper class]&lt;br /&gt;
* [https://framagit.org/SondagePro-LimeSurvey-plugin/radioToStarRating radioToStarRating : set any radio list to star rating system]&lt;br /&gt;
* [https://framagit.org/SondagePro-LimeSurvey-plugin/moveSomeAnswers moveSomeAnswers] : If using random_order attribute : allow to always move some answers at end.&lt;br /&gt;
&lt;br /&gt;
== Data editing plugins ==&lt;br /&gt;
* [https://manual.limesurvey.org/MassAction_Plugin MassAction] : A plugin for faster survey editing by loading questions details into editable cells. Includes a search and replace feature.&lt;br /&gt;
&lt;br /&gt;
== Email plugins ==&lt;br /&gt;
&lt;br /&gt;
* [https://gitlab.com/SondagesPro/mailing/noMailToExample noMailToExample]&lt;br /&gt;
* [https://github.com/LimeSurvey/LimeSurvey/blob/develop/plugins/mailSenderToFrom/mailSenderToFrom.php mailSenderToFrom]&lt;br /&gt;
* [https://github.com/Xites/LS_mailDKIM mailDKIM]&lt;br /&gt;
* [https://github.com/Xites/LS_mailEmbedImages mailEmbedImages]&lt;br /&gt;
&lt;br /&gt;
== Other plugins ==&lt;br /&gt;
&lt;br /&gt;
* [http://extensions.sondages.pro/recomputeexpression-for-limesurvey Recompute Expressions:] A Plugin for LimeSurvey to recompute expression in survey with already submitted survey. Allow to update some relevance too.&lt;br /&gt;
* [https://git.framasoft.org/SondagePro-LimeSurvey-plugin/showAdvancedSettings showAdvancedSettings:] Show advanced settings in question edit by default.&lt;br /&gt;
* [https://git.framasoft.org/SondagePro-LimeSurvey-plugin/replaceRegister  replaceRegisterː] Extra option for Register, starting point for other plugin. &lt;br /&gt;
* [http://extensions.sondages.pro/fixmaxstep-for-question-index/ fixMaxStep : Fix question index for token answer persistence survey:] Example of usage : get the complete index when user come back to the survey.&lt;br /&gt;
* [http://extensions.sondages.pro/sendmailajax-all-email-in-one/ sendMailAjax : Send token email one by one with ajaxː] Allow to send all email in one click without restriction.&lt;br /&gt;
* [http://extensions.sondages.pro/mailing-management/sendmailcron sendMailCron: Automatically send invitations and reminders using cronjobsː] Automatically sends invitations and reminders in custom intervals. Extensive configuration and debugging options&lt;br /&gt;
* [https://github.com/SteveCohen/Piwik-for-Limesurvey Piwik-for-Limesurvey Piwik for LImesurveyː] Plugs Piwik into Limesurvey, so you can track your survey admin users and respondents.&lt;br /&gt;
* [https://github.com/SondagesPro/surveysModel Mark surveys as &amp;quot;Survey Model/Template&amp;quot;ː] Allow admins to mark a survey as &amp;quot;Survey Model&amp;quot;, a kind of &amp;quot;master survey&amp;quot; or &amp;quot;survey template&amp;quot; which only users with appropriate rights are allowed to edit. The common user is only allowed to create copies based on such a survey template.&lt;br /&gt;
* [https://github.com/SondagesPro/LS-toolsDomDocument toolsDomDocumentː] a tools for anothers plugin&lt;br /&gt;
* [https://github.com/TonisOrmisson/limesurvey-url-templates UrlTemplateChangerː] Set respondent&#039;s interview template over an URL parameter.&lt;br /&gt;
* [https://github.com/evently-nl/zesthook  ZestHookː] Makes it possible to send a Post request on every response submission. You can set the URL to post to, as well as several other options.&lt;br /&gt;
* [https://github.com/CEric-fr/limesurvey-rgpd Extension RGPD pour LimeSurvey] Each questionnaire owner is able to interact with these conditions of use via a new submenu added in the &amp;quot;questionnaire parameters&amp;quot; entitled: GDPR configuration.&lt;br /&gt;
&lt;br /&gt;
== Example and demo plugins ==&lt;br /&gt;
* [https://framagit.org/SondagePro-LimeSurvey-plugin/extendRemoteControl extendRemoteControl] : Show how to add function to [[RemoteControl_2_API]], show how to create a new admin page too (usage of public function actionIndex() )&lt;br /&gt;
&lt;br /&gt;
[[Category:Plugins]]&lt;/div&gt;</summary>
		<author><name>Holch</name></author>
	</entry>
	<entry>
		<id>https://www.limesurvey.org/manual/index.php?title=Workarounds:_Manipulating_a_survey_at_runtime_using_Javascript&amp;diff=64495</id>
		<title>Workarounds: Manipulating a survey at runtime using Javascript</title>
		<link rel="alternate" type="text/html" href="https://www.limesurvey.org/manual/index.php?title=Workarounds:_Manipulating_a_survey_at_runtime_using_Javascript&amp;diff=64495"/>
		<updated>2015-03-11T18:02:32Z</updated>

		<summary type="html">&lt;p&gt;Holch: /* Text input masks - second method */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
Often you want to manipulate certain elements of a survey at runtime. The only solution without touching the source code is to use JavaScript or jQuery which is shipped with LimeSurvey. Here are some examples to hide and style elements, validate user input or do calculations at runtime.&lt;br /&gt;
&lt;br /&gt;
Other workarounds can be found at&lt;br /&gt;
* [[Workarounds: Survey behaviour]]&lt;br /&gt;
* [[Workarounds: Question design, layout and templating]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;&amp;lt;center&amp;gt;&amp;lt;br /&amp;gt;&#039;&#039;&#039;Please keep in mind that these workarounds are not official LimeSurvey extensions - they are solutions that users have created for themselves.&amp;lt;br /&amp;gt;&amp;lt;span style=&#039;color:#EE0000,#FFFFFF&#039;&amp;gt;Therefore LimeSurvey can&#039;t offer guarantees or support for these solutions.&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;If you have questions, please contact the users that, thankfully, shared their solutions with the community.&#039;&#039;&#039;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;/center&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;Note:  Version 1.92 implements many new features that make some existing workarounds obsolete.  You can continue to use existing workarounds, but may want to consider switching over to using the new features (since those new features are officially supported, and the workarounds are not).  Please review below for details of which are no longer needed.&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;Also Note:  Version 1.92&#039;s Expression Manager (EM) may cause some of these work-arounds to fail.  Any custom javascript included as a .js file will be fine.  However, if you in-line your JavaScript code, you must make sure that you have a space after every opening (left) curly brace, and a space before every closing (right) curly brace.  Otherwise, EM will think that the content between the curly braces is something it should parse and understand.  I have fixed all of the work-arounds below that can be fixed (many did not follow those rules).  However, some will continue to break.  If a work-around contains a regular expression which contains curly braces (to indicate a range of repeats of a sub-expression), EM will try to process those curly braces, and thus break your regular expression.  Strategies to continue to support that work-around functionality are discussed below.&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=How to &#039;&#039;add&#039;&#039; a javascript workaround solution to this Wiki page?=&lt;br /&gt;
&lt;br /&gt;
Well, this is pretty easy. Click the edit icon and create your own headline within the javascript section starting with &amp;quot;&#039;&#039;&#039;!&#039;&#039;&#039;&amp;quot;. Then add a short note about the version you have used when creating your workaround, you can copy/paste this code snippet &amp;lt;nowiki&amp;gt;&#039;&#039;Tested with: (enter LimeSurvey version and maybe browser)&#039;&#039;&amp;lt;/nowiki&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Finally it&#039;s imported to mark all your code with code tags, other wise you might break this page.&lt;br /&gt;
*Start tag: &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
*End tag: &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=How to &#039;&#039;use&#039;&#039; Script (eg. JavaScript etc.) in LimeSurvey?=&lt;br /&gt;
&lt;br /&gt;
To use JavaScript within LimeSurvey, the XSS filter must be turned off and the code inserted in the source of a question or a group description.&lt;br /&gt;
*Go to Global settings --&amp;gt; Security and set &amp;quot;Filter HTML for XSS&amp;quot; to &amp;quot;Off&amp;quot;.&lt;br /&gt;
* [http://docs.limesurvey.org/tiki-index.php?page=Adding+A+Question Add a new question]&lt;br /&gt;
* Edit the question and click the &amp;quot;Source&amp;quot; button in the editor toolbar:&lt;br /&gt;
&lt;br /&gt;
   [[File:editor_1.gif]]&lt;br /&gt;
* Enter your script after the question text:&lt;br /&gt;
&lt;br /&gt;
   [[File:editor_2.gif]]&lt;br /&gt;
* Save the question&lt;br /&gt;
&lt;br /&gt;
A simple test to see if JavaScript is enabled is to echo an alert. Use this code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
   alert(&amp;quot;Test!&amp;quot;);&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is a good practice to use the jQuery $(document).ready function to prevent the code from executing until the page is fully loaded:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
       alert(&amp;quot;Test!&amp;quot;);&lt;br /&gt;
   });&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is also good practice to use jslint.com to get a good layout and design (e.q. no cluttering of name space)&lt;br /&gt;
&lt;br /&gt;
==Usage of brackets (&amp;lt;nowiki&amp;gt;{ and }&amp;lt;/nowiki&amp;gt;)==&lt;br /&gt;
{{Alert|title=Caution with bracket ( &amp;lt;nowiki&amp;gt;{ and }&amp;lt;/nowiki&amp;gt;)|text=[[Expression Manager#Syntax|Expression manager]] use bracket ( &amp;lt;nowiki&amp;gt;{ and }&amp;lt;/nowiki&amp;gt;) to enclose expression. Then if you have to use bracket in your javascript, you must add space or line feed after starting bracket (&amp;lt;nowiki&amp;gt;{&amp;lt;/nowiki&amp;gt;) and before closing bracket (&amp;lt;nowiki&amp;gt;}&amp;lt;/nowiki&amp;gt;) }}&lt;br /&gt;
&lt;br /&gt;
===Exemples of usage of brackets===&lt;br /&gt;
&lt;br /&gt;
Expression Manager try to parse the javascript : &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
   $(function() {console.log(&#039;broken javascript&#039;);});&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adding line feed and Expression Manager don&#039;t parse&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
   $(function() {&lt;br /&gt;
      console.log(&#039;Adding a line feed for javascript&#039;);&lt;br /&gt;
   });&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Expression Manager try to parse the javascript : &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
   if(myvar==1) {console.log(&#039;broken javascript&#039;);};&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adding line feed and Expression Manager don&#039;t parse&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
   if(myvar==1) { console.log(&#039;Adding a space for javascript&#039;); };&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Sum up input values using Javascript=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, this is easier to do using the sum() function in [[Expression Manager|Expression Manager]].  See this [[Expression Manager HowTos#Calculate assessment values at runtime and store the results in the survey data|HowTo example]].&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;Starting in  Version 1.92, you also do no longer need to use SGQA (e.g. 45251X1X5) identifiers. Instead the code &amp;lt;code&amp;gt;{SGQ}&amp;lt;/code&amp;gt; will automatically replaced by the current questions SGQA-codes.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is from a survey that is a invitation to a longer party, when the user clicks to the next page, the calculated results will be shown.&lt;br /&gt;
&lt;br /&gt;
If you wonder what the {INSERTANS:1X6X12} stuff is, look at [http://docs.limesurvey.org/tiki-index.php?page=SGQA+Identifier SGQA identifier] and [[Adding a question#Information from previous answers|Using information from previous answers]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;text-align: left&amp;quot;&amp;gt;These are your answers:&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;u&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;u&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;u&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;u&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;script LANGUAGE=&amp;quot;JavaScript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
partyprice = 3;&lt;br /&gt;
&lt;br /&gt;
beadclothprice = 3;&lt;br /&gt;
&lt;br /&gt;
breakfastprice = 7;&lt;br /&gt;
&lt;br /&gt;
lunchprice = 8;&lt;br /&gt;
&lt;br /&gt;
dinnerprice = 10;&lt;br /&gt;
&lt;br /&gt;
foodtotal = 0;&lt;br /&gt;
&lt;br /&gt;
var isreallytrue = &amp;quot;Yes&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
var noanswer = &amp;quot;No answer&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
document.write( &amp;quot;Can you come? = {INSERTANS:45251X1X1}&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
if (&amp;quot;{INSERTANS:45251X1X1}&amp;quot; == isreallytrue )&lt;br /&gt;
&lt;br /&gt;
  {&lt;br /&gt;
&lt;br /&gt;
   if (&amp;quot;{INSERTANS:45251X1X3}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
   else { answer = &amp;quot;{INSERTANS:45251X1X3}&amp;quot;; }&lt;br /&gt;
&lt;br /&gt;
   partypeople = parseInt(answer);&lt;br /&gt;
&lt;br /&gt;
   partytotal = partyprice * partypeople;&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;It&#039;s {INSERTANS:45251X1X3} persons who will come = &amp;quot; + partytotal + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   if (&amp;quot;{INSERTANS:45251X1X4}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
   else { answer = &amp;quot;{INSERTANS:45251X1X4}&amp;quot;;}&lt;br /&gt;
&lt;br /&gt;
   beadcloths = parseInt(answer);&lt;br /&gt;
&lt;br /&gt;
   beadclothtotal = beadclothprice * beadcloths;&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;You want to borrow {INSERTANS:45251X1X4} beadcloths = &amp;quot; + beadclothtotal + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;Will you be there thursday? = {INSERTANS:45251X1X5}&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;On friday you will have these meals: &amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   if (&amp;quot;{INSERTANS:45251X1X71}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
   else { answer = &amp;quot;{INSERTANS:45251X1X71}&amp;quot;;}&lt;br /&gt;
&lt;br /&gt;
   breakfastfriday = parseInt(answer) * breakfastprice;&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; breakfeasts = &amp;quot; + breakfastfriday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   if (&amp;quot;{INSERTANS:45251X1X72}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
   else { answer = &amp;quot;{INSERTANS:45251X1X72}&amp;quot;;}&lt;br /&gt;
&lt;br /&gt;
   lunchfriday = parseInt(answer) * lunchprice ;&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; lunches = &amp;quot; + lunchfriday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   if (&amp;quot;{INSERTANS:45251X1X73}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
   else { answer = &amp;quot;{INSERTANS:45251X1X73}&amp;quot;;}&lt;br /&gt;
&lt;br /&gt;
   dinnerfriday = parseInt(answer)* dinnerprice ;&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; dinners = &amp;quot; + dinnerfriday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   foodtotal = breakfastfriday + lunchfriday + dinnerfriday;&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;Will you be there saturday? = {INSERTANS:45251X1X8}&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   if (&amp;quot;{INSERTANS:45251X1X8}&amp;quot; == isreallytrue )&lt;br /&gt;
&lt;br /&gt;
      {&lt;br /&gt;
&lt;br /&gt;
       document.write( &amp;quot;On saturday you will have these meals: &amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
       if (&amp;quot;{INSERTANS:45251X1X91}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
       else { answer = &amp;quot;{INSERTANS:45251X1X91}&amp;quot;; }&lt;br /&gt;
&lt;br /&gt;
       breakfastsaturday = parseInt(answer) * breakfastprice ;&lt;br /&gt;
&lt;br /&gt;
       document.write(&amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; breakfeasts = &amp;quot; + breakfastsaturday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
       if (&amp;quot;{INSERTANS:45251X1X92}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
       else { answer = &amp;quot;{INSERTANS:45251X1X92}&amp;quot;; }&lt;br /&gt;
&lt;br /&gt;
       lunchsaturday = parseInt(answer) * lunchprice ;&lt;br /&gt;
&lt;br /&gt;
       document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; lunches = &amp;quot; + lunchsaturday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
       if (&amp;quot;{INSERTANS:45251X1X93}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
       else { answer = &amp;quot;{INSERTANS:45251X1X93}&amp;quot;; }&lt;br /&gt;
&lt;br /&gt;
       dinnersaturday = parseInt(answer) * dinnerprice ;&lt;br /&gt;
&lt;br /&gt;
       document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; dinners = &amp;quot; + dinnersaturday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
       foodtotal = foodtotal + breakfastsaturday + lunchsaturday + dinnersaturday;&lt;br /&gt;
&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;Will you be there sunday? = {INSERTANS:45251X1X10}&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   if (&amp;quot;{INSERTANS:45251X1X10}&amp;quot; == isreallytrue )&lt;br /&gt;
&lt;br /&gt;
      {&lt;br /&gt;
&lt;br /&gt;
       document.write( &amp;quot;On sunday you will have these meals: &amp;lt;br&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
       if (&amp;quot;{INSERTANS:45251X1X111}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
       else { answer = &amp;quot;{INSERTANS:45251X1X111}&amp;quot;; }&lt;br /&gt;
&lt;br /&gt;
       breakfastsunday = parseInt(answer) * breakfastprice ;&lt;br /&gt;
&lt;br /&gt;
       document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; breakfeasts = &amp;quot; + breakfastsunday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot;  );&lt;br /&gt;
&lt;br /&gt;
       if (&amp;quot;{INSERTANS:45251X1X112}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
       else { answer = &amp;quot;{INSERTANS:45251X1X112}&amp;quot;; }&lt;br /&gt;
&lt;br /&gt;
       lunchsunday = parseInt(answer) * lunchprice ;&lt;br /&gt;
&lt;br /&gt;
       document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; lunches = &amp;quot; + lunchsunday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
       if (&amp;quot;{INSERTANS:45251X1X113}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
       else { answer = &amp;quot;{INSERTANS:45251X1X113}&amp;quot;; }&lt;br /&gt;
&lt;br /&gt;
       dinnersunday = parseInt(answer) * dinnerprice ;&lt;br /&gt;
&lt;br /&gt;
       document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; dinners = &amp;quot; + dinnersunday + &amp;quot;&amp;amp;euro;&amp;lt;p&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
       foodtotal = foodtotal + breakfastsunday + lunchsunday + dinnersunday;&lt;br /&gt;
&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
   total = partytotal + beadclothtotal + foodtotal;&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;&amp;lt;h3&amp;gt;In total it will cost you &amp;quot; + total + &amp;quot;&amp;amp;euro;&amp;lt;/h3&amp;gt;&amp;lt;BR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   Put that sum in this bank account 1234 5678 9012&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/SCRIPT&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Multiple Question Validation=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, this is easier to do using the min/max/equals_num_value attributes (to validate sums), or the em_validation_q function, which lets you refer to other variables when you validate the current question [[Expression Manager|Expression Manager]].  Such validations also work on the current page, and properly handle array_filter and cascading relevance.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround is in case you need to do some validation involving more than one question, it implies a very little JavaScript programming and the use of SGQA Identifiers; this should work on almost any version of LimeSurvey.&lt;br /&gt;
&lt;br /&gt;
Is easy to explain with an example, we need to do a survey of the percentage of males and females and we want to be sure that the sum is 100, to do this follow this steps (the necessary data that is not indicated in these instructions are not important i.e. question codes, etc.):&lt;br /&gt;
#Create a new survey of type &amp;quot;group by group&amp;quot;, set the &amp;quot;Show |&amp;lt;&amp;lt; Prev| button&amp;quot; to yes and note the SID.&lt;br /&gt;
#Add a new group called &amp;quot;Group 1&amp;quot; and note the GID.&lt;br /&gt;
#Add a new question &amp;quot;Percent of males&amp;quot; of type &amp;quot;numeric&amp;quot;, make it mandatory and note the QID (we will refer to this as QID1).&lt;br /&gt;
#Add a new question &amp;quot;Percent of females&amp;quot; of type &amp;quot;numeric&amp;quot;, make it mandatory and note the QID (we will refer to this as QID2).&lt;br /&gt;
#Add a new group called &amp;quot;Group 2&amp;quot;&lt;br /&gt;
#Add a new non mandatory question, here is the trick the question text has to be (be sure to replace the SID, GID, QID1 and QID2&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
function validation()&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   if [[{INSERTANS:SIDXGIDXQID1}+{INSERTANS:SIDXGIDXQID2}) != 100)&lt;br /&gt;
&lt;br /&gt;
   {&lt;br /&gt;
&lt;br /&gt;
     alert(&amp;quot;Your responses don&#039;t sum 100! Check them&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
     document.limesurvey.move.value = &#039;moveprev&#039;;&lt;br /&gt;
&lt;br /&gt;
     document.limesurvey.submit();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   else&lt;br /&gt;
&lt;br /&gt;
   {&lt;br /&gt;
&lt;br /&gt;
     document.limesurvey.move.value = &#039;movelast&#039;;&lt;br /&gt;
&lt;br /&gt;
     document.limesurvey.submit();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 setTimeout(&amp;quot;validation()&amp;quot;,250);&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But this will show shortly the question and will jump to the end page, a little weird for the survey taker but works.&lt;br /&gt;
&lt;br /&gt;
This is a proof of concept, and may have some problems, please if you notice something or improve it send me an e-mail to leochaton-limesurvey at yahoo dot com.&lt;br /&gt;
&lt;br /&gt;
This will work for 2 questions that you want to be the same.  Works well for email and confirm email questions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 function validation() {&lt;br /&gt;
&lt;br /&gt;
 if (&amp;quot;{INSERTANS:SIDXGIDXQID}&amp;quot; != &amp;quot;{INSERTANS:SIDXGIDXQID}&amp;quot;) {&lt;br /&gt;
&lt;br /&gt;
    alert(&amp;quot;Your responses don&#039;t match Check them&amp;quot;); document.limesurvey.move.value = &#039;moveprev&#039;;&lt;br /&gt;
&lt;br /&gt;
    document.limesurvey.submit();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 setTimeout(&amp;quot;validation()&amp;quot;,250);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Alternate exit=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Using the same idea of the previous post, you can implement an alternate exit of your survey.&lt;br /&gt;
&lt;br /&gt;
This script should be in the first question to be displayed in a next page after the question that should trigger the alternate exit. In this example the question that trigger the alternate exit is a Yes/No question, if the user chooses no, he is redirected to another page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if (&amp;quot;{INSERTANS:SIDXGIDXQID}&amp;quot; == &amp;quot;No&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
  window.location=&amp;quot;http://www.limesurvey.org&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Custom onload function=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: &#039;All browsers&#039;, LimeSurvey 1.70 and up&lt;br /&gt;
&lt;br /&gt;
==General==&lt;br /&gt;
&lt;br /&gt;
This simple workaround describes how to &#039;&#039;&#039;add a custom Javascript code&#039;&#039;&#039; that is triggered right after the page is loaded. It may have numerous applications, especially when you deal with a custom JS/HTML code. It may be used to hide form elements (&amp;lt;input&amp;gt;  tags), make them read-only, display alert messages, etc.&lt;br /&gt;
&lt;br /&gt;
To run any Javascript code right after page load use the Query ready() function. It will be executed when the page is being loaded. For example when you add the following code to one of your question definitions...:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
jQuery(document).ready(&lt;br /&gt;
&lt;br /&gt;
   function(){&lt;br /&gt;
&lt;br /&gt;
       alert(&#039;onload alert!&#039;);&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
...it will display a pop-up message immediately after the page has been loaded.&lt;br /&gt;
&lt;br /&gt;
Some of the applications of this trick I&#039;ve explored are:&lt;br /&gt;
&lt;br /&gt;
a) Hiding the form elements by calling in your Custom_On_Load:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;document.getElementById(&amp;quot;answer73166X16X54&amp;quot;).style.display=&#039;none&#039;;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: As of svn build 9755, you can now dynamically reference the questions input fields by using the {SGQ} keyword. You can rewrite the previous example like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;document.getElementById(&amp;quot;answer{SGQ}&amp;quot;).style.display=&#039;none&#039;;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
this makes it a little easier when exporting surveys, so you don&#039;t have to worry about manually entering each questions SurveyGroupQuestion ID.&lt;br /&gt;
&lt;br /&gt;
b) Making the elements read only:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;document.getElementById(&amp;quot;answer73166X16X54&amp;quot;).readOnly=true;&amp;lt;/syntaxhighlight&amp;gt; where the &amp;quot;answer73166X16X54&amp;quot; structure has been described in one of other workarounds above.&lt;br /&gt;
&lt;br /&gt;
c) For Hiding by a lot of elements by calling in your Customer_On_Load&lt;br /&gt;
&lt;br /&gt;
jQuery searchs in html document for input-fields with radio type, if his answer text empty then do the display css set to none.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
jQuery(document).ready(&lt;br /&gt;
&lt;br /&gt;
           function() {&lt;br /&gt;
&lt;br /&gt;
             jQuery(&#039;input:radio&#039;).each(&lt;br /&gt;
&lt;br /&gt;
               function() {&lt;br /&gt;
&lt;br /&gt;
                 var s = jQuery(this);&lt;br /&gt;
&lt;br /&gt;
                 var c = s.parent().children(&#039;.answertext&#039;);&lt;br /&gt;
&lt;br /&gt;
                 for(var i=0; i &amp;lt; c.length; i++) {&lt;br /&gt;
&lt;br /&gt;
                   var a = jQuery(c[i]]);&lt;br /&gt;
&lt;br /&gt;
                   if(this.id &amp;lt;/u&amp;gt; a.attr(&#039;for&#039;) &amp;amp;&amp;amp; a.text() == &#039;&#039;) {&lt;br /&gt;
&lt;br /&gt;
                     s.css({ &#039;display&#039; : &#039;none&#039; });&lt;br /&gt;
&lt;br /&gt;
                     a.css({ &#039;display&#039; : &#039;none&#039; });&lt;br /&gt;
&lt;br /&gt;
                     break;&lt;br /&gt;
&lt;br /&gt;
                   }&lt;br /&gt;
&lt;br /&gt;
                 }&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
             )&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
         );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Advanced usage==&lt;br /&gt;
&lt;br /&gt;
If you want to place global Javascript code using the above jQuery(document).ready function then the best place to do this is the template javascript file template.js. You can edit this file using the template editor. Please be aware that placing it in the template javascript file will make the function available to all surveys using that template. If needed just create a new template copy for your survey.&lt;br /&gt;
&lt;br /&gt;
Alternatively you can place the jQuery(document).ready function in the group description to make a Javascript function only available to a certain question group.&lt;br /&gt;
&lt;br /&gt;
==Language-specific Javascript code==&lt;br /&gt;
&lt;br /&gt;
There is an easy way to find out the current language and execute according Javascript using jQuery: The &amp;lt;html&amp;gt; tag of any survey pages contains an &#039;lang&#039; attribute which holds the current language code. You can read that language code by using the followin code&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
jQuery(document).ready(&lt;br /&gt;
&lt;br /&gt;
   function(){&lt;br /&gt;
&lt;br /&gt;
       languagecode=$(&#039;html&#039;).attr(&#039;lang&#039;);&lt;br /&gt;
&lt;br /&gt;
       alert(&#039;This is the current language code: &#039;+languagecode);&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For an English survey the above code would show a messagebox with &amp;quot;This is the current language code: en&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=Custom onload function in multi-language survey=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.85+ (7253), IE 6/7, FireFox 3.0, Safari 3.2,&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
To use custom onload functions, as above, in multi-language surveys you must define the functions in the question source for &#039;&#039;&#039;all&#039;&#039;&#039; languages.&lt;br /&gt;
&lt;br /&gt;
While this initially seems to be a bit tedious, it actually can be useful - you can alter your onload functions depending on the language in use. For example, you can dynamically display alerts or element contents in the current language.&lt;br /&gt;
&lt;br /&gt;
=Skipping the welcome page=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.85 (second code snippet)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;Note: As of version 1.91, there is a survey option letting you skip the welcome page, so this workaround is not needed.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solution 1:&#039;&#039;&#039; Include this Javascript in your welcome template, in the file welcome.pstpl for all welcome page, or in the source of the welcome text for one survey:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
jQuery(document).ready(function($) {&lt;br /&gt;
&lt;br /&gt;
document.limesurvey.move.value = &#039;movenext&#039;;&lt;br /&gt;
&lt;br /&gt;
document.limesurvey.submit(); });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It will reproduce the onclick event of the submit button and submit the form.&lt;br /&gt;
&lt;br /&gt;
Drawback of course is that users will see the page flashing up.&lt;br /&gt;
&lt;br /&gt;
Therefore, you may want to announce &amp;quot;... loading survey ...&amp;quot; as a description of your welcome page (in the admin interface when creating the survey), to pretend loading something big.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solution 2:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
function custom_on_load(){&lt;br /&gt;
&lt;br /&gt;
  document.limesurvey.move.value = &#039;movenext&#039;;&lt;br /&gt;
&lt;br /&gt;
  document.limesurvey.submit();&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
window.setTimeout( &#039;custom_on_load()&#039;,1);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Filter answers of a question with the answer of another=&lt;br /&gt;
&lt;br /&gt;
===Method 1===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.70 - 1.72&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, this is easier to do using the the array_filter attribute, or relevance equations in general.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to filter the answer of a question with another answer, you can use this workaround.&lt;br /&gt;
&lt;br /&gt;
First, use answer code like that: XX for the first question, and XXYYY for the second one.&lt;br /&gt;
&lt;br /&gt;
Answer of the second question filter if the 2 first letters are the answer of the first question.&lt;br /&gt;
&lt;br /&gt;
We use 1000X1X1 and 1000X1X2 for the example, question had to be on separate page (question by question for example).The second question had to be a dropdown list (we can do similar workaround, but droplis is the best). You can do this using JQuery.  It leaves the answer in the select box, but disables it.  You could also replace &amp;quot;disable&amp;quot; with &amp;quot;remove&amp;quot; to get rid of it altogether.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
var previousQuestionAnswer = &amp;quot;{INSERTANS:1000X1X1}&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
var currentQuestionID = &amp;quot;#answer1000X1X1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
   // See if the answer for the previous question matches an answer in the current question&lt;br /&gt;
&lt;br /&gt;
   // (other than &#039;No Answer&#039;)&lt;br /&gt;
&lt;br /&gt;
   // If so, disable it.&lt;br /&gt;
&lt;br /&gt;
   if (previousQuestionAnswer!=&#039;No Answer&#039;) {&lt;br /&gt;
&lt;br /&gt;
       $(currentQuestionID).children().each(function(index, Element)&lt;br /&gt;
&lt;br /&gt;
       {&lt;br /&gt;
&lt;br /&gt;
           if ($(this).attr(&#039;text&#039;) == previousQuestionAnswer)&lt;br /&gt;
&lt;br /&gt;
               { $(this).attr(&#039;disabled&#039;, true); }&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       );}&lt;br /&gt;
&lt;br /&gt;
}); // End of JQuery ready function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Method 2===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with 1.92 + Firefox 9.0&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you have a country, state, and city set of questions (or similar), you could code answer options as:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Q1 Country&#039;&#039;&#039; &#039;&#039;Single choice list (ratio, dropdown)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
X country#&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Q2 State&#039;&#039;&#039; &#039;&#039;Single choice list (dropdown)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
XY state#&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Q3 City&#039;&#039;&#039; &#039;&#039;Single choice list (dropdown)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
XYZZ city#&lt;br /&gt;
&lt;br /&gt;
Now you must put the following Javascript code in the source of question 2 (State):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Get the countryCode (first character of the country)&lt;br /&gt;
       var countryCode = &#039;{INSERTANS:1000X1X1}&#039;.substr(0, 1).toUpperCase();&lt;br /&gt;
&lt;br /&gt;
       // Loop through all dropdown options and remove those with codes not starting with the countryCode&lt;br /&gt;
       $(&#039;select[id^=&amp;quot;answer&amp;quot;] option&#039;).each(function(i){&lt;br /&gt;
&lt;br /&gt;
           if($(this).attr(&#039;value&#039;)  &amp;amp;&amp;amp; $(this).attr(&#039;value&#039;).substr(0, 1).toUpperCase() != countryCode) {&lt;br /&gt;
               $(this).remove();&lt;br /&gt;
           }&lt;br /&gt;
       });&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And the following code in the source of question 3 (City):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Get the stateCode (two first characters of the state)&lt;br /&gt;
&lt;br /&gt;
       var stateCode = &#039;{INSERTANS:1000X1X2}&#039;.substr(0, 2).toUpperCase();&lt;br /&gt;
&lt;br /&gt;
       // Loop through all dropdown options and remove those with codes not starting with the stateCode&lt;br /&gt;
&lt;br /&gt;
       $(&#039;select[id^=&amp;quot;answer&amp;quot;] option&#039;).each(function(i){&lt;br /&gt;
&lt;br /&gt;
           if($(this).attr(&#039;value&#039;)  &amp;amp;&amp;amp; $(this).attr(&#039;value&#039;).substr(0, 2).toUpperCase() != stateCode) {&lt;br /&gt;
&lt;br /&gt;
               $(this).remove();&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each question must be in different pages of survey to work, i.e. in a question by question survey, or in diferent groups in a group by group survey.&lt;br /&gt;
&lt;br /&gt;
Note that if you choose a two characters answer option code in the State question, i.e. a XYY answer option code, you must change the &#039;&#039;substr(0, 2)&#039;&#039; part of code in question 3 to &#039;&#039;substr(0, 3)&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=Filter answers of a multiple numeric type question=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, this is easier to do using the the array_filter attribute, or relevance equations in general.  In 1.92, array_filter works with all questions that have sub-questions (e.g. also works for multiple numeric and multiple short text).&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to filter a question of type &amp;quot;multiple numeric&amp;quot;, you have to modify the workaround.&lt;br /&gt;
&lt;br /&gt;
Note that this workaround assumes that the code for each of the subquestions are a numeric sequence 1,2,3...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 $(document).ready(function(){&lt;br /&gt;
&lt;br /&gt;
   // Match elements with labels using htmlFor and a loop&lt;br /&gt;
&lt;br /&gt;
   var labels = document.getElementsByTagName(&#039;LABEL&#039;);&lt;br /&gt;
&lt;br /&gt;
   for (var i = 0; i &amp;lt; labels.length; i++) {&lt;br /&gt;
&lt;br /&gt;
       if (labels[i].htmlFor != &#039;&#039;) {&lt;br /&gt;
&lt;br /&gt;
            var elem = document.getElementById(labels[i].htmlFor);&lt;br /&gt;
&lt;br /&gt;
            if (elem)&lt;br /&gt;
&lt;br /&gt;
               elem.label = labels[i];&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   var answerFilter=&amp;quot;{INSERTANS:96553X63X759}&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
   for (i=0; i&amp;lt;30; i++){&lt;br /&gt;
&lt;br /&gt;
     var iLabel = document.getElementById(&#039;answer96553X63X760&#039;+(i+1]].label.innerHTML;&lt;br /&gt;
&lt;br /&gt;
     if (answerFilter.search(iLabel) == -1){&lt;br /&gt;
&lt;br /&gt;
       // Hide element&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question760&#039;).find(&#039;li&#039;).eq(i).hide();&lt;br /&gt;
&lt;br /&gt;
       // Set value of hidden elements to zero&lt;br /&gt;
&lt;br /&gt;
       document.getElementById(&#039;answer96553X63X760&#039;+(i+1)).value = 0;&lt;br /&gt;
&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
 });&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Use an answer to prefill another question (default value)=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.72&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;And tested with: 1.91+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, this is easier to do using the enhanced defaults feature, which lets you pre-fill most question types with default values.  In 1.91, you could set defaults for list and multiple choice questions.  In 1.92, you can set defaults for any text-entry question too.  Moreover, the defaults can be [[Expression Manager|Expression Manager]] compatible equations or tailored text.  Finally, with 1.92, defaults are properly managed even when set on the same page.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround gives you the ablility to use an answer to fill the default value for another question. It&#039;s explained for free text question type but can be adapted for another question type.&lt;br /&gt;
&lt;br /&gt;
We use SGQA identifier. For example, we use SGQA 1000X10X20 and 1000X10X21 to prefill 1000X11X30 and 1000X11X31. For the script to work, the question has to be on a different page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
 $(&#039;#answer1000X11X30&#039;).val(&#039;{INSERTANS:1000X10X20}&#039;);&lt;br /&gt;
&lt;br /&gt;
 $(&#039;#answer1000X11X31&#039;).val(&#039;{INSERTANS:1000X10X21}&#039;);&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want use two times the value of an integer input, you can also use this to prefill a question that you hide via CSS.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
 $(&#039;#answer1000X2X2&#039;).val(parseInt(&#039;{INSERTANS:1000X1X1}&#039;)*2);&lt;br /&gt;
&lt;br /&gt;
 $(&amp;quot;#question2&amp;quot;).hide();&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you can use {INSERTANS:1000X2X2} for giving you twice the value of the user input from question 1.&lt;br /&gt;
&lt;br /&gt;
=Dynamic Sum=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, this is easier to do with [[Expression Manager|Expression Manager]] using the sum() function.  Not only will sums be dynamic, but they wille exclude irrelevant values, so you can array_filter a multiple numeric question and get the sum of just the answers that are visible.  This [[Expression Manager HowTos#Calculate assessment values at runtime and store the results in the survey data|HowTo example]] demonstrates the dynamic sum feature.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;Also note, as of version 1.92, the following workaround will fail, since it includes a a regular expression containing curly braces.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This script is used with a &amp;quot;Multiple Options&amp;quot; type question calculate a total price based on how which checkboxes are selected. The prices are listed as part of the answer. The answers are set up like this: &amp;quot;USB Mouse ($20)&amp;quot;. The script uses the number between the &amp;quot;($&amp;quot; and the &amp;quot;)&amp;quot; as the price for that item. You can adapt the script to if you need to change the currency or need to sum something other than money.&lt;br /&gt;
&lt;br /&gt;
This script works when used in a question-by-question format.  It does not work when there are more than one question on a page. I think it can be adapted to work, but I haven&#039;t done the coding yet.&lt;br /&gt;
&lt;br /&gt;
Put the following code into body of your question:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script language=Javascript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// General definitions&lt;br /&gt;
&lt;br /&gt;
// Define a regular expression to match the labels containing information about an answer&lt;br /&gt;
&lt;br /&gt;
// In LimeSurvey, these labels start with &amp;quot;answer...&amp;quot;&lt;br /&gt;
&lt;br /&gt;
var answerRegex = /^answer/;&lt;br /&gt;
&lt;br /&gt;
// Find all answer checkboxes in the document and set their&lt;br /&gt;
&lt;br /&gt;
// onchange events to updatePrice&lt;br /&gt;
&lt;br /&gt;
function Custom_On_Load()&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   // Find all input elements&lt;br /&gt;
&lt;br /&gt;
   var inputList=document.getElementsByTagName(&amp;quot;input&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
   // Loop through each, looking for checkboxes&lt;br /&gt;
&lt;br /&gt;
   var i;&lt;br /&gt;
&lt;br /&gt;
   for( i=0; i&amp;lt; inputList.length;i++ )&lt;br /&gt;
&lt;br /&gt;
   {&lt;br /&gt;
&lt;br /&gt;
       // If input item does not have an ID, skip&lt;br /&gt;
&lt;br /&gt;
       if (! (inputList[i].id)) { continue; }&lt;br /&gt;
&lt;br /&gt;
       // Skip to next if ID doesn&#039;t start with &amp;quot;answer&amp;quot;&lt;br /&gt;
&lt;br /&gt;
       if (!answerRegex.test(inputList[i].id)) { continue; }&lt;br /&gt;
&lt;br /&gt;
       // Skip to next if not a checkbox&lt;br /&gt;
&lt;br /&gt;
       if (inputList[i].type.toUpperCase()!=&#039;CHECKBOX&#039;)  { continue; }&lt;br /&gt;
&lt;br /&gt;
       // This is an answer checkbox!&lt;br /&gt;
&lt;br /&gt;
       // Setup onchange event&lt;br /&gt;
&lt;br /&gt;
       inputList[i].onclick = updatePrice;&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
       // Load initial sum&lt;br /&gt;
&lt;br /&gt;
   updatePrice();&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function updatePrice()&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
var labels=document.getElementsByTagName(&amp;quot;LABEL&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
// Define a regular expression to match a price inside parenthesis&lt;br /&gt;
&lt;br /&gt;
// For example: ($29) or ($29.54).&lt;br /&gt;
&lt;br /&gt;
// Set up&lt;br /&gt;
&lt;br /&gt;
priceRegex = /\(\$(\d*\.{0,1}\d+)\)/;&lt;br /&gt;
&lt;br /&gt;
// Loop through all the labels, looking for labels corresponding to&lt;br /&gt;
&lt;br /&gt;
// answers that have a price in them.&lt;br /&gt;
&lt;br /&gt;
var i;&lt;br /&gt;
&lt;br /&gt;
var total = 0;&lt;br /&gt;
&lt;br /&gt;
for( i=0; i&amp;lt;labels.length;i++ )&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   var myArray;    // Define array used for regex matching&lt;br /&gt;
&lt;br /&gt;
   var inputID;    // Define field element&lt;br /&gt;
&lt;br /&gt;
   // Get the ID of the field corresponding to the label using the&lt;br /&gt;
&lt;br /&gt;
   // &amp;quot;htmlFor&amp;quot; attribute&lt;br /&gt;
&lt;br /&gt;
   // (FYI, there are some labels that will have to be screened out&lt;br /&gt;
&lt;br /&gt;
   // because they don&#039;t correspond to an answer)&lt;br /&gt;
&lt;br /&gt;
   // Does the label start with &amp;quot;answer&amp;quot;?&lt;br /&gt;
&lt;br /&gt;
   // If not: exit.&lt;br /&gt;
&lt;br /&gt;
   if (!answerRegex.test(labels[i].htmlFor)) { continue; }&lt;br /&gt;
&lt;br /&gt;
   // First make sure this element exists&lt;br /&gt;
&lt;br /&gt;
   // If it doesn&#039;t, go to the next element&lt;br /&gt;
&lt;br /&gt;
   // If it does, it will be defined in inputID&lt;br /&gt;
&lt;br /&gt;
   if (! (inputID = document.getElementById(labels[i].htmlFor)) ) { continue; }&lt;br /&gt;
&lt;br /&gt;
   // See if the corresponding answer is a checkbox that is checked.&lt;br /&gt;
&lt;br /&gt;
   // If not, go to next label&lt;br /&gt;
&lt;br /&gt;
   if (inputID.type.toUpperCase()!=&#039;CHECKBOX&#039;)  { continue; }&lt;br /&gt;
&lt;br /&gt;
   if (!inputID.checked) { continue; }&lt;br /&gt;
&lt;br /&gt;
   // This is label for an answer.&lt;br /&gt;
&lt;br /&gt;
   // The innerHTML will give us the text of the label&lt;br /&gt;
&lt;br /&gt;
   // The price information will be in the form ($XX.XX)&lt;br /&gt;
&lt;br /&gt;
   // which in contained in the label text.&lt;br /&gt;
&lt;br /&gt;
   // Find a match for a decimal number inside the pattern &amp;quot;($&amp;quot; and &amp;quot;)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   if [[myArray = priceRegex.exec(labels[i].innerHTML]] != null)&lt;br /&gt;
&lt;br /&gt;
   {&lt;br /&gt;
&lt;br /&gt;
       // Keep a running tally&lt;br /&gt;
&lt;br /&gt;
       total += parseFloat(myArray[1]);&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
  // Update total price on form&lt;br /&gt;
&lt;br /&gt;
  document.getElementById(&amp;quot;totalPrice&amp;quot;).value = &amp;quot;$&amp;quot; + formatCurrency(total);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function formatCurrency(num) {&lt;br /&gt;
&lt;br /&gt;
  num = isNaN(num) || num &amp;lt;u&amp;gt; &#039;&#039; || num &amp;lt;/u&amp;gt; null ? 0.00 : num;&lt;br /&gt;
&lt;br /&gt;
  return parseFloat(num).toFixed(2);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Put the following code in the help section (or wherever you want the sum to appear):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;Total Cost for selected accessories: &amp;lt;input type=&amp;quot;readonly&amp;quot; value=&amp;quot;&amp;quot; id=&amp;quot;totalPrice&amp;quot; /&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Focus on the first Input field=&lt;br /&gt;
&lt;br /&gt;
(&#039;&#039;Tested with: LimeSurvey 1.80 / IE6/7, Firefox 3, Safari, Opera, chrome&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.91, there is a built-in JavaScript function called  focusFirst() to focus on the first visible element.  It uses jQuery, so is more robust than this example.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again an onload Function is needed for this tasks. I have done it the DOM way with compatibility to IE6/7.&lt;br /&gt;
&lt;br /&gt;
Put the following code into the startpage.pstpl of your template, right before the &amp;lt;/head&amp;gt; closing tag:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   function focusFirst(Event)&lt;br /&gt;
&lt;br /&gt;
   {&lt;br /&gt;
&lt;br /&gt;
       var i=0;&lt;br /&gt;
&lt;br /&gt;
       while(document.forms[0].elements[i].type == &amp;quot;hidden&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
       {&lt;br /&gt;
&lt;br /&gt;
           i++;&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       document.forms[0].elements[i].focus();&lt;br /&gt;
&lt;br /&gt;
       return;&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   if(ie)&lt;br /&gt;
&lt;br /&gt;
   { window.attachEvent(&amp;quot;onload&amp;quot;, focusFirst); }&lt;br /&gt;
&lt;br /&gt;
   else&lt;br /&gt;
&lt;br /&gt;
   { document.addEventListener(&amp;quot;load&amp;quot;, focusFirst, true); }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; I am using this with version 1.80. As changes happened to the templates in the last release, you might need to add the following before the code, if your template is older than 1.80 stable and does not include this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   var ie = false;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will need this for the var ie to be set. Without this var, the function will not work with ie.&lt;br /&gt;
&lt;br /&gt;
=Answer questions by keypress=&lt;br /&gt;
&lt;br /&gt;
(&#039;&#039;Tested with: IE7, Firefox 3&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
This workaround allow to answer the question on key 0-9 (0 is for the 10 answer).&lt;br /&gt;
&lt;br /&gt;
Follow issues are supported at the moment:&lt;br /&gt;
*Yes-No Questions&lt;br /&gt;
*List Questions (radio)&lt;br /&gt;
*other radio questions&lt;br /&gt;
&lt;br /&gt;
In lists the answer limit is ten.&lt;br /&gt;
&lt;br /&gt;
You supply the template &amp;quot;endpage&amp;quot; of your template with the following script.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
jQuery(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
   jQuery(document).bind(&#039;keypress&#039;, function(e){&lt;br /&gt;
&lt;br /&gt;
       if (48 &amp;lt;= e.which &amp;amp;&amp;amp; e.which &amp;lt;= 57) {&lt;br /&gt;
&lt;br /&gt;
           jQuery(&#039;input:radio&#039;).each(function() {&lt;br /&gt;
&lt;br /&gt;
               var v = jQuery(this).val();&lt;br /&gt;
&lt;br /&gt;
               var c = (e.which &amp;lt;u&amp;gt; 48) ? 10 : e.which - 48;&lt;br /&gt;
&lt;br /&gt;
               if(v &amp;lt;/u&amp;gt; &#039;Y&#039; || v &amp;lt;u&amp;gt; &#039;N&#039;) {&lt;br /&gt;
&lt;br /&gt;
                   v = (v &amp;lt;/u&amp;gt; &#039;Y&#039;) ? 1 : 2;&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               if(v == c) {&lt;br /&gt;
&lt;br /&gt;
                   jQuery(this).click();&lt;br /&gt;
&lt;br /&gt;
                   jQuery(&#039;#limesurvey input:submit&#039;).click();&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   })&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Math notation in LimeSurvey=&lt;br /&gt;
#download the js file from [http://mathcs.chapman.edu/~jipsen/mathml/asciimathdownload.html AsciiMath script]&lt;br /&gt;
#copy it in the /scripts/ folder in your installation&lt;br /&gt;
#modify the startpage.psptl of the template you want to use adding the reference to the script (if you use an older version make sure that you copy the template folder first!) for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;ASCIIMathML.js&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the notation where you need it!&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; If you use internet explorer or safari you will need to download the plugin as well, but firefox does the lot for you.&lt;br /&gt;
&lt;br /&gt;
Finally, if you are confident with the limesurvey structure you could add the editor which support math notation and change the reference to the editor you want to use in the configuration file. here is the [http://www.imathas.com/editordemo/demo.html link for a TinyMCE with math support].&lt;br /&gt;
&lt;br /&gt;
=Reverse array_filter (for pre-1.90)=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.85+ (7253), IE 6/7, FireFox 3.0, Safari 3.2, Chrome 2.0&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;Note: Version 1.91 natively supports this functionality via the array_filter_exclude advanced quation option.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This can be used to filter the answers of an array question to be displayed based on the answers of a multi option question that were &#039;&#039;&#039;NOT&#039;&#039;&#039; selected. A possible application would be to have a multi-option question asking which products were purchased, followed by 2 array questions - one asking to rate the purchased products and another asking why the remaining products were not purchased. Another would be to ask about sessions attended at a conference as in [http://www.limesurvey.org/en/forum/5-can-i-do-this-with-limesurvey/27970-reverse-of-arrayfilter.html this forum thread] and pictured below. There is a live [http://www.partnersinc.biz/surveys//index.php?sid=43358&amp;amp;newtest=Y&amp;amp;lang=en demo here]&lt;br /&gt;
&lt;br /&gt;
[[File:sessions_645x344.gif]]&lt;br /&gt;
&lt;br /&gt;
We&#039;ll use the above example to explain the process as follows:&lt;br /&gt;
#In group 1 - Create a &#039;&#039;SessionsAttended&#039;&#039; multi-options question&lt;br /&gt;
#In group 1 - Create a &#039;&#039;SessionsNotAttended&#039;&#039; multi-options question with identical answers as &#039;&#039;SessionsAttended&#039;&#039; and hide it with styles or conditions&lt;br /&gt;
#In group 2 - Create a &#039;&#039;RateSessionsAttended&#039;&#039; array question with an [http://docs.limesurvey.org/tiki-index.php?page=Question+attributes&amp;amp;structure;=English+Instructions+for+LimeSurvey#array_filter array_filter] based on &#039;&#039;SessionsAttended&#039;&#039;&lt;br /&gt;
#In group 2 - Create a &#039;&#039;ReasonNotAttended&#039;&#039; array question with an [http://docs.limesurvey.org/tiki-index.php?page=Question+attributes&amp;amp;structure;=English+Instructions+for+LimeSurvey#array_filter array_filter] based on &#039;&#039;SessionsNotAttended&#039;&#039;&lt;br /&gt;
#In group 1 - Place JavaScript/jQeury listeners on each of the checkboxes in &#039;&#039;SessionsAttended&#039;&#039; that would toggle the corresponding checkbox in &#039;&#039;SessionsNotAttended&#039;&#039; to the opposite state&lt;br /&gt;
&lt;br /&gt;
The JavaScript/jQuery code used would be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
       // The toggle function&lt;br /&gt;
&lt;br /&gt;
   function toggle(q1, q2) {&lt;br /&gt;
&lt;br /&gt;
       if ($(q1).attr(&#039;checked&#039;) == false ) {&lt;br /&gt;
&lt;br /&gt;
           $(q2).attr(&#039;checked&#039;, true);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       else {&lt;br /&gt;
&lt;br /&gt;
           $(q2).attr(&#039;checked&#039;, false);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   // Initialize the SessionNotAttended checkboxes to &amp;quot;checked&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   toggle (&#039;#answer11111X22X331&#039;, &#039;#answer11111X22X441&#039;);&lt;br /&gt;
&lt;br /&gt;
   toggle (&#039;#answer11111X22X332&#039;, &#039;#answer11111X22X442&#039;);&lt;br /&gt;
&lt;br /&gt;
   toggle (&#039;#answer11111X22X333&#039;, &#039;#answer11111X22X443&#039;);&lt;br /&gt;
&lt;br /&gt;
   toggle (&#039;#answer11111X22X334&#039;, &#039;#answer11111X22X444&#039;);&lt;br /&gt;
&lt;br /&gt;
   // The jQuery listeners on the SessionAttended checkboxes&lt;br /&gt;
&lt;br /&gt;
   // that toggle the SessionNotAttended checkboxes&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#answer11111X22X331&#039;).change(function() {&lt;br /&gt;
&lt;br /&gt;
       toggle (&#039;#answer11111X22X331&#039;, &#039;#answer11111X22X441&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#answer11111X22X332&#039;).change(function() {&lt;br /&gt;
&lt;br /&gt;
       toggle (&#039;#answer11111X22X332&#039;, &#039;#answer11111X22X442&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#answer11111X22X333&#039;).change(function() {&lt;br /&gt;
&lt;br /&gt;
       toggle (&#039;#answer11111X22X333&#039;, &#039;#answer11111X22X443&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#answer11111X22X334&#039;).change(function() {&lt;br /&gt;
&lt;br /&gt;
       toggle (&#039;#answer11111X22X334&#039;, &#039;#answer11111X22X444&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some notes about the code:&lt;br /&gt;
*The code is in an onload function defined in the first question of group 1 - see [[Workarounds#Custom_onload_function|here]]&lt;br /&gt;
*Both &#039;&#039;SessionsAttended&#039;&#039; and &#039;&#039;SessionsNotAttended&#039;&#039; must be in the same group for the toggling to work&lt;br /&gt;
*This case only uses 4 checkboxes but could be expanded as required&lt;br /&gt;
*In this case the survey ID is 11111, the group ID is 22, &#039;&#039;SessionsAttended&#039;&#039; ID is 33 and SessionsNotAttended ID is 44 - these would need to be modified for your survey&lt;br /&gt;
*The toggle function looks for the state of a checkbox in &#039;&#039;SessionsAttended&#039;&#039; and sets the corresponding checkbox in &#039;&#039;SessionsNotAttended&#039;&#039; to the opposite state&lt;br /&gt;
*The &amp;quot;Initialize&amp;quot; section sets the state of &#039;&#039;SessionsNotAttended&#039;&#039; checkboxes whenever we navigate to the group&lt;br /&gt;
*The &amp;quot;Listener&amp;quot; section uses jQuery listeners to detect any change in the &#039;&#039;SessionsAttended&#039;&#039; checkboxes and then toggle the corresponding &#039;&#039;SessionsNotAttended&#039;&#039; checkbox&lt;br /&gt;
&lt;br /&gt;
Some general notes about the questions:&lt;br /&gt;
*CSS can be used to hide &#039;&#039;SessionsNotAttended&#039;&#039; (div#question44 { display: none; }) if you don&#039;t want to use conditions (because maybe you&#039;ve got [[Optional settings#Survey Behavior|$deletenonvalues set to 1]])&lt;br /&gt;
*&#039;&#039;RateSessionsAttended&#039;&#039; and &#039;&#039;ReasonNotAttended&#039;&#039; are another group to avoid things popping in and out of existence as &#039;&#039;SessionsAttended&#039;&#039; is answered&lt;br /&gt;
*[[Setting conditions|Conditions]] are used to ensure that &#039;&#039;RateSessionsAttended&#039;&#039; only appears if some sessions are selected and &#039;&#039;ReasonNotAttended&#039;&#039; only appears if no sessions are selected&lt;br /&gt;
&lt;br /&gt;
=Filter Ranking Question With Multiple-Options (pre 1.92)=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90, IE 7/8, FireFox 3/4, Safari 5.0, Chrome 10.0&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, most of this is easier to do using the the array_filter attribute, or relevance equations in general.  They all work on the same page, and fully support cascading relevance.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround applies a filter to a ranking question based on the checked boxes of a previous multiple-options question. There are two methods - one for filter and ranking questions being on the same page and a slightly different one for the filter question being on a page before the ranking question.&lt;br /&gt;
&lt;br /&gt;
There is a [http://www.partnersinc.biz/surveys//index.php?sid=96314&amp;amp;newtest=Y&amp;amp;lang=en demo of both methods here].&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FOR BOTH METHODS:&#039;&#039;&#039;&lt;br /&gt;
*[[Workarounds: Manipulating a survey at runtime using Javascript#How to use Script (eg. JavaScript etc.) in LimeSurvey?|Set up your survey to use JavaScript]].&lt;br /&gt;
*Place the following script in your template.js file. This function will be accessed by either method.&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
// A function to filter choices in a ranking question&lt;br /&gt;
function rankFilter(q1ID, q2ID, prevPage) {&lt;br /&gt;
&lt;br /&gt;
	// If filter question is on a previous page, hide Q1 and check all &amp;quot;visible&amp;quot; boxes&lt;br /&gt;
	if(prevPage == 1) {&lt;br /&gt;
		$(&#039;#question&#039;+q1ID+&#039; li[id^=&amp;quot;javatbd&amp;quot;]:visible input.checkbox&#039;).attr(&#039;checked&#039;, true);&lt;br /&gt;
		$(&#039;#question&#039;+q1ID+&#039;&#039;).hide();&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	handleChecked(q1ID, q2ID);&lt;br /&gt;
	$(&#039;#question&#039;+q1ID+&#039; input.checkbox&#039;).click(function() {&lt;br /&gt;
		handleChecked(q1ID, q2ID);&lt;br /&gt;
	});&lt;br /&gt;
	&lt;br /&gt;
	function handleChecked(q1ID, q2ID) {&lt;br /&gt;
	&lt;br /&gt;
		// Find the survey and group IDs&lt;br /&gt;
		if($( &#039;input#fieldnames&#039; ).length != 0) {&lt;br /&gt;
			var fieldNames = $( &#039;input#fieldnames&#039; ).attr(&#039;value&#039;);&lt;br /&gt;
			var tmp = fieldNames.split(&#039;X&#039;);&lt;br /&gt;
			var sID = tmp[0];&lt;br /&gt;
			var gID = tmp[1];&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		// Loop through all Q1 options&lt;br /&gt;
		$(&#039;#question&#039;+q1ID+&#039; input.checkbox&#039;).each(function(i) {&lt;br /&gt;
		&lt;br /&gt;
			// Find the answer code and value&lt;br /&gt;
			var tmp2 = $(this).attr(&#039;id&#039;).split(&#039;X&#039;+gID+&#039;X&#039;+q1ID+&#039;&#039;);&lt;br /&gt;
			var ansCode = tmp2[1];&lt;br /&gt;
			var ansTxt = $(this).next(&#039;label&#039;).text();&lt;br /&gt;
			&lt;br /&gt;
			// If option is checked and not in rank choices or output, add it to the rank choices&lt;br /&gt;
			if($(this).attr(&#039;checked&#039;) == true&lt;br /&gt;
						  &amp;amp;&amp;amp; $(&#039;#question&#039;+q2ID+&#039; select.select option[value=&amp;quot;&#039;+ansCode+&#039;&amp;quot;]&#039;).length == 0&lt;br /&gt;
						  &amp;amp;&amp;amp; $(&#039;#question&#039;+q2ID+&#039; .output input[id^=&amp;quot;fvalue_&amp;quot;][value=&amp;quot;&#039;+ansCode+&#039;&amp;quot;]&#039;).length == 0) {&lt;br /&gt;
				$(&#039;&amp;lt;option value=&amp;quot;&#039;+ansCode+&#039;&amp;quot;&amp;gt;&#039;+ansTxt+&#039;&amp;lt;/option&amp;gt;&#039;).appendTo(&#039;#question&#039;+q2ID+&#039; select.select&#039;);&lt;br /&gt;
			}&lt;br /&gt;
			&lt;br /&gt;
			// If option is unchecked...&lt;br /&gt;
			else if($(this).attr(&#039;checked&#039;) == false) {&lt;br /&gt;
				// Remove it from the rank choices&lt;br /&gt;
				$(&#039;#question&#039;+q2ID+&#039; select.select option[value=&amp;quot;&#039;+ansCode+&#039;&amp;quot;]&#039;).remove();&lt;br /&gt;
				// Remove it from the rank output and reset hidden values&lt;br /&gt;
$(&#039;#question&#039;+q2ID+&#039; .output input[id^=&amp;quot;fvalue_&amp;quot;][value=&amp;quot;&#039;+ansCode+&#039;&amp;quot;]&#039;).attr(&#039;value&#039;, &#039;&#039;).siblings(&#039;input.text&#039;).val(&#039;&#039;).siblings(&#039;img&#039;).hide();&lt;br /&gt;
			}&lt;br /&gt;
		});&lt;br /&gt;
		&lt;br /&gt;
		// Clean up empty inputs in the rank output table&lt;br /&gt;
		$(&#039;#question&#039;+q2ID+&#039; .output table tr&#039;).each(function(i) {&lt;br /&gt;
			var nextRow = $(this).next(&#039;tr&#039;);&lt;br /&gt;
			if($(&#039;input.text&#039;, this).val() == &#039;&#039; &amp;amp;&amp;amp; $(&#039;input.text&#039;, nextRow).val() != &#039;&#039;) {&lt;br /&gt;
				$(&#039;input.text&#039;, this).val($(&#039;input.text&#039;, nextRow).val());&lt;br /&gt;
				$(&#039;input.text&#039;, nextRow).val(&#039;&#039;);&lt;br /&gt;
				$(&#039;input[id^=&amp;quot;fvalue_&amp;quot;]&#039;, this).attr(&#039;value&#039;, $(&#039;input[id^=&amp;quot;fvalue_&amp;quot;]&#039;, nextRow).attr(&#039;value&#039;));&lt;br /&gt;
				$(&#039;input[id^=&amp;quot;fvalue_&amp;quot;]&#039;, nextRow).attr(&#039;value&#039;, &#039;&#039;);&lt;br /&gt;
			}&lt;br /&gt;
		});&lt;br /&gt;
		&lt;br /&gt;
		// Show the scissors for the last populated rank output row&lt;br /&gt;
		$(&#039;#question&#039;+q2ID+&#039; .output table img[id^=&amp;quot;cut_&amp;quot;]&#039;).hide();&lt;br /&gt;
		$(&#039;#question&#039;+q2ID+&#039; .output table input.text[value!=&amp;quot;&amp;quot;]:last&#039;).siblings(&#039;img[id^=&amp;quot;cut_&amp;quot;]&#039;).show();&lt;br /&gt;
		&lt;br /&gt;
		// Hide extra rank output rows&lt;br /&gt;
		var optNum = $(&#039;#question&#039;+q1ID+&#039; input.checkbox:checked&#039;).length;&lt;br /&gt;
		$(&#039;#question&#039;+q2ID+&#039; .output table tr&#039;).hide();&lt;br /&gt;
		$(&#039;#question&#039;+q2ID+&#039; .output table tr:lt(&#039;+(optNum+1)+&#039;)&#039;).show();&lt;br /&gt;
		&lt;br /&gt;
		// Hide and clear the ranking question if there are less than 2 checked options in Q1&lt;br /&gt;
		if(optNum &amp;lt; 2) {&lt;br /&gt;
			$(&#039;#question&#039;+q2ID+&#039;&#039;).hide();&lt;br /&gt;
			$(&#039;#question&#039;+q2ID+&#039; input.text&#039;).val(&#039;&#039;);&lt;br /&gt;
			$(&#039;#question&#039;+q2ID+&#039; input[id^=&amp;quot;fvalue_&amp;quot;]&#039;).attr(&#039;value&#039;, &#039;&#039;);&lt;br /&gt;
		}&lt;br /&gt;
		else {&lt;br /&gt;
			$(&#039;#question&#039;+q2ID+&#039;&#039;).show();&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		// A workaround for the built in max-answers function&lt;br /&gt;
		$(&#039;#question&#039;+q2ID+&#039; select.select&#039;).attr(&#039;disabled&#039;, true);&lt;br /&gt;
		$(&#039;#question&#039;+q2ID+&#039; td.output tr:visible&#039;).each(function(i) {&lt;br /&gt;
			if($(&#039;input.text&#039;, this).val() == &#039;&#039;) {&lt;br /&gt;
				$(&#039;#question&#039;+q2ID+&#039; select.select&#039;).attr(&#039;disabled&#039;, false);&lt;br /&gt;
			}&lt;br /&gt;
		});&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	// A listener to work around the built in max-answers function&lt;br /&gt;
	$(&#039;#question&#039;+q2ID+&#039; td.rank&#039;).click(function (event) {&lt;br /&gt;
		$(&#039;#question&#039;+q2ID+&#039; select.select&#039;).attr(&#039;disabled&#039;, true);&lt;br /&gt;
		$(&#039;#question&#039;+q2ID+&#039; td.item input.text&#039;).each(function(i) {&lt;br /&gt;
			if ($(this).val() == &#039;&#039;) {&lt;br /&gt;
				$(&#039;#question&#039;+q2ID+&#039; select.select&#039;).attr(&#039;disabled&#039;, false);&lt;br /&gt;
			}&lt;br /&gt;
		});&lt;br /&gt;
	});&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FOR BOTH FILTER AND RANKING QUESTIONS ON SAME PAGE:&#039;&#039;&#039;&lt;br /&gt;
*Create a multiple options question and a ranking question on the same page (in the same group).&lt;br /&gt;
*Both questions &#039;&#039;&#039;MUST&#039;&#039;&#039; have identical sub-questions and sub-question codes.&lt;br /&gt;
*Place the following script in the source of one of the questions.&lt;br /&gt;
*Replace &amp;quot;MM&amp;quot; with the ID of the multiple options question and &amp;quot;RR&amp;quot; with the ID of the ranking question.&lt;br /&gt;
*The function will hide the ranking question unless at least two options are selected in the multiple options question, in which case, it will only show the options selected.&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	$(document).ready(function() {&lt;br /&gt;
		rankFilter(MM, RR);&lt;br /&gt;
	});&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FOR FILTER AND RANKING QUESTIONS ON SEPARATE PAGES:&#039;&#039;&#039;&lt;br /&gt;
*Create a multiple options question on page 1.&lt;br /&gt;
*Create a multiple options question and a ranking question on page 2.&lt;br /&gt;
*All three questions &#039;&#039;&#039;MUST&#039;&#039;&#039; have identical sub-questions and sub-question codes.&lt;br /&gt;
*Set the multiple options on page 2 to be filtered by the multiple options on page 1.&lt;br /&gt;
*Place the following script in the source of one of the questions on page 2.&lt;br /&gt;
*Replace &amp;quot;MM&amp;quot; with the ID of the multiple options question and &amp;quot;RR&amp;quot; with the ID of the ranking question. Do not modify the &amp;quot;1&amp;quot;.&lt;br /&gt;
*The function will hide the multiple options question. If at least 2 options were selected in the multiple options on page 1, the corresponding options will be checked in the hidden multiple options question which will then be used to control the display of the ranking question.&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
	$(document).ready(function() {&lt;br /&gt;
		rankFilter(MM, RR, 1);&lt;br /&gt;
	});&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Filter &amp;quot;Array by Column&amp;quot; Question With &amp;quot;Multiple-Options&amp;quot;=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 2.05&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround applies a filter to an &amp;quot;Array by Column&amp;quot; question based on the checked boxes of a previous multiple-options question. There are two methods - one for filter and array questions being on the same page and a slightly different one for the filter question being on a page before the array question.&lt;br /&gt;
&lt;br /&gt;
There is a [http://www.partnersinc.biz/surveys//index.php?sid=74213&amp;amp;newtest=Y&amp;amp;lang=en demo of both methods here].&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FOR BOTH METHODS:&#039;&#039;&#039;&lt;br /&gt;
*[[Workarounds: Manipulating a survey at runtime using Javascript#How to use Script (eg. JavaScript etc.) in LimeSurvey?|Set up your survey to use JavaScript]].&lt;br /&gt;
*If using LimeSurvey version 2.05 or newer, place the following functions in your template.js file. These will be accessed by either method.&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;function filterArrByCol(qMultiOpt, qArray, prevPage) {&lt;br /&gt;
&lt;br /&gt;
	// If filter question is on a previous page, hide Q1 and check all &amp;quot;visible&amp;quot; boxes&lt;br /&gt;
	if(prevPage == 1) {&lt;br /&gt;
		$(&#039;#question&#039;+qMultiOpt+&#039; li[id^=&amp;quot;javatbd&amp;quot;]:visible input.checkbox&#039;).attr(&#039;checked&#039;, true);&lt;br /&gt;
		$(&#039;#question&#039;+qMultiOpt+&#039;&#039;).hide();&lt;br /&gt;
	}&lt;br /&gt;
	   &lt;br /&gt;
	// Assign classes to the answer cells&lt;br /&gt;
	$(&#039;#question&#039;+qArray+&#039; td.answer-item&#039;).each(function(i){&lt;br /&gt;
		var classArr = $(this).attr(&#039;class&#039;).split(&#039;answer_cell_00&#039;);&lt;br /&gt;
		classArr = classArr[1].split(&#039; &#039;);&lt;br /&gt;
		var ansCode = classArr[0];&lt;br /&gt;
		$(this).addClass(&#039;ans-&#039;+ansCode+&#039; filtered&#039;);&lt;br /&gt;
	});&lt;br /&gt;
	   &lt;br /&gt;
	// Assign classes to the answer label cells&lt;br /&gt;
	$(&#039;#question&#039;+qArray+&#039; table.subquestions-list tbody tr:eq(0) td.answer-item&#039;).each(function(i){&lt;br /&gt;
		var classArr2 = $(this).attr(&#039;class&#039;).split(&#039; ans-&#039;);&lt;br /&gt;
		var ansCode2 = classArr2[1];&lt;br /&gt;
		$(&#039;#question&#039;+qArray+&#039; table.subquestions-list thead tr:eq(0) th:eq(&#039;+i+&#039;)&#039;).addClass(&#039;ans-&#039;+ansCode2+&#039;&#039;);&lt;br /&gt;
	});&lt;br /&gt;
	   &lt;br /&gt;
	// Fire the filter function on page load&lt;br /&gt;
	filterArr(qMultiOpt, qArray);&lt;br /&gt;
&lt;br /&gt;
	// Listener on multi-opt checkboxes to fire the filter function&lt;br /&gt;
	$(&#039;#question&#039;+qMultiOpt+&#039; input.checkbox&#039;).click(function(){&lt;br /&gt;
		filterArr(qMultiOpt, qArray);&lt;br /&gt;
	});&lt;br /&gt;
	   &lt;br /&gt;
	// On submit, clear all hidden radios of array&lt;br /&gt;
	$(&#039;#movenextbtn, #movesubmitbtn&#039;).click(function(){&lt;br /&gt;
		$(&#039;#question&#039;+qArray+&#039; td.filtered:hidden&#039;).each(function(i){&lt;br /&gt;
				$(&#039;input.radio&#039;, this).prop(&#039;checked&#039;, false);&lt;br /&gt;
		});&lt;br /&gt;
		return true;&lt;br /&gt;
	});&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function filterArr(qMultiOpt, qArray) {&lt;br /&gt;
&lt;br /&gt;
	if($(&#039;#question&#039;+qMultiOpt+&#039; input.checkbox:checked&#039;).length &amp;lt; 1) {&lt;br /&gt;
		// Hide the array if no multi-opt options are checked&lt;br /&gt;
		$(&#039;#question&#039;+qArray+&#039;&#039;).hide();&lt;br /&gt;
	}&lt;br /&gt;
	else {&lt;br /&gt;
		$(&#039;#question&#039;+qArray+&#039;&#039;).show();&lt;br /&gt;
	   &lt;br /&gt;
		// Hide all columns of array&lt;br /&gt;
		$(&#039;#question&#039;+qArray+&#039; table.subquestions-list tbody td.answer-item, #question&#039;+qArray+&#039; table.question thead th&#039;).hide();&lt;br /&gt;
	   &lt;br /&gt;
		// Loop through multi-opt checkboxes and, if checked, show corresponding column of array&lt;br /&gt;
		$(&#039;#question&#039;+qMultiOpt+&#039; input.checkbox&#039;).each(function(i){&lt;br /&gt;
			if($(this).prop(&#039;checked&#039;) == true) {&lt;br /&gt;
				var classArr3 = $(this).attr(&#039;id&#039;).split(&#039;X&#039;+qMultiOpt);&lt;br /&gt;
				var ansCode3 = classArr3[1];&lt;br /&gt;
				$(&#039;#question&#039;+qArray+&#039; .ans-&#039;+ansCode3+&#039;&#039;).show();&lt;br /&gt;
			}&lt;br /&gt;
		});&lt;br /&gt;
	}&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*If using LimeSurvey version 2.0 or older, place the following functions in your template.js file. These will be accessed by either method.&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
	function filterArrByCol(qMultiOpt, qArray, prevPage) {&lt;br /&gt;
	&lt;br /&gt;
		// If filter question is on a previous page, hide Q1 and check all &amp;quot;visible&amp;quot; boxes&lt;br /&gt;
		if(prevPage == 1) {&lt;br /&gt;
			$(&#039;#question&#039;+qMultiOpt+&#039; li[id^=&amp;quot;javatbd&amp;quot;]:visible input.checkbox&#039;).attr(&#039;checked&#039;, true);&lt;br /&gt;
			$(&#039;#question&#039;+qMultiOpt+&#039;&#039;).hide();&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		// Assign classes to the answer cells&lt;br /&gt;
		$(&#039;#question&#039;+qArray+&#039; table.question tbody td&#039;).each(function(i){&lt;br /&gt;
			var classArr = $(this).attr(&#039;class&#039;).split(&#039;answer_cell_00&#039;);&lt;br /&gt;
			var ansCode = classArr[1];&lt;br /&gt;
			$(this).addClass(&#039;ans-&#039;+ansCode+&#039; filtered&#039;);&lt;br /&gt;
		});&lt;br /&gt;
		&lt;br /&gt;
		// Assign classes to the answer label cells&lt;br /&gt;
		$(&#039;#question&#039;+qArray+&#039; table.question tbody tr:eq(0) td&#039;).each(function(i){&lt;br /&gt;
			var classArr2 = $(this).attr(&#039;class&#039;).split(&#039; ans-&#039;);&lt;br /&gt;
			var ansCode2 = classArr2[1];&lt;br /&gt;
			$(&#039;#question&#039;+qArray+&#039; table.question thead tr:eq(0) th:eq(&#039;+i+&#039;)&#039;).addClass(&#039;ans-&#039;+ansCode2+&#039;&#039;);&lt;br /&gt;
		});&lt;br /&gt;
		&lt;br /&gt;
		// Fire the filter function on page load&lt;br /&gt;
		filterArr(qMultiOpt, qArray);&lt;br /&gt;
&lt;br /&gt;
		// Listener on multi-opt checkboxes to fire the filter function&lt;br /&gt;
		$(&#039;#question&#039;+qMultiOpt+&#039; input.checkbox&#039;).click(function(){&lt;br /&gt;
			filterArr(qMultiOpt, qArray);&lt;br /&gt;
		});&lt;br /&gt;
		&lt;br /&gt;
		// On submit, clear all hidden radios of array&lt;br /&gt;
		$(&#039;#movenextbtn, #movesubmitbtn&#039;).click(function(){&lt;br /&gt;
			$(&#039;#question&#039;+qArray+&#039; td.filtered:hidden&#039;).each(function(i){&lt;br /&gt;
				$(&#039;input.radio&#039;, this).attr(&#039;checked&#039;, false);&lt;br /&gt;
			});&lt;br /&gt;
			return true;&lt;br /&gt;
		});&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	function filterArr(qMultiOpt, qArray) {&lt;br /&gt;
	&lt;br /&gt;
		if($(&#039;#question&#039;+qMultiOpt+&#039; input.checkbox:checked&#039;).length &amp;lt; 1) {&lt;br /&gt;
			// Hide the array if no multi-opt options are checked&lt;br /&gt;
			$(&#039;#question&#039;+qArray+&#039;&#039;).hide();&lt;br /&gt;
		}&lt;br /&gt;
		else {&lt;br /&gt;
			$(&#039;#question&#039;+qArray+&#039;&#039;).show();&lt;br /&gt;
			&lt;br /&gt;
			// Hide all columns of array&lt;br /&gt;
			$(&#039;#question&#039;+qArray+&#039; table.question tbody td, #question&#039;+qArray+&#039; table.question thead th&#039;).hide();&lt;br /&gt;
			&lt;br /&gt;
			// Loop through multi-opt checkboxes and, if checked, show corresponding column of array&lt;br /&gt;
			$(&#039;#question&#039;+qMultiOpt+&#039; input.checkbox&#039;).each(function(i){&lt;br /&gt;
				if($(this).attr(&#039;checked&#039;) == true) {&lt;br /&gt;
					var classArr3 = $(this).attr(&#039;id&#039;).split(&#039;X&#039;+qMultiOpt);&lt;br /&gt;
					var ansCode3 = classArr3[1];&lt;br /&gt;
					$(&#039;#question&#039;+qArray+&#039; .ans-&#039;+ansCode3+&#039;&#039;).show();&lt;br /&gt;
				}&lt;br /&gt;
			});&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
});&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FOR BOTH FILTER AND ARRAY QUESTIONS ON SAME PAGE:&#039;&#039;&#039;&lt;br /&gt;
*Create a multiple options question and an array-by-column question on the same page (in the same group).&lt;br /&gt;
*Both questions &#039;&#039;&#039;MUST&#039;&#039;&#039; have identical sub-questions and sub-question codes.&lt;br /&gt;
*Place the following script in the source of one of the questions.&lt;br /&gt;
*Replace &amp;quot;MM&amp;quot; with the ID of the multiple options question and &amp;quot;AA&amp;quot; with the ID of the ranking question.&lt;br /&gt;
*The function will hide the array question unless at least one option is selected in the multiple-options question, in which case, it will only show the corresponding array column(s).&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
	$(document).ready(function() {&lt;br /&gt;
		filterArrByCol(MM, AA);&lt;br /&gt;
	});&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FOR FILTER AND ARRAY QUESTIONS ON SEPARATE PAGES:&#039;&#039;&#039;&lt;br /&gt;
*Create a multiple options question on page 1.&lt;br /&gt;
*Create a multiple options question and an array-by-column question on page 2.&lt;br /&gt;
*All three questions &#039;&#039;&#039;MUST&#039;&#039;&#039; have identical sub-questions and sub-question codes.&lt;br /&gt;
*Set the multiple options on page 2 to be filtered by the multiple options on page 1.&lt;br /&gt;
*Place the following script in the source of one of the questions on page 2.&lt;br /&gt;
*Replace &amp;quot;MM&amp;quot; with the ID of the multiple options question and &amp;quot;AA&amp;quot; with the ID of the array question. Do not modify the &amp;quot;1&amp;quot;.&lt;br /&gt;
*The function will hide the multiple options question. If options were selected in the multiple options on page 1, the corresponding options will be checked in the hidden multiple options question which will then be used to control the display of the array columns.&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
	$(document).ready(function() {&lt;br /&gt;
		filterArrByCol(MM, AA, 1);&lt;br /&gt;
	});&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Auto-tabbing between text input fields=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 6/7, FireFox 3.0, Safari 3.2, Chrome 2.0&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This is a workaround to facilitate auto-tabbing between text input questions in a single group using a [http://plugins.jquery.com/project/autotab jQuery plugin by Mathachew] and the Maximum characters attribute of questions.&lt;br /&gt;
&lt;br /&gt;
The behaviour will be: When the maximum number of characters has been entered into an input field, the focus (cursor) will be automatically moved to the next input field. When the backspace key is used to remove all characters from a field, the focus will be moved to the previous field. It&#039;s very useful in surveys having many text input questions to avoid having to manually tab or click between fields.&lt;br /&gt;
&lt;br /&gt;
You can view a small demo survey [http://www.partnersinc.biz/surveys//index.php?sid=11327&amp;amp;newtest=Y&amp;amp;lang=en here].&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#Visit [http://plugins.jquery.com/autotabs http://plugins.jquery.com/autotabs], download the plugin script and save it as &#039;&#039;jquery.autotab-1.1b.js&#039;&#039; in the template folder.&lt;br /&gt;
#Link to the script by placing &#039;&#039;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;{TEMPLATEURL}jquery.autotab-1.1b.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&#039;&#039; within the &#039;&#039;&amp;lt;head&amp;gt;&#039;&#039; tag of startpage.pstpl.&lt;br /&gt;
#[[Workarounds: Manipulating a survey at runtime using Javascript#How to use Script (eg. JavaScript etc.) in LimeSurvey?|Set up your survey to use JavaScript]].&lt;br /&gt;
#Create the text based questions that auto-tabbing is to be applied to. (All must be in the same group if you&#039;re using group by group presentation)&lt;br /&gt;
#Define a Maximum characters attribute for all questions that the autotab is applied to.&lt;br /&gt;
{{QS:maximum_chars}}  &lt;br /&gt;
#In the source of the first question of the group that contains the auto-tabbed questions, add the following code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#answerSSSSSXGGXAA&#039;).focus(); //initially focus on the first input&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#answerSSSSSXGGXAA&#039;).autotab({ target: &#039;answerSSSSSXGGXBB&#039; });&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#answerSSSSSXGGXBB&#039;).autotab({ previous: &#039;answerSSSSSXGGXAA&#039;, target: &#039;answerSSSSSXGGXCC&#039; });&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#answerSSSSSXGGXCC&#039;).autotab({ previous: &#039;answerSSSSSXGGXBB&#039;, target: &#039;answerSSSSSXGGXDD&#039; });&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#answerSSSSSXGGXDD&#039;).autotab({ previous: &#039;answerSSSSSXGGXCC&#039; });&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example has 4 fields to be auto-tabbed between - all instances of the following must be replaced to be compatible with your survey (See image below):&lt;br /&gt;
*SSSSS -&amp;gt; Survey ID&lt;br /&gt;
*GG -&amp;gt; Group ID&lt;br /&gt;
*AA -&amp;gt; First question&lt;br /&gt;
*BB -&amp;gt; Second question&lt;br /&gt;
*CC -&amp;gt; Third question&lt;br /&gt;
*DD -&amp;gt; Last question&lt;br /&gt;
&lt;br /&gt;
[[File:ids_343x252.gif]]&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;target&#039;&#039; parameter defines where the next input is and the &#039;&#039;previous&#039;&#039; parameter defines (you guessed it) the previous input.&lt;br /&gt;
&lt;br /&gt;
This plugin also has limited capability of formatting the input text - see comments in the plugin script.&lt;br /&gt;
&lt;br /&gt;
=Custom response listeners=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.85+ (7253), IE 6/7, FireFox 3.0, Safari 3.2, Chrome 2.0&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Listeners can be used to perform functions when a change in an input is detected. There are many uses such as the [[Workarounds#Reverse_array_filter|Reverse array_filter]] but a simple one would be to warn a respondent if they enter a value that may be too high.&lt;br /&gt;
&lt;br /&gt;
We can use the [http://docs.jquery.com/Events/change jQuery change( ) event] to fire a function whenever there is a change to the input. The function will look for an input value higher than 10 and, if found, will warn the respondent.&lt;br /&gt;
#[[Workarounds: Manipulating a survey at runtime using Javascript#How to use Script (eg. JavaScript etc.) in LimeSurvey?|Set up your survey to use JavaScript]].&lt;br /&gt;
#Place the script below in the source of one of the questions on the page where:&lt;br /&gt;
**11111 is the survey ID&lt;br /&gt;
**22 is the group ID&lt;br /&gt;
**33 is the question ID&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
		$(&#039;#answer11111X22X33&#039;).change(function() {&lt;br /&gt;
&lt;br /&gt;
			if ( $(&#039;#answer11111X22X33&#039;).val() &amp;gt; 10 ) {&lt;br /&gt;
				alert (&amp;quot;That&#039;s an awful lot. Are you sure?&amp;quot;);&lt;br /&gt;
			}&lt;br /&gt;
		});&lt;br /&gt;
	});&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Text input masks=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 7, FireFox 3.0, Safari 3.2, Chrome 2.0&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
There may be instances where you would like to place a mask on a text input - for example only allowing respondents to enter the correct characters for a North American phone number ((###) ###-####) or a Canadian postal code (A1A 1A1) The [http://plugins.jquery.com/project/meioMask jQuery meioMask plugin by fabiomcosta] can be used to do this.&lt;br /&gt;
&lt;br /&gt;
The plugin has several pre-defined masks and supports custom masks. It also allows for pasting of input, allows default values and can auto-focus the next form element when the current input is completely filled. See [http://www.meiocodigo.com/projects/meiomask/ http://www.meiocodigo.com/projects/meiomask/] for more details on features and options.&lt;br /&gt;
&lt;br /&gt;
There is a small demo [http://www.partnersinc.biz/surveys//index.php?sid=36146&amp;amp;newtest=Y&amp;amp;lang=en here].&lt;br /&gt;
&lt;br /&gt;
Implementation for this demo was as follows:&lt;br /&gt;
#Visit [http://www.meiocodigo.com/projects/meiomask/ http://www.meiocodigo.com/projects/meiomask/], download the latest plugin script and save it as jquery.meiomask.js in the template folder.&lt;br /&gt;
#Link to the script by placing &amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;{TEMPLATEURL}jquery.meiomask.js&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&amp;lt;/script&amp;gt; within the &amp;lt;head&amp;gt; tag of startpage.pstpl.&lt;br /&gt;
#Turn off $filterxsshtml to allow insertion of JavaScript in the questions. ([http://docs.limesurvey.org/tiki-index.php?page=Optional+settings&amp;amp;structure=English+Instructions+for+LimeSurvey#Filtering_dangerous_HTML_tags_in_survey_objects See documentation here])&lt;br /&gt;
#Create the text input questions that the masks are to be applied to&lt;br /&gt;
#In the source of the help section of the first question of the group that contains the masked inputs, add the following code. ([http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._ See How to use script here]) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$(document).ready(function() {	&lt;br /&gt;
						   &lt;br /&gt;
	// Define custom masks&lt;br /&gt;
	$.mask.masks = $.extend($.mask.masks,{&lt;br /&gt;
		customMask1:{ mask: &#039;a9a 9a9&#039; }, // Canadian postal code&lt;br /&gt;
		// Maximum input of 9,999.99, reverse input, default value of 0.00		&lt;br /&gt;
		customMask2:{ mask: &#039;99.999,9&#039;, type : &#039;reverse&#039;, defaultValue : &#039;000&#039; } &lt;br /&gt;
	});&lt;br /&gt;
	&lt;br /&gt;
	// Set the &#039;alt&#039; attributes of the inputs&lt;br /&gt;
	$(&#039;#answer111111X22XAA&#039;).attr(&#039;alt&#039;, &#039;phone-us&#039;); // a pre-defined mask					   &lt;br /&gt;
	$(&#039;#answer111111X22XBB&#039;).attr(&#039;alt&#039;, &#039;customMask1&#039;); // a custom mask					   &lt;br /&gt;
	$(&#039;#answer111111X22XCC&#039;).attr(&#039;alt&#039;, &#039;customMask2&#039;); // a custom mask					   &lt;br /&gt;
	$(&#039;#answer111111X22XDD&#039;).attr(&#039;alt&#039;, &#039;cc&#039;); // a pre-defined mask for credit card&lt;br /&gt;
	&lt;br /&gt;
	// Tell the plugin to apply masks to these inputs&lt;br /&gt;
	$(&#039;input:#answer111111X22XAA&#039;).setMask();&lt;br /&gt;
	$(&#039;input:#answer111111X22XBB&#039;).setMask();&lt;br /&gt;
	$(&#039;input:#answer111111X22XCC&#039;).setMask();&lt;br /&gt;
	$(&#039;input:#answer111111X22XDD&#039;).setMask();	&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The first section defines two custom masks to be used - one for Canadian postal code with a format of A#A #A# and a second for a maximum amount of 9999.99 with reverse input (useful for cost inputs) and a default value of 0.00.&lt;br /&gt;
&lt;br /&gt;
The next section sets the &amp;quot;alt&amp;quot; attributes for the text inputs. This will tell meioMask which mask we will be applying to each input. By default meioMask looks at the alt attribute to find which mask to apply however this can be changed using the [http://www.meiocodigo.com/projects/meiomask/#mm_options mask options].&lt;br /&gt;
&lt;br /&gt;
In the final section we apply the masks to the inputs.&lt;br /&gt;
&lt;br /&gt;
This example has 4 inputs with masks on them - all instances of the following must be replaced to be compatible with your survey (See image below):&lt;br /&gt;
&lt;br /&gt;
*11111 -&amp;gt; Survey ID&lt;br /&gt;
*22 -&amp;gt; Group ID&lt;br /&gt;
*AA -&amp;gt; First question&lt;br /&gt;
*BB -&amp;gt; Second question&lt;br /&gt;
*CC -&amp;gt; Third question&lt;br /&gt;
*DD -&amp;gt; Fourth question&lt;br /&gt;
&lt;br /&gt;
[[File:Ids 343x252.gif]]&lt;br /&gt;
&lt;br /&gt;
=Text input masks - second method=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.91RC6+, FireFox 4.0&#039;&#039;&lt;br /&gt;
&#039;&#039;Tested with: 2.05, Chrome 40.0.2214.115 m (64-bit)&lt;br /&gt;
&lt;br /&gt;
There may be instances where you would like to place a mask on a text input - for example only allowing respondents to enter the correct characters for a North American phone number ((###) ###-####) or a US social security number (###-##-####). The jQuery meioMask plugin by fabiomcosta is no longer supported but an alternative exists. The DigitalBush Masked Input Plugin is updated and simple to implement in LimeSurvey. See [http://digitalbush.com/projects/masked-input-plugin/ http://digitalbush.com/projects/masked-input-plugin/] for more details on features and options.&lt;br /&gt;
&lt;br /&gt;
Implementation as follows:&lt;br /&gt;
&lt;br /&gt;
#Visit [http://digitalbush.com/projects/masked-input-plugin/ http://digitalbush.com/projects/masked-input-plugin/], download the latest plugin script and save it as jquery.maskedinput.js in the template folder.&lt;br /&gt;
#Link to the script by placing &amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;{TEMPLATEURL}jquery.maskedinput.js&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&amp;lt;/script&amp;gt; within the &amp;lt;head&amp;gt; tag of startpage.pstpl.&lt;br /&gt;
#Turn off $filterxsshtml to allow insertion of JavaScript in the questions. ([http://docs.limesurvey.org/tiki-index.php?page=Optional+settings&amp;amp;structure=English+Instructions+for+LimeSurvey#Filtering_dangerous_HTML_tags_in_survey_objects See documentation here])&lt;br /&gt;
#Create the text input questions that the masks are to be applied to&lt;br /&gt;
#In the source of the help section of the first question of the group that contains the masked inputs, add the following code. ([http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._ See How to use script here])  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
	$(document).ready(function($) {	 &lt;br /&gt;
		$(&amp;quot;#answer55431X1X5&amp;quot;).mask(&amp;quot;999-99-9999&amp;quot;,{ placeholder:&amp;quot;#&amp;quot; });&lt;br /&gt;
	});&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Replace the &amp;quot;#answer55431X1X5&amp;quot; with your survey ID, group ID, and question ID. You can change the mask format and change or eliminate the placeholder if you wish. If you have multiple questions in the same group, simply copy and paste the line that begins with &amp;quot;$&amp;quot; and change the code to what is needed for your application.&lt;br /&gt;
&lt;br /&gt;
=Select a random response to a &amp;quot;Multiple options&amp;quot; question for later use=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 6/7, FireFox 3.0, Safari 3.2, Chrome 2.0&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround allows you to randomly select one of the checked boxes in a &amp;quot;Multiple options&amp;quot; question and store it&#039;s label for later use in the survey. A possible use would be to have a question asking what products were purchased and then randomly selecting one of the products to ask further questions about.&lt;br /&gt;
&lt;br /&gt;
There is a small demo of the above example [http://www.partnersinc.biz/surveys//index.php?sid=81252&amp;amp;newtest=Y&amp;amp;lang=en here].&lt;br /&gt;
&lt;br /&gt;
Basically what we&#039;ve done here is to put listeners on all of the checkboxes. If a change of state is detected in any of them the &amp;quot;randomResponse&amp;quot; function is called which loops through all of the checkboxes and if it finds a checked state, that box&#039;s label is added to an array. Then a random item is pulled from the array and used to populate the hidden question. This hidden question can then be drawn upon later in the survey using [http://docs.limesurvey.org/tiki-index.php?page=Adding+a+Question#Information_from_previous_answers INSERTANS] or [http://docs.limesurvey.org/tiki-index.php?page=Setting+conditions&amp;amp;structure=English+Instructions+for+LimeSurvey Conditions].&lt;br /&gt;
&lt;br /&gt;
Implementation for this demo is as follows:&lt;br /&gt;
&lt;br /&gt;
#[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_ Set up your survey to use JavaScript].&lt;br /&gt;
#Create a &amp;quot;Multiple options&amp;quot; question that we&#039;re going to randomly pick a checked box from&lt;br /&gt;
#Create a text input question to store the label of the checked box in (we&#039;re going to hide this with JavaScript)&lt;br /&gt;
#Place the script below in the source of one of the questions on the page. &lt;br /&gt;
&lt;br /&gt;
The following edits are required to implement this in your survey:&lt;br /&gt;
&lt;br /&gt;
*EDIT HERE (1) - 11111 -&amp;gt; Survey ID, 22 -&amp;gt; Group ID, 44 -&amp;gt; hidden question ID.&lt;br /&gt;
*EDIT HERE (2) - 44 -&amp;gt; hidden question ID.&lt;br /&gt;
*EDIT HERE (3) - 11111 -&amp;gt; Survey ID, 22 -&amp;gt; Group ID, 33 -&amp;gt; multiple option question ID, A/B/C/D/E/F -&amp;gt; multiple option answer codes. Also add or remove CBs for more or less checkboxes.&lt;br /&gt;
*EDIT HERE (4) - add or remove CBs for more or less checkboxes.&lt;br /&gt;
*EDIT HERE (5) - add or remove CBs for more or less checkboxes. &lt;br /&gt;
&lt;br /&gt;
For more info on these IDs see [http://docs.limesurvey.org/tiki-index.php?page=SGQA+identifier&amp;amp;structure=English+Instructions+for+LimeSurvey SGQA identifier].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
	$(document).ready(function() {&lt;br /&gt;
				&lt;br /&gt;
		//// Identify the hidden question input&lt;br /&gt;
		//// EDIT HERE (1) - replace with your hidden question input ID&lt;br /&gt;
		var hiddenInput = &#039;#answer11111X22X44&#039;;&lt;br /&gt;
		&lt;br /&gt;
		//// Make the &amp;quot;hidden&amp;quot; question disappear&lt;br /&gt;
		//// EDIT HERE (2) - replace with your hidden question ID&lt;br /&gt;
		$(&#039;#question44&#039;).hide();&lt;br /&gt;
		&lt;br /&gt;
		//// Identify the checkboxes to be randomized&lt;br /&gt;
		//// EDIT HERE (3) - add or remove as required, &lt;br /&gt;
		//// replace with your checkbox IDs&lt;br /&gt;
		var CB1 = &#039;#answer11111X22X33A&#039;;&lt;br /&gt;
		var CB2 = &#039;#answer11111X22X33B&#039;;&lt;br /&gt;
		var CB3 = &#039;#answer11111X22X33C&#039;;&lt;br /&gt;
		var CB4 = &#039;#answer11111X22X33D&#039;;&lt;br /&gt;
		var CB5 = &#039;#answer11111X22X33E&#039;;&lt;br /&gt;
		var CB6 = &#039;#answer11111X22X33F&#039;;&lt;br /&gt;
		&lt;br /&gt;
		//// Create an array of all checkboxes to be randomized&lt;br /&gt;
		//// EDIT HERE (4) - add or remove CBs as required&lt;br /&gt;
		checkBoxes = new Array( CB1, CB2, CB3, CB4, CB5, CB6 );&lt;br /&gt;
		var checkBoxesLength = checkBoxes.length;&lt;br /&gt;
		&lt;br /&gt;
		//// The randomizing function - no editing required&lt;br /&gt;
		function randomResponse () {&lt;br /&gt;
			var boxLabels = new Array();&lt;br /&gt;
			&lt;br /&gt;
			// loop through all of the checkboxes and if they are checked, &lt;br /&gt;
			// add their label to the boxLabels array&lt;br /&gt;
			for( var i=0; i&amp;lt;checkBoxesLength; i++ ) {&lt;br /&gt;
				if ( $(checkBoxes[i]).attr(&#039;checked&#039;) == true ) {&lt;br /&gt;
					var cbid = checkBoxes[i].replace(&#039;#&#039;,&#039;&#039;);&lt;br /&gt;
					boxLabels.push( $( &#039;label[for=&#039; + cbid + &#039;]&#039; ).html() );&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
			&lt;br /&gt;
			// find a random index of the responses array&lt;br /&gt;
			var randomNum = Math.floor(Math.random() * boxLabels.length); &lt;br /&gt;
			&lt;br /&gt;
			// populate the hidden question input with the &lt;br /&gt;
			// random input value&lt;br /&gt;
			$(hiddenInput).val( boxLabels[randomNum] ); &lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		//// The listeners that will fire the randomize function if a &lt;br /&gt;
		//// change occurs in the checkboxes&lt;br /&gt;
		//// EDIT HERE (5) - add or remove CBs as required&lt;br /&gt;
		$(CB1).change(function() {&lt;br /&gt;
			randomResponse ();&lt;br /&gt;
		});&lt;br /&gt;
		$(CB2).change(function() {&lt;br /&gt;
			randomResponse ();&lt;br /&gt;
		});&lt;br /&gt;
		$(CB3).change(function() {&lt;br /&gt;
			randomResponse ();&lt;br /&gt;
		});&lt;br /&gt;
		$(CB4).change(function() {&lt;br /&gt;
			randomResponse ();&lt;br /&gt;
		});&lt;br /&gt;
		$(CB5).change(function() {&lt;br /&gt;
			randomResponse ();&lt;br /&gt;
		});&lt;br /&gt;
		$(CB6).change(function() {&lt;br /&gt;
			randomResponse ();&lt;br /&gt;
		});	&lt;br /&gt;
	});&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Display secondary options in a &amp;quot;Multiple options&amp;quot; question=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 2.05&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround allows you to display secondary options in a &amp;quot;Multiple options&amp;quot; question if a primary option is checked as in the images below.&lt;br /&gt;
&lt;br /&gt;
Primary option not selected:&amp;lt;br /&amp;gt;&lt;br /&gt;
[[File:Secondary_options_1.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Primary option selected:&amp;lt;br /&amp;gt;&lt;br /&gt;
[[File:Secondary_options_2.jpg]]&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;DOWNLOADS:&#039;&#039;&#039;&amp;lt;br /&amp;gt;&lt;br /&gt;
- [[Media:Demo_Secondary_Checkboxes.zip|Demo template]]&amp;lt;br /&amp;gt;&lt;br /&gt;
- [[Media:Demo_Secondary_Checkboxes.lss|Demo survey]].&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPLEMENTATION:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1) [[Workarounds: Manipulating a survey at runtime using Javascript#How to use Script (eg. JavaScript etc.) in LimeSurvey?|Set up your survey to use JavaScript]].&lt;br /&gt;
&lt;br /&gt;
2) Create a &amp;quot;Multiple options&amp;quot; question including both the primary and secondary sub-questions (in the order that you would like them displayed if all shown).&lt;br /&gt;
&lt;br /&gt;
3) Add the following function to the end of template.js:&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
// A function to handle &amp;quot;secondary&amp;quot; checkboxes&lt;br /&gt;
function secondaryCheckboxes(qID, primaryPosition, secondaryCount) {&lt;br /&gt;
	// Identify the elements&lt;br /&gt;
	var thisQuestion = $(&#039;#question&#039;+qID);&lt;br /&gt;
	var primaryRow = $(&#039;li.question-item:eq(&#039;+(primaryPosition-1)+&#039;)&#039;, thisQuestion);&lt;br /&gt;
	var primaryInput = $(&#039;input.checkbox&#039;, primaryRow);&lt;br /&gt;
	var secondaryRows = primaryRow.nextAll(&#039;li.question-item:lt(&#039;+(secondaryCount)+&#039;)&#039;);&lt;br /&gt;
	var secondaryInputs = $(&#039;input.checkbox&#039;, secondaryRows);&lt;br /&gt;
	&lt;br /&gt;
	// Indent the secondaries&lt;br /&gt;
	secondaryRows.css({ &#039;margin-left&#039;:&#039;2.5em&#039; });&lt;br /&gt;
	&lt;br /&gt;
	// Initial states of the secondary answers&lt;br /&gt;
	if (primaryInput.prop(&#039;checked&#039;) == false ) {&lt;br /&gt;
		secondaryRows.hide(); &lt;br /&gt;
	} &lt;br /&gt;
	&lt;br /&gt;
	// A listener on the primary answer to show or hide secondary answers &lt;br /&gt;
	primaryInput.click(function (event) { &lt;br /&gt;
		&lt;br /&gt;
		// Hide/show the secondary answers accordingly&lt;br /&gt;
		if (!$(this).is(&#039;:checked&#039;)) {&lt;br /&gt;
			secondaryRows.hide();				&lt;br /&gt;
			secondaryInputs.prop(&#039;checked&#039;, false);&lt;br /&gt;
			secondaryInputs.each(function(i) {&lt;br /&gt;
				checkconditions(this.value, this.name, this.type);&lt;br /&gt;
			});&lt;br /&gt;
		}&lt;br /&gt;
		else {&lt;br /&gt;
			secondaryRows.show(); &lt;br /&gt;
		}&lt;br /&gt;
	});&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;4) Call the function in the source of the question with the question ID (no editing necessary), the start position of the primary sub-question and the number of secondaries to follow. &lt;br /&gt;
So, in this example, sub-question 1 is a primary followed by 2 secondaries and subquestion 6 is a primary followed by 3 secondaries.&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;	&lt;br /&gt;
	$(document).ready(function() {&lt;br /&gt;
		// Sub-question 1 is primary followed by 2 secondaries&lt;br /&gt;
		secondaryCheckboxes({QID}, 1, 2);&lt;br /&gt;
		// Sub-question 6 is primary followed by 3 secondaries		&lt;br /&gt;
		secondaryCheckboxes({QID}, 6, 3);&lt;br /&gt;
    });	&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Minimum number of required answers in an array (pre 1.92)=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 6/7, FireFox 3.0, Safari 3.2,&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92 all array style questions have the min_answers and max_answers options, so this script is obsolete.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround allows you to specify a &#039;&#039;&#039;minimum number&#039;&#039;&#039; of answers required in an array question. It is an alternative to the &amp;quot;Mandatory&amp;quot; parameter which specifies that &#039;&#039;&#039;all&#039;&#039;&#039; answers are required. It could also be easily modified to specify a maximum number of answers.&lt;br /&gt;
&lt;br /&gt;
We accomplish this by placing an onload function in the source of the array question. This function hides the Next/Submit button and displays a warning element until it detects a minimum number of responses. It then hides the warning and shows the Next/Submit button.&lt;br /&gt;
&lt;br /&gt;
There is a demo [http://www.partnersinc.biz/surveys//index.php?sid=97166&amp;amp;newtest=Y&amp;amp;lang=en here].&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#Turn off &#039;&#039;$filterxsshtml&#039;&#039; to allow insertion of JavaScript in the questions. (See [[Optional settings#Security|documentation here]])&lt;br /&gt;
#Set up the template to use custom onload functions. (See the [[Workarounds#Custom onload function|workaround here]])&lt;br /&gt;
#In the source of the array question add the following onload function. (See [[Workarounds: Manipulating a survey at runtime using Javascript#How to use Script (eg. JavaScript etc.) in LimeSurvey?|How to use script here]])&lt;br /&gt;
#Modify the &#039;&#039;SETTINGS&#039;&#039; section of the code as required.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	// Wait until the document is fully loaded&lt;br /&gt;
	$(document).ready(function() {&lt;br /&gt;
	&lt;br /&gt;
		/********************** SETTINGS **********************/&lt;br /&gt;
		// The text to appear in the warning element&lt;br /&gt;
		var warningText = &#039;Please answer at least 4 to continue&#039;;&lt;br /&gt;
		// The question ID&lt;br /&gt;
		var questionId = 137;&lt;br /&gt;
		// The minimum number of answers required&lt;br /&gt;
		var minNumber = 4;&lt;br /&gt;
		/******************************************************/&lt;br /&gt;
		&lt;br /&gt;
		// Create the warning element and place it after the submit button&lt;br /&gt;
		var el = document.createElement(&#039;div&#039;);&lt;br /&gt;
		el.setAttribute(&#039;id&#039;,&#039;warning&#039;);&lt;br /&gt;
		document.body.appendChild(el);&lt;br /&gt;
		$( &#039;#warning&#039; ).css({&lt;br /&gt;
			&#039;border&#039;:&#039;1px solid #333333&#039;,&lt;br /&gt;
			&#039;width&#039;:&#039;200px&#039;,&lt;br /&gt;
			&#039;padding&#039;:&#039;3px&#039;,&lt;br /&gt;
			&#039;color&#039;:&#039;red&#039;&lt;br /&gt;
		});&lt;br /&gt;
		$(&#039;#warning&#039;).html(warningText);&lt;br /&gt;
		$(&#039;input[type=&amp;quot;submit&amp;quot;]&#039;).after($(&#039;#warning&#039;));&lt;br /&gt;
		&lt;br /&gt;
		// Detect the initial number of checked answers &amp;amp; display Next/Submit button accordingly&lt;br /&gt;
		var inputInitCount = 0;&lt;br /&gt;
		$(&#039;#question&#039; + questionId + &#039; input&#039;).each(function(i) {&lt;br /&gt;
			if ($( this ).attr(&#039;checked&#039;) == true ) {&lt;br /&gt;
				inputInitCount++;&lt;br /&gt;
			}&lt;br /&gt;
		});&lt;br /&gt;
		if (inputInitCount &amp;gt; (minNumber - 1)) {&lt;br /&gt;
			$(&#039;input[type=&amp;quot;submit&amp;quot;]&#039;).show();&lt;br /&gt;
			$(&#039;#warning&#039;).hide();&lt;br /&gt;
		}&lt;br /&gt;
		else {&lt;br /&gt;
			$(&#039;#warning&#039;).show();&lt;br /&gt;
			$(&#039;input[type=&amp;quot;submit&amp;quot;]&#039;).hide();&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		// Listener to detect number of checked answers &amp;amp; display Next/Submit button accordingly&lt;br /&gt;
		$(&#039;#question&#039; + questionId + &#039; input.radio, #question&#039;+questionId+&#039; tbody[id^=&amp;quot;javatbd&amp;quot;] td&#039;).click(function() {&lt;br /&gt;
			var inputCount = 0;&lt;br /&gt;
			$(&#039;#question&#039; + questionId + &#039; input.radio&#039;).each(function(i) {&lt;br /&gt;
				if ($( this ).attr(&#039;checked&#039;) == true ) {&lt;br /&gt;
					inputCount++;&lt;br /&gt;
				}&lt;br /&gt;
			});&lt;br /&gt;
			if (inputCount &amp;gt; (minNumber - 1)) {&lt;br /&gt;
				$(&#039;input[type=&amp;quot;submit&amp;quot;]&#039;).show();&lt;br /&gt;
				$(&#039;#warning&#039;).hide();&lt;br /&gt;
			}&lt;br /&gt;
			else {&lt;br /&gt;
				$(&#039;#warning&#039;).show();&lt;br /&gt;
				$(&#039;input[type=&amp;quot;submit&amp;quot;]&#039;).hide();&lt;br /&gt;
			}&lt;br /&gt;
			&lt;br /&gt;
			// The original functions of the click event&lt;br /&gt;
			checkconditions(this.value, this.name, this.type);&lt;br /&gt;
		});&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Minimum elapsed time before moving forward in survey=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.91, IE 7/8, Firefox 7.0, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround interrupts the Next/Submit function and checks the amount of time elapsed since the page loaded. If the time is less than the minimum dictated, the respondent is alerted and not allowed to proceed. It is useful if you want to enforce a minimum amount of time spent viewing a page.&lt;br /&gt;
#[[Workarounds: Manipulating a survey at runtime using Javascript#How to use Script (eg. JavaScript etc.) in LimeSurvey?|Set up your survey to use JavaScript]].&lt;br /&gt;
#Place the script below in the source of one of the questions on the page, replacing &amp;quot;TT&amp;quot; with the minimum number of seconds required before advancing is allowed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
		minTime(TT);&lt;br /&gt;
&lt;br /&gt;
		function minTime(minTime) {&lt;br /&gt;
&lt;br /&gt;
			var startTime = new Date();&lt;br /&gt;
&lt;br /&gt;
			$(&#039;#movenextbtn, #movesubmitbtn&#039;).click(function(){&lt;br /&gt;
&lt;br /&gt;
				var endTime = new Date();&lt;br /&gt;
&lt;br /&gt;
				if((endTime - startTime)/1000 &amp;lt;= minTime) {&lt;br /&gt;
					alert (&#039;You must spend at least &#039;+minTime+&#039; seconds on the question.&#039;);&lt;br /&gt;
					return false;&lt;br /&gt;
				}&lt;br /&gt;
				else {&lt;br /&gt;
					return true;&lt;br /&gt;
				}&lt;br /&gt;
			});&lt;br /&gt;
		}&lt;br /&gt;
	});&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Minimum number of characters in Long free text or Huge free text questions=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.91, IE 7/8, Firefox 7.0, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.91, you can use regular expression masks (validation) to specify the minimum number of required characters.  However, even if the question is mandatory, it can still be blank.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version  1.92, if you make the question mandatory and use a validation mask to specify the minimum number of characters, then the user will be forced to answer the question.  Note that unlike 1.91, they can submit their current answers, even if partially invalid (so they are stored in the database), but they will not ber able to proceed to the next page until they have passed all mandatory and validity checks.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround interrupts the Next/Submit function and checks the number of characters entered in a Long free text or Huge free text question. If the number is less than the minimum dictated, the respondent is alerted and not allowed to proceed.&lt;br /&gt;
&lt;br /&gt;
#[[Workarounds: Manipulating a survey at runtime using Javascript#How to use Script (eg. JavaScript etc.) in LimeSurvey?|Set up your survey to use JavaScript]].&lt;br /&gt;
&lt;br /&gt;
#Place the script below in the source of one of the questions on the page, replace &amp;quot;QQ&amp;quot; with the question ID and &amp;quot;CC&amp;quot; with the minimum number of characters required before advancing is allowed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       minChar(QQ, CC);&lt;br /&gt;
&lt;br /&gt;
       function minChar(qID, minChars) {&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#movenextbtn, #movesubmitbtn&#039;).click(function(){&lt;br /&gt;
&lt;br /&gt;
               if($(&#039;#question&#039;+qID+&#039; textarea&#039;).val().replace(/ /g,&#039;&#039;).length &amp;lt; minChars) {&lt;br /&gt;
&lt;br /&gt;
                   alert (&#039;You must enter at least &#039;+minChars+&#039; characters.&#039;);&lt;br /&gt;
&lt;br /&gt;
                   return false;&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               else {&lt;br /&gt;
&lt;br /&gt;
                   return true;&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Variable Length Array (Multi Flexible Text) question=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 6/7/8, FireFox 3.0, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround allows a respondent to add or remove rows of an Array (Multi Flexible Text) question. It&#039;s useful to avoid the page being cluttered with unnecessary array rows.&lt;br /&gt;
&lt;br /&gt;
A function is placed in the template.js file of your template (use template editor). This function hides all of the array rows except the first and inserts two elements that when clicked show or hide rows accordingly.&lt;br /&gt;
&lt;br /&gt;
There is a demo [http://www.partnersinc.biz/surveys//index.php?sid=53132&amp;amp;newtest=Y&amp;amp;lang=en here].&lt;br /&gt;
&lt;br /&gt;
It must be noted that you can not make this question Mandatory as the respondent will have no way to complete hidden fields. If you want the displayed fields to be mandatory you will need to validate them in another function or modify this function to only allow the addition of rows if all fields in the last row are completed and then disable those fields - that, however, is a little over the top for this example.&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
&lt;br /&gt;
#Set up your survey to use JavaScript (See instructions [[Workarounds: Manipulating a survey at runtime using Javascript#How to use Script (eg. JavaScript etc.) in LimeSurvey?|here]])&lt;br /&gt;
&lt;br /&gt;
#Add the following script to your &#039;&#039;template.js&#039;&#039; file.&lt;br /&gt;
&lt;br /&gt;
#Replace &amp;quot;QQ&amp;quot; in the function call at the end with the question ID.&lt;br /&gt;
&lt;br /&gt;
#Create one or more Array (Multi Flexible Text) questions&lt;br /&gt;
&lt;br /&gt;
#If you want to apply it to more arrays on the same page simply add more calls with the appropriate question IDs. (eg. varLengthArray(1); varLengthArray(2);...)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
   // A function to add or remove rows of an Array (Multi Flexible)(Text) question&lt;br /&gt;
	function varLengthArray(qID) {&lt;br /&gt;
&lt;br /&gt;
		if ($(&#039;#question&#039;+qID+&#039;&#039;).length &amp;gt; 0) {&lt;br /&gt;
&lt;br /&gt;
			// The HTML content of the Add/Remove elements - modify as you wish&lt;br /&gt;
			var addContent = &#039;[+]&#039;;&lt;br /&gt;
			var removeContent = &#039;[-]&#039;;&lt;br /&gt;
&lt;br /&gt;
			// Create the Add and Remove elements &amp;amp; insert them&lt;br /&gt;
			var el1 = document.createElement(&#039;div&#039;);&lt;br /&gt;
			el1.setAttribute(&#039;id&#039;,&#039;addButton&#039;+qID);&lt;br /&gt;
			document.body.appendChild(el1);&lt;br /&gt;
			var el2 = document.createElement(&#039;div&#039;);&lt;br /&gt;
			el2.setAttribute(&#039;id&#039;,&#039;removeButton&#039;+qID);&lt;br /&gt;
			document.body.appendChild(el2);&lt;br /&gt;
&lt;br /&gt;
			// Move them to after the array&lt;br /&gt;
			$( &#039;div#addButton&#039;+qID ).appendTo($( &#039;#question&#039; + qID + &#039; table.question&#039; ).parent());&lt;br /&gt;
			$( &#039;div#removeButton&#039;+qID ).appendTo($( &#039;#question&#039; + qID + &#039; table.question&#039; ).parent());&lt;br /&gt;
&lt;br /&gt;
			// Insert their HTML&lt;br /&gt;
			$( &#039;div#addButton&#039;+qID ).html( addContent );&lt;br /&gt;
			$( &#039;div#removeButton&#039;+qID ).html( removeContent );&lt;br /&gt;
&lt;br /&gt;
			// Style the elements - you can modify here if you wish&lt;br /&gt;
			$( &#039;div#addButton&#039;+qID ).css({&lt;br /&gt;
				&#039;margin&#039;:&#039;10px 0 0 10px&#039;,&lt;br /&gt;
				&#039;padding&#039;:&#039;1px&#039;,&lt;br /&gt;
				&#039;text-align&#039;:&#039;center&#039;,&lt;br /&gt;
				&#039;font-weight&#039;:&#039;bold&#039;,&lt;br /&gt;
				&#039;width&#039;:&#039;auto&#039;,&lt;br /&gt;
				&#039;cursor&#039;:&#039;pointer&#039;,&lt;br /&gt;
				&#039;float&#039;:&#039;left&#039;&lt;br /&gt;
			});&lt;br /&gt;
&lt;br /&gt;
			$( &#039;div#removeButton&#039;+qID ).css({&lt;br /&gt;
				&#039;margin&#039;:&#039;10px 0 0 10px&#039;,&lt;br /&gt;
				&#039;padding&#039;:&#039;1px&#039;,&lt;br /&gt;
				&#039;text-align&#039;:&#039;center&#039;,&lt;br /&gt;
				&#039;font-weight&#039;:&#039;bold&#039;,&lt;br /&gt;
				&#039;width&#039;:&#039;auto&#039;,&lt;br /&gt;
				&#039;cursor&#039;:&#039;pointer&#039;,&lt;br /&gt;
				&#039;float&#039;:&#039;left&#039;&lt;br /&gt;
			});&lt;br /&gt;
&lt;br /&gt;
			// Initially hide the Remove element&lt;br /&gt;
			$( &#039;div#removeButton&#039;+qID ).hide();&lt;br /&gt;
&lt;br /&gt;
			// Call the functions below when clicked&lt;br /&gt;
			$( &#039;div#addButton&#039;+qID ).click(function (event) {&lt;br /&gt;
				addRow(qID);&lt;br /&gt;
			});&lt;br /&gt;
			$( &#039;div#removeButton&#039;+qID ).click(function (event) {&lt;br /&gt;
				removeRow(qID);&lt;br /&gt;
			});&lt;br /&gt;
&lt;br /&gt;
			// Function to add a row, also shows the Remove element and hides the&lt;br /&gt;
			//Add element if all rows are shown&lt;br /&gt;
			function addRow(qID) {&lt;br /&gt;
				var arrayRow = &#039;#question&#039; + qID + &#039; table.question tbody&#039;;&lt;br /&gt;
				var rowCount = $( arrayRow ).size() - 1;&lt;br /&gt;
				$( arrayRow + &#039;[name=&amp;quot;hidden&amp;quot;]:first&#039; ).attr(&#039;name&#039;, &#039;visible&#039;).show();&lt;br /&gt;
				$( &#039;div#removeButton&#039;+qID ).show();&lt;br /&gt;
				if ( $( arrayRow + &#039;:eq(&#039; + rowCount + &#039;)&#039; ).attr(&#039;name&#039;) == &#039;visible&#039; )  {&lt;br /&gt;
					$( &#039;div#addButton&#039;+qID ).hide();&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			// Function to remove a row, also clears the contents of the removed row,&lt;br /&gt;
			// shows the Add element if the last row is hidden and hides the Remove&lt;br /&gt;
			// element if only the first row is shown&lt;br /&gt;
			function removeRow(qID) {&lt;br /&gt;
				var arrayRow = &#039;#question&#039; + qID + &#039; table.question tbody&#039;;&lt;br /&gt;
				var rowCount = $( arrayRow ).size() - 1;&lt;br /&gt;
				$( arrayRow + &#039;[name=&amp;quot;visible&amp;quot;]:last input[type=&amp;quot;text&amp;quot;]&#039; ).val(&#039;&#039;);&lt;br /&gt;
				$( arrayRow + &#039;[name=&amp;quot;visible&amp;quot;]:last&#039; ).attr(&#039;name&#039;, &#039;hidden&#039;).hide();&lt;br /&gt;
				$( &#039;div#addButton&#039;+qID ).show();&lt;br /&gt;
				if ( $( arrayRow + &#039;:eq(1)&#039; ).attr(&#039;name&#039;) == &#039;hidden&#039; )  {&lt;br /&gt;
					$( &#039;div#removeButton&#039;+qID ).hide();&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			// Just some initialization stuff&lt;br /&gt;
			var arrayRow = &#039;#question&#039; + qID + &#039; table.question tbody&#039;;&lt;br /&gt;
			var rowCount = &#039;&#039;;&lt;br /&gt;
&lt;br /&gt;
			// Initially hide all except first row or any rows with populated inputs&lt;br /&gt;
			$( arrayRow ).each(function(i) {&lt;br /&gt;
				if ( i &amp;gt; 0 ) {&lt;br /&gt;
					// We also need to give the hidden rows a name cause IE doesn&#039;t&lt;br /&gt;
					// recognize jQuery :visible selector consistently&lt;br /&gt;
					$( this ).attr(&#039;name&#039;, &#039;hidden&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
					$(&#039;input[type=text]&#039;, this).each(function(i) {&lt;br /&gt;
						if ($(this).attr(&#039;value&#039;) != &#039;&#039;) {&lt;br /&gt;
							$(this).parents(&#039;tbody:eq(0)&#039;).attr(&#039;name&#039;, &#039;visible&#039;).show();&lt;br /&gt;
							$( &#039;div#removeButton&#039;+qID ).show();&lt;br /&gt;
						}&lt;br /&gt;
					});&lt;br /&gt;
					rowCount = i;&lt;br /&gt;
				}&lt;br /&gt;
			});&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	// Call the function with a question ID&lt;br /&gt;
	varLengthArray(QQ);&lt;br /&gt;
&lt;br /&gt;
});&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Expandable Array=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 6/7, FireFox 3.5, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround allows you to present an array question incrementally. That is to say that initially only the first option (row) in the array is shown. When that option is answered the next is shown and so-on.&lt;br /&gt;
&lt;br /&gt;
A JavaScript function is placed in the source of the array question. This function hides all of the array rows except the first and then displays them as options are answered.&lt;br /&gt;
&lt;br /&gt;
There is a demo [http://www.partnersinc.biz/surveys//index.php?sid=94958&amp;amp;newtest=Y&amp;amp;lang=en here].&lt;br /&gt;
&lt;br /&gt;
The workaround supports following question types:&lt;br /&gt;
*Array (flexible labels)&lt;br /&gt;
*Array (flexible labels) by column&lt;br /&gt;
*Array (Yes/No/Uncertain)&lt;br /&gt;
*Array (Increase, Same, Decrease)&lt;br /&gt;
*Array (Flexible Labels) dual scale&lt;br /&gt;
*Array (10 point choice)&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#Set up your survey to use JavaScript. (See [[Workarounds: Manipulating a survey at runtime using Javascript#How to use Script (eg. JavaScript etc.) in LimeSurvey?|documentation here]])&lt;br /&gt;
#Create one or more Array questions&lt;br /&gt;
#In the source of the first array question add the following script.&lt;br /&gt;
#Replace &amp;quot;QQ&amp;quot; in the function call at the end of the script with the question ID of the array you would like to manipulate.&lt;br /&gt;
#If you want to apply it to more arrays on the same page, simply add more calls with the appropriate question IDs. (eg. expandingArray(1); expandingArray(2);...)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
		// A function to show subsequent rows of an array as options are checked&lt;br /&gt;
		function expandingArray(qID) {&lt;br /&gt;
&lt;br /&gt;
			// Build an array of the question rows&lt;br /&gt;
			var arrayRow = &#039;#question&#039; + qID + &#039; table.question tbody tr&#039;;&lt;br /&gt;
&lt;br /&gt;
			// Initially hide all rows unless an input was previously checked&lt;br /&gt;
			$( arrayRow ).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
				if ( $( arrayRow  + &#039;:eq(&#039; + i + &#039;) input.radio:checked&#039; ).length != 0 ) {&lt;br /&gt;
					$(this).attr(&#039;name&#039;, &#039;clickedRow&#039;);&lt;br /&gt;
				}&lt;br /&gt;
				else {&lt;br /&gt;
					$(this).attr(&#039;name&#039;, &#039;hidden&#039;).hide();&lt;br /&gt;
				}&lt;br /&gt;
			});&lt;br /&gt;
&lt;br /&gt;
			// Now show the first hidden row&lt;br /&gt;
			addRow();&lt;br /&gt;
&lt;br /&gt;
			// Add another row when an option is checked for the first time&lt;br /&gt;
			$( &#039;#question&#039; + qID + &#039; td.answer input.radio&#039; ).click(function (event) {&lt;br /&gt;
&lt;br /&gt;
				if ($(this).parents(&#039;tr:eq(0)&#039;).attr(&#039;name&#039;) != &#039;clickedRow&#039;) {&lt;br /&gt;
					addRow();&lt;br /&gt;
					$(this).parents(&#039;tr:eq(0)&#039;).attr(&#039;name&#039;, &#039;clickedRow&#039;);&lt;br /&gt;
				}&lt;br /&gt;
&lt;br /&gt;
				// The original function of the click event&lt;br /&gt;
				checkconditions(this.value, this.name, this.type);&lt;br /&gt;
			});&lt;br /&gt;
&lt;br /&gt;
			// Add another row when an table cell is clicked for the first time&lt;br /&gt;
			$( &#039;#question&#039; + qID + &#039; table.question tbody td&#039; ).click(function (event) {&lt;br /&gt;
&lt;br /&gt;
				if ($(this).parents(&#039;tr:eq(0)&#039;).attr(&#039;name&#039;) != &#039;clickedRow&#039;) {&lt;br /&gt;
					addRow();&lt;br /&gt;
					$(this).parents(&#039;tr:eq(0)&#039;).attr(&#039;name&#039;, &#039;clickedRow&#039;);&lt;br /&gt;
				}&lt;br /&gt;
			});&lt;br /&gt;
&lt;br /&gt;
			// Function to add a row&lt;br /&gt;
			function addRow() {&lt;br /&gt;
				$( arrayRow + &#039;[name=&amp;quot;hidden&amp;quot;]:first&#039; ).attr(&#039;name&#039;, &#039;visible&#039;).show();&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		// Call the function with a question ID&lt;br /&gt;
		expandingArray(QQ);&lt;br /&gt;
&lt;br /&gt;
	});&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Partially Randomized Answers - Array questions=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 2.05&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround allows the answers of Array questions to be randomized while always keeping one sub-question at the end of the list.&lt;br /&gt;
&lt;br /&gt;
After the LimeSurvey randomizing has occurred a function in the source of a question moves the sub-question with a defined code to the bottom of the array.&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#[[Workarounds: Manipulating a survey at runtime using Javascript#How to use Script (eg. JavaScript etc.) in LimeSurvey?|Set up your survey to use JavaScript]]&lt;br /&gt;
#Create an Array type question. &lt;br /&gt;
#Set the &amp;quot;Random order&amp;quot; question setting to &amp;quot;Randomize on each page load&amp;quot;.&lt;br /&gt;
#Place the following script in the source of the question.&lt;br /&gt;
#Modify the &amp;quot;fixedCode&amp;quot; value as required.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;	&lt;br /&gt;
	$(document).ready(function() {&lt;br /&gt;
 &lt;br /&gt;
		// The sub-question code to place in the last position&lt;br /&gt;
		var fixedCode = &#039;A1&#039;;&lt;br /&gt;
 &lt;br /&gt;
		// Identify this question&lt;br /&gt;
		var q1ID = {QID};&lt;br /&gt;
		var thisQuestion = $(&#039;#question&#039;+q1ID);&lt;br /&gt;
 &lt;br /&gt;
		// Move the &amp;quot;fixed&amp;quot; row to the end&lt;br /&gt;
		$(&#039;table.subquestions-list tbody&#039;, thisQuestion).append($(&#039;tr[id$=&amp;quot;X&#039;+q1ID+fixedCode+&#039;&amp;quot;]&#039;));&lt;br /&gt;
			&lt;br /&gt;
		// Fix up the array row background colours&lt;br /&gt;
		$(&#039;tr.answers-list&#039;, thisQuestion).each(function(i){&lt;br /&gt;
			$(this).removeClass(&#039;array1 array2&#039;).addClass(&#039;array&#039;+(2-(i%2)));&lt;br /&gt;
		});&lt;br /&gt;
 &lt;br /&gt;
    });&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Download sample survey:&#039;&#039;&#039;&amp;lt;br /&amp;gt;&lt;br /&gt;
[[Media:Partially_randomized_array.lss|Partially_randomized_array.lss]]&lt;br /&gt;
&lt;br /&gt;
=Partially Randomized Answers - Multiple Options &amp;amp; List (radio) questions=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 2.05&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround allows the answers of Multiple Options &amp;amp; List (radio) questions to be randomized while always keeping one answer at the end of the list. It&#039;s useful if you want to randomize, say, the first 4 of your answers but always have the fifth displayed last as in the image below:&lt;br /&gt;
&lt;br /&gt;
[[File:random_336x179gif.gif]]&lt;br /&gt;
&lt;br /&gt;
After the LimeSurvey randomizing has occurred a function in the source of a question moves the answer with the highest answer code to the end of the list.&lt;br /&gt;
&lt;br /&gt;
Some conditions on the use of this are:&lt;br /&gt;
*The &amp;quot;Show No answer&amp;quot; survey setting must be set to &amp;quot;No&amp;quot; &lt;br /&gt;
*You must use sequential numbers, starting at 1 as response codes. (See image below)&lt;br /&gt;
&lt;br /&gt;
[[File:Partially_Randomized_Answers_1.png]]&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#[[Workarounds: Manipulating a survey at runtime using Javascript#How to use Script (eg. JavaScript etc.) in LimeSurvey?|Set up your survey to use JavaScript]]&lt;br /&gt;
#Create a Multiple Options or List (radio) question with sequential response codes. &lt;br /&gt;
#Set the &amp;quot;Random order&amp;quot; question setting to &amp;quot;Randomize on each page load&amp;quot;.&lt;br /&gt;
#Place the following script in the source of the question&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;	&lt;br /&gt;
 &lt;br /&gt;
	$(document).ready(function() {&lt;br /&gt;
 &lt;br /&gt;
		// Identify this question&lt;br /&gt;
		var qID = {QID}; &lt;br /&gt;
 &lt;br /&gt;
		// Find the number of answers&lt;br /&gt;
		var ansCount = $(&#039;#question&#039;+qID+&#039; li.answer-item&#039;).length;&lt;br /&gt;
 &lt;br /&gt;
		// Place the last answer created at the end of the list&lt;br /&gt;
		var answer = $( &#039;input[id$=&amp;quot;X&#039;+qID+ansCount+&#039;&amp;quot;]&#039;);&lt;br /&gt;
		var answerItem = $(answer).closest(&#039;li&#039;);&lt;br /&gt;
		var answersList = $(answer).closest(&#039;ul&#039;);&lt;br /&gt;
		$(answersList).append(answerItem);&lt;br /&gt;
 &lt;br /&gt;
	});&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Download sample survey:&#039;&#039;&#039;&amp;lt;br /&amp;gt;&lt;br /&gt;
[[Media:Partially_Ranomized_Answers.lss|Partially_Ranomized_Answers.lss]]&lt;br /&gt;
&lt;br /&gt;
=Partially Randomized Answers - Multiple Options &amp;amp; List (radio) questions (Enhanced)=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 2.05&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround allows the answers of Multiple Options &amp;amp; List (radio) questions to be randomized while always keeping a specified number of answers fixed at the end of the list. It&#039;s useful if you want to randomize, say, the first 4 of your answers but always have the fifth and sixth displayed last as in the image below:&lt;br /&gt;
&lt;br /&gt;
[[File:Partially_Randomized_Answers_Enhanced_1.png]]&lt;br /&gt;
&lt;br /&gt;
After the LimeSurvey randomizing has occurred a function in the source of a question moves the answer with the highest answer code to the end of the list.&lt;br /&gt;
&lt;br /&gt;
Some conditions on the use of this are:&lt;br /&gt;
*The &amp;quot;Show No answer&amp;quot; survey setting must be set to &amp;quot;No&amp;quot; &lt;br /&gt;
*You must use sequential numbers, starting at 1 as response codes. (See image below)&lt;br /&gt;
&lt;br /&gt;
[[File:Partially_Randomized_Answers_Enhanced_2.png]]&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#[[Workarounds: Manipulating a survey at runtime using Javascript#How to use Script (eg. JavaScript etc.) in LimeSurvey?|Set up your survey to use JavaScript]]&lt;br /&gt;
#Create a Multiple Options or List (radio) question with sequential response codes. &lt;br /&gt;
#Set the &amp;quot;Random order&amp;quot; question setting to &amp;quot;Randomize on each page load&amp;quot;.&lt;br /&gt;
#Place the following script in the source of the question.&lt;br /&gt;
#Modify the &amp;quot;fixedAnswers&amp;quot; variable as required.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;	&lt;br /&gt;
	&lt;br /&gt;
	$(document).ready(function() {&lt;br /&gt;
	&lt;br /&gt;
		// The number of answers to be fixed at the end of the list&lt;br /&gt;
		var fixedAnswers = 2;&lt;br /&gt;
		&lt;br /&gt;
		// Identify this question&lt;br /&gt;
		var qID = {QID}; &lt;br /&gt;
		&lt;br /&gt;
		// Find the number of answers&lt;br /&gt;
		var ansCount = $(&#039;#question&#039;+qID+&#039; li.answer-item&#039;).length;&lt;br /&gt;
		&lt;br /&gt;
		// Place the last n answers created at the end of the list&lt;br /&gt;
		var fixedIndex = fixedAnswers - 1;&lt;br /&gt;
		for (var i=0; i&amp;lt;fixedAnswers; i++) {&lt;br /&gt;
			var answer = $( &#039;input[id$=&amp;quot;X&#039;+qID+(ansCount-fixedIndex)+&#039;&amp;quot;]&#039;);&lt;br /&gt;
			var answerItem = $(answer).closest(&#039;li&#039;);&lt;br /&gt;
			var answersList = $(answer).closest(&#039;ul&#039;);&lt;br /&gt;
			$(answersList).append(answerItem);&lt;br /&gt;
			fixedIndex--;&lt;br /&gt;
		}		&lt;br /&gt;
	});&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Download sample survey:&#039;&#039;&#039;&amp;lt;br /&amp;gt;&lt;br /&gt;
[[Media:Partially_Randomized_Answers_Enhanced.lss|Partially_Randomized_Answers_Enhanced.lss]]&lt;br /&gt;
&lt;br /&gt;
=Partially Randomized Answers - List (dropdown) questions=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 6/7, FireFox 3.0, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround, similar to the one above, allows the answers of List (dropdown) questions to be randomized while always keeping one answer at the end of the list. It&#039;s useful if you want to randomize, say, the first 4 of your answers but always have the fifth displayed last.&lt;br /&gt;
&lt;br /&gt;
A script is placed in the source of a question. After the randomizing has occurred this script moves the answer with the highest answer code to the end of the list.&lt;br /&gt;
&lt;br /&gt;
There is a demo [http://www.partnersinc.biz/surveys//index.php?sid=89344&amp;amp;newtest=Y&amp;amp;lang=en here].&lt;br /&gt;
&lt;br /&gt;
A condition is that you must use sequential numbers, starting at 1 as response codes. (See image below)&lt;br /&gt;
&lt;br /&gt;
[[File:random_700x154.png]]&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#Turn off &#039;&#039;$filterxsshtml&#039;&#039; to allow insertion of JavaScript in the questions. (See [[Optional settings#Security|documentation here]])&lt;br /&gt;
#Create one or more List (dropdown) questions with sequential response codes. Set the [[Advanced question settings#random order|random_order question attribute]] to 1.&lt;br /&gt;
#In the source of the first question add the following onload function. (See [[Workarounds: Manipulating a survey at runtime using Javascript#How to use Script (eg. JavaScript etc.) in LimeSurvey?|How to use script here]])&lt;br /&gt;
#Replace &amp;quot;SSSSS&amp;quot;, &amp;quot;GG&amp;quot;, &amp;quot;QQ&amp;quot; in the function call at the end with the survey ID, group ID and question ID respectively.&lt;br /&gt;
#If you want to apply it to more questions on the same page simply add more calls with the appropriate IDs. (eg. partRandDD(11111, 22, 1); partRandDD(11111, 22, 2); ...)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
		// Function to allow randomization of all answers&lt;br /&gt;
		//except the last one in List/dropdown questions&lt;br /&gt;
		function partRandDD(sID, gID, qID) {&lt;br /&gt;
&lt;br /&gt;
			// Find the number of answers&lt;br /&gt;
			var ansCount = &#039;&#039;&lt;br /&gt;
			$( &#039;div#question&#039; + qID + &#039; select option&#039; ).each(function(i) {&lt;br /&gt;
				ansCount = i;&lt;br /&gt;
			});&lt;br /&gt;
&lt;br /&gt;
			// Place the last answer created at the end of the list&lt;br /&gt;
			$( &#039;option[value=&amp;quot;&#039; + ansCount + &#039;&amp;quot;]&#039; ).appendTo($( &#039;div#question&#039; + qID + &#039; select&#039; ));&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		// Call the function with the SID, GID and QID&lt;br /&gt;
		partRandDD(89344, 72, 244);&lt;br /&gt;
&lt;br /&gt;
	});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Partially Randomized Answers - Multiple numerical input=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, Safari 5.1&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround, similar to the ones above, allows the answers of Multiple numerical input questions to be randomized while always keeping one answer at the end of the list. It&#039;s useful if you want to randomize, say, the first 4 of your answers but always have the fifth displayed last.&lt;br /&gt;
&lt;br /&gt;
An onload function is placed in the source of a question. After the randomizing has occurred this function moves the answer with the highest answer code to the end of the list.&lt;br /&gt;
&lt;br /&gt;
A condition is that you must use sequential numbers, starting at 1 as response codes. (See image below)&lt;br /&gt;
&lt;br /&gt;
[[File:random_700x154.png]]&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#Turn off &#039;&#039;$filterxsshtml&#039;&#039; to allow insertion of JavaScript in the questions. (See [[Optional settings#Security|documentation here]])&lt;br /&gt;
#Create one or more Multiple numerical input question with sequential response codes. Set the [[Advanced question settings#random order|random_order question attribute]] to 1.&lt;br /&gt;
#In the source of the first question add the following onload function. (See [[Workarounds: Manipulating a survey at runtime using Javascript#How to use Script (eg. JavaScript etc.) in LimeSurvey?|How to use script here]])&lt;br /&gt;
#Replace &amp;quot;SSSSS&amp;quot;, &amp;quot;GG&amp;quot;, &amp;quot;QQ&amp;quot; in the function call at the end with the survey ID, group ID and question ID respectively.&lt;br /&gt;
#If you want to apply it to more questions on the same page simply add more calls with the appropriate IDs. (eg. partRandDD(11111, 22, 1); partRandDD(11111, 22, 2); ...)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
		// Function to allow randomization of all answers except the last one in multiple numeric input questions&lt;br /&gt;
		function partRand(sID, gID, qID) {&lt;br /&gt;
&lt;br /&gt;
			// Find the number of answers&lt;br /&gt;
			var ansCount = &#039;&#039;&lt;br /&gt;
			$( &#039;div#question&#039; + qID + &#039; div.answers li&#039; ).each(function(i) {&lt;br /&gt;
				ansCount = (i - 1);&lt;br /&gt;
			});&lt;br /&gt;
&lt;br /&gt;
			// Place the last answer created at the end of the list - but before the first helping sum&lt;br /&gt;
			$( &#039;li#javatbd&#039; + sID + &#039;X&#039; + gID + &#039;X&#039; + qID + ansCount + &#039;&#039; ).insertBefore($( &#039;div#question&#039; + qID + &#039; div.answers li.multiplenumerichelp&#039; ).first());&lt;br /&gt;
&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		// Call the function with the SID, GID and QID&lt;br /&gt;
		partRand(SID, GID, QID);&lt;br /&gt;
&lt;br /&gt;
	});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using this solution for Multiple numerical input questions might be a bit more complicated than for other question types. All answers are organized in an unordered list (&amp;lt;nowiki&amp;gt;&amp;lt;ul&amp;gt;&amp;lt;/nowiki&amp;gt;) structure. However, if advanced question settings like &#039;&#039;Equals sum value&#039;&#039; are used, LimeSurvey adds helping information (e.g. sum of all entries and remainder) to the same unordered list using the class &#039;&#039;multiplenumerichelp&#039;&#039; for these additional list items. The above example  assumes that at least one of these list items is present and moves the last answer to the position right above the first helper item. Without such advanced settings, the code will most certainly need adaptation.&lt;br /&gt;
&lt;br /&gt;
=Making one (or more) rows of an array mandatory=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 6/7, Firefox 3.0, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround allows you to define one or more rows of an array question as mandatory (instead of all of them which the &amp;quot;Mandatory&amp;quot; question setting does). It is [http://www.partnersinc.biz/surveys//index.php?sid=26842&amp;amp;newtest=Y&amp;amp;lang=en demonstrated here].&lt;br /&gt;
&lt;br /&gt;
A JavaScript function interrupts the submit function and checks if the inputs in the mandatory row(s) are populated. If not, an alert is popped up, the offending inputs are turned pink and the submit is aborted. Otherwise the submit goes ahead.&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#Turn off &#039;&#039;$filterxsshtml&#039;&#039; to allow insertion of JavaScript in the questions (see [[Optional settings#Security|documentation here]]).&lt;br /&gt;
#Create the array question.&lt;br /&gt;
#In the source of the array question add the following script (see [[Workarounds: Manipulating a survey at runtime using Javascript#How to use Script (eg. JavaScript etc.) in LimeSurvey?|How to use script here]]).&lt;br /&gt;
#Modify the warningText (line10)as required.&lt;br /&gt;
#Replace &amp;quot;QQ&amp;quot; (lines 13 and 14)  with the question ID and add calls as necessary for more rows - the example code renders rows 1 and 3 mandatory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	$(document).ready(function () {&lt;br /&gt;
&lt;br /&gt;
		// Interrupt the submit function&lt;br /&gt;
		$(&#039;form#limesurvey&#039;).submit(function () {&lt;br /&gt;
&lt;br /&gt;
			// Override the built-in &amp;quot;disable navigation buttons&amp;quot; feature&lt;br /&gt;
			$(&#039;#moveprevbtn, #movenextbtn, #movesubmitbtn&#039;).attr(&#039;disabled&#039;, &#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
			var empty = 0;&lt;br /&gt;
			var warningText = &#039;Please complete the highlighted inputs.&#039;;&lt;br /&gt;
&lt;br /&gt;
			// Call the mandatory row function with question IDs and row numbers&lt;br /&gt;
			mandatoryRow(QQ, 1);&lt;br /&gt;
			mandatoryRow(QQ, 3);&lt;br /&gt;
&lt;br /&gt;
			// A function to render rows of an array mandatory&lt;br /&gt;
			function mandatoryRow(qID, rowNum) {&lt;br /&gt;
&lt;br /&gt;
				$(&#039;div#question&#039; + qID + &#039; table.question tbody[id^=&amp;quot;javatbd&amp;quot;]:eq(&#039; + Number(rowNum - 1) + &#039;) input[type=&amp;quot;text&amp;quot;]&#039;).each(function (i) {&lt;br /&gt;
&lt;br /&gt;
					if ($(this).val() == &#039;&#039;) {&lt;br /&gt;
						$(this).css(&#039;background-color&#039;, &#039;pink&#039;);&lt;br /&gt;
						empty = 1;&lt;br /&gt;
					} &lt;br /&gt;
					else {&lt;br /&gt;
						$(this).css(&#039;background-color&#039;, &#039;#FFFFFF&#039;);&lt;br /&gt;
					}&lt;br /&gt;
				});&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			if (empty == 1) {&lt;br /&gt;
				alert(warningText);&lt;br /&gt;
				return false;&lt;br /&gt;
			} &lt;br /&gt;
			else {&lt;br /&gt;
				return true;&lt;br /&gt;
			}&lt;br /&gt;
		});&lt;br /&gt;
&lt;br /&gt;
	});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Randomly displaying one of a few YouTube videos, and recording which was displayed=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested in 1.85+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Jason Cleeland has created and documented a method to randomly display one of a number of youtube videos in a single question, and save which one was displayed.&lt;br /&gt;
&lt;br /&gt;
http://www.aptigence.com.au/home/archives/23-Random-display-of-videos-in-a-question-2-YouTube.html&lt;br /&gt;
&lt;br /&gt;
=Randomly displaying one of a few pictures, and recording which was displayed=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested in 1.91+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The following steps allow you to randomly display one of a few pictures and record in the dataset which picture was displayed. We use four pictures in this example, but you can easily adapt these scripts according to your needs.&lt;br /&gt;
&lt;br /&gt;
1. Create a new sub-directory &#039;&#039;&#039;pic&#039;&#039;&#039; in your LimeSurvey folder.&lt;br /&gt;
&lt;br /&gt;
2. Copy four pictures (named &#039;&#039;1.jpg&#039;&#039;, &#039;&#039;2.jpg&#039;&#039;, &#039;&#039;3.jpg&#039;&#039;, and &#039;&#039;4.jpg&#039;&#039;) in this pic sub-directory.&lt;br /&gt;
&lt;br /&gt;
3. Deactivate the &#039;&#039;Filter HTML for XSS&#039;&#039; function in LimeSurvey&#039;s &#039;&#039;Global Settings&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
4. Create a &#039;&#039;&#039;Short free text&#039;&#039;&#039; question where you want these pictures to be displayed.&lt;br /&gt;
&lt;br /&gt;
5. Figure out the [[SGQA identifier|SGQA Identifier]] of this question (e.g., 12345X67X89).&lt;br /&gt;
&lt;br /&gt;
6. Paste the following code as question text after activating the editor&#039;s &#039;&#039;Source&#039;&#039; view and replace both SSSSSXGGXQQ strings with your SGQA identifier:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please have a look at this picture:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$(document).ready(&lt;br /&gt;
&lt;br /&gt;
function(){&lt;br /&gt;
&lt;br /&gt;
// Find a random number (here between 1 and 4)&lt;br /&gt;
&lt;br /&gt;
var randNumber = Math.floor(Math.random()*4 + 1);&lt;br /&gt;
&lt;br /&gt;
// Save the number as answer of this question&lt;br /&gt;
&lt;br /&gt;
$(&#039;input#answerSSSSSXGGXQQ&#039;).val(randNumber);&lt;br /&gt;
&lt;br /&gt;
// Hide this answer field&lt;br /&gt;
&lt;br /&gt;
document.getElementById(&amp;quot;answerSSSSSXGGXQQ&amp;quot;).style.display=&#039;none&#039;;&lt;br /&gt;
&lt;br /&gt;
// Show the picture&lt;br /&gt;
&lt;br /&gt;
picString = &#039;&amp;lt;img src=&amp;quot;pic/&#039; + String(randNumber) + &#039;.jpg&amp;quot;&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
document.getElementById(&#039;pic&#039;).innerHTML = picString;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;pic&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to display the number of this picture in a later question, use the following code as question text (don&#039;t forget to replace the SSSSSXGGXQQ string acordingly):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You saw picture number {INSERTANS:SSSSSXGGXQQ}.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Perhaps you want to display the same picture again in a later question, but a little bit smaller (100px width, 100px height)? Just paste the following code as question text after activating the editor&#039;s &#039;&#039;Source&#039;&#039; view, and replace the SSSSSXGGXQQ string acordingly:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here you see the picture again: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$(document).ready(&lt;br /&gt;
&lt;br /&gt;
function(){&lt;br /&gt;
&lt;br /&gt;
// Get the picture number from previous question&lt;br /&gt;
&lt;br /&gt;
var randNumber = &amp;quot;{INSERTANS:SSSSSXGGXQQ}&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
// Show picture&lt;br /&gt;
&lt;br /&gt;
picString = &#039;&amp;lt;img width=&amp;quot;100&amp;quot; height=&amp;quot;100&amp;quot; src=&amp;quot;pic/&#039; + String(randNumber) + &#039;.jpg&amp;quot;&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
document.getElementById(&#039;pic&#039;).innerHTML = picString;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;pic&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Multiple numerical input with max_num_value defined in token (personalized limit)=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested in 1.85+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, max_num_value can be an experession, so you can simply enter the {TOKEN} or other variable in that question attribute.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To make personalized survey with multiple numerical input when max_num_value (Maximum sum value) is different for each user and is loaded from the token use following tricks:&lt;br /&gt;
*Create 1st group with numerical input field (1000X10X11). &amp;quot;Limit&amp;quot;&lt;br /&gt;
*Add java script into this question:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
function Custom_On_Load(){&lt;br /&gt;
&lt;br /&gt;
  document.getElementById(&#039;answer1000X10X11&#039;).value=&#039;{TOKEN:ATTRIBUTE_1}&#039;;&lt;br /&gt;
&lt;br /&gt;
  document.getElementById(&#039;answer1000X10X11&#039;).readOnly=1;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where:&lt;br /&gt;
&lt;br /&gt;
TOKEN:ATTRIBUTE_1 is individual limit defined in token.&lt;br /&gt;
&lt;br /&gt;
readOnly=1 // user shouldn&#039;t change it.&lt;br /&gt;
*Create 2nd group with multiple numerical input and add &amp;quot;Max value from SGQA&amp;quot; with 1000X10X11 as argument.&lt;br /&gt;
&lt;br /&gt;
Note: If you don&#039;t want to show first field with numerical input (and show definied limit in different way) you can add 2 lines to above script to hide whole question:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
document.getElementById(&#039;question85&#039;).style.display=&#039;none&#039;;&lt;br /&gt;
&lt;br /&gt;
document.getElementById(&#039;display85&#039;).value=&#039;&#039;;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where:&lt;br /&gt;
&lt;br /&gt;
question85 and display85 are field names.&lt;br /&gt;
&lt;br /&gt;
Note: It&#039;s no possible to create it into one group, because all SGQA references can only refer to data on a previous page because when clicking next the answer is stored at the DB and the SGQA is replaced by querying the database.&lt;br /&gt;
&lt;br /&gt;
=Default values in array questions=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 2.05+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround uses JavaScript to allow you to pre-check default answers in all sub-questions of an array type question. You can select a column of the array to be checked as the page loads. The script first checks to see if a sub-question has already been answered and, if not, checks the default answer.&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#[[Workarounds: Manipulating a survey at runtime using Javascript#How to use Script (eg. JavaScript etc.) in LimeSurvey?|Set up your survey to use script]].&lt;br /&gt;
#Create the array question.&lt;br /&gt;
#In the source of the array question add the following script.&lt;br /&gt;
#Replace&amp;quot;QQ&amp;quot; with the question ID and &amp;quot;CC&amp;quot; with the column number to be checked.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;	&lt;br /&gt;
	$(document).ready(function() {&lt;br /&gt;
		// A function to pre-check a column of an array&lt;br /&gt;
		function checkedDefault(qID, column) {&lt;br /&gt;
			var checkedCol = column - 1;&lt;br /&gt;
			$(&#039;#question&#039;+qID+&#039; tr.subquestions-list&#039;).each(function(i) {&lt;br /&gt;
				if ($(&#039;input.checkbox:checked&#039;, this).length == 0) {&lt;br /&gt;
					$(&#039;input.checkbox:eq(&#039;+checkedCol+&#039;)&#039;, this).prop(&#039;checked&#039;, true);&lt;br /&gt;
					$(&#039;input.checkbox:eq(&#039;+checkedCol+&#039;)&#039;, this).parent().find(&#039;input[type=&amp;quot;hidden&amp;quot;]&#039;).val(1);&lt;br /&gt;
				}&lt;br /&gt;
			});&lt;br /&gt;
		}&lt;br /&gt;
		// Call the function with a question ID and column number&lt;br /&gt;
		checkedDefault(QQ, CC);&lt;br /&gt;
	});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Default Values In One Scale Of A Dual-scale Array Question=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 2.0+, IE 9/10, Firefox 24&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Overview&#039;&#039;&#039;&amp;lt;br /&amp;gt;&lt;br /&gt;
This workaround uses JavaScript to allow you to pre-check default answers in all sub-questions of one scale of a dual-scale-array type question. You can select a scale and a column of that scale to be checked. The script first checks to see if a sub-question has already been answered and, if not, checks the default answer.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Implementation:&#039;&#039;&#039;&lt;br /&gt;
#[[Workarounds: Manipulating a survey at runtime using Javascript#How to use Script (eg. JavaScript etc.) in LimeSurvey?|Set up your survey to use script]].&lt;br /&gt;
#Create the array question.&lt;br /&gt;
#In the source of the array question add the following script.&lt;br /&gt;
#Adjust &amp;quot;&#039;&#039;defaultAnsweredScale&#039;&#039;&amp;quot; and &amp;quot;&#039;&#039;defaultAnsweredColumn&#039;&#039;&amp;quot; as necessary.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;	&lt;br /&gt;
 &lt;br /&gt;
	$(document).ready(function() {&lt;br /&gt;
  &lt;br /&gt;
		// Scale to set the default answer on&lt;br /&gt;
		var defaultAnsweredScale = 2; &lt;br /&gt;
		// Column of that scale to set as default answer&lt;br /&gt;
		var defaultAnsweredColumn = 3;&lt;br /&gt;
		&lt;br /&gt;
		// Identify this question&lt;br /&gt;
		var thisQuestion = $(&#039;#question{self.qid}&#039;);&lt;br /&gt;
		&lt;br /&gt;
		// Identify the scales and columns&lt;br /&gt;
		$(&#039;.answer-item[class^=&amp;quot;answer_cell_1&amp;quot;]&#039;, thisQuestion).addClass(&#039;scale-1-item&#039;);&lt;br /&gt;
		$(&#039;.answer-item[class^=&amp;quot;answer_cell_2&amp;quot;]&#039;, thisQuestion).addClass(&#039;scale-2-item&#039;);&lt;br /&gt;
		$(&#039;tr.answers-list&#039;, thisQuestion).each(function(i) {&lt;br /&gt;
			$(&#039;.scale-1-item&#039;, this).each(function(i) {&lt;br /&gt;
				$(this).addClass(&#039;scale-1-column-&#039;+(i+1)+&#039;-item&#039;);&lt;br /&gt;
			});&lt;br /&gt;
			$(&#039;.scale-2-item&#039;, this).each(function(i) {&lt;br /&gt;
				$(this).addClass(&#039;scale-2-column-&#039;+(i+1)+&#039;-item&#039;);&lt;br /&gt;
			});&lt;br /&gt;
		});&lt;br /&gt;
		&lt;br /&gt;
		// Click the default answers&lt;br /&gt;
		$(&#039;tr.answers-list&#039;, thisQuestion).each(function(i) {&lt;br /&gt;
			if($(&#039;.scale-&#039;+defaultAnsweredScale+&#039;-item input[type=&amp;quot;radio&amp;quot;]:checked&#039;, this).length == 0) {&lt;br /&gt;
				$(&#039;.scale-&#039;+defaultAnsweredScale+&#039;-column-&#039;+defaultAnsweredColumn+&#039;-item input[type=&amp;quot;radio&amp;quot;]:last&#039;, this).click();&lt;br /&gt;
			}&lt;br /&gt;
		});&lt;br /&gt;
	});&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Download sample survey:&#039;&#039;&#039;&amp;lt;br /&amp;gt;&lt;br /&gt;
[[Media:Dual_scale_with_default_answers.lss|Dual_scale_with_default_answers.lss]]&lt;br /&gt;
&lt;br /&gt;
=Record group view time=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.87+ (8518), IE 6/7, Firefox 3.5, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, group view time is accurately recorded in the timings table if you choose the Record Timings survey option.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround uses JavaScript to populate a hidden question with the total time that a respondent views a group. If used in a group with only one question, it could be used to track the amount of time required to answer the question.&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#[[Workarounds: Manipulating a survey at runtime using Javascript#How to use Script (eg. JavaScript etc.) in LimeSurvey?|Set up your survey to use JavaScript]].&lt;br /&gt;
#In the group, create a short-text question. We will hide this later with JavaScript and populate it with the elapsed time.&lt;br /&gt;
#Place the following script in the source of the short-text question.&lt;br /&gt;
#Replace &amp;quot;QQ&amp;quot; in line 6 with the ID of the short-text question.&lt;br /&gt;
&lt;br /&gt;
The script populates the hidden question with the elapsed time since the group was opened. If a respondent leaves the group and then returns, the timer continues up from the elapsed time of the last visit.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function(){&lt;br /&gt;
&lt;br /&gt;
       // call the functions with the hidden timer question ID&lt;br /&gt;
&lt;br /&gt;
       runTimer(QQ);&lt;br /&gt;
&lt;br /&gt;
       function runTimer(timeQID) {&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+timeQID).hide();&lt;br /&gt;
&lt;br /&gt;
           var initSec = &#039;0&#039;;&lt;br /&gt;
&lt;br /&gt;
           // Check for elapsed time from previous visits&lt;br /&gt;
&lt;br /&gt;
           if ($(&#039;#question&#039;+timeQID+&#039; input.text&#039;).val()) {&lt;br /&gt;
&lt;br /&gt;
               var initTime = $(&#039;#question&#039;+timeQID+&#039; input.text&#039;).val();&lt;br /&gt;
&lt;br /&gt;
               initTimeArr = initTime.split(&#039;:&#039;);&lt;br /&gt;
&lt;br /&gt;
               initSec = Number[[initTimeArr[0]*3600]]+Number[[initTimeArr[1]*60]]+Number(initTimeArr[2]);&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
           // Run the timer update function&lt;br /&gt;
&lt;br /&gt;
           recordTime(initSec, timeQID);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   // Timer update function&lt;br /&gt;
&lt;br /&gt;
   function recordTime(elapsedSec, timeQID){&lt;br /&gt;
&lt;br /&gt;
       elapsedSec++;&lt;br /&gt;
&lt;br /&gt;
       var h = Math.floor(elapsedSec / 3600);&lt;br /&gt;
&lt;br /&gt;
       var m = Math.floor(elapsedSec % 3600 / 60);&lt;br /&gt;
&lt;br /&gt;
       var s = Math.floor(elapsedSec % 3600 % 60);&lt;br /&gt;
&lt;br /&gt;
       var elapsedTime = [[h &amp;gt; 0 ? h + &amp;quot;:&amp;quot; : &amp;quot;00:&amp;quot;) + (m &amp;gt; 0 ? (m &amp;lt; 10 ? &amp;quot;0&amp;quot; : &amp;quot;&amp;quot;) + m + &amp;quot;:&amp;quot; : &amp;quot;00:&amp;quot;) + (s &amp;lt; 10 ? &amp;quot;0&amp;quot; : &amp;quot;&amp;quot;) + s);&lt;br /&gt;
&lt;br /&gt;
        $(&#039;#question&#039;+timeQID+&#039; input.text&#039;).val(elapsedTime);&lt;br /&gt;
&lt;br /&gt;
        // Run the timer update function every second&lt;br /&gt;
&lt;br /&gt;
        setTimeout(&#039;recordTime(&#039;+elapsedSec+&#039;, &#039;+timeQID+&#039;)&#039;,1000);&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Toggle visibility of groups=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 6/7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround uses JavaScript to toggle the visibility of groups in an &amp;quot;all in one&amp;quot; survey. Initially the groups are hidden and there are links inserted to display the groups. It&#039;s useful to avoid the page being cluttered with many groups and lets the respondent focus on one at a time.&lt;br /&gt;
&lt;br /&gt;
It&#039;s [http://www.partnersinc.biz/surveys//index.php?sid=33613&amp;amp;newtest=Y&amp;amp;lang=en demonstrated here].&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
&lt;br /&gt;
#[[Workarounds: Manipulating a survey at runtime using Javascript#How to use Script (eg. JavaScript etc.) in LimeSurvey?|Set up your survey to use JavaScript]].&lt;br /&gt;
#Set the survey to run in &amp;quot;all in one&amp;quot; mode.&lt;br /&gt;
#Add your groups and questions.&lt;br /&gt;
#Place the following script in the source of one of the questions in the first group.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The comments in the script are pretty self-explanatory but it does the following:&lt;br /&gt;
&lt;br /&gt;
#initially hides all of the groups&lt;br /&gt;
#inserts a link above each one to toggle its display&lt;br /&gt;
#some styles are added to the clickable links but these could be done in template.css instead&lt;br /&gt;
#shows any groups that have an unanswered mandatory after a submit attempt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	$(document).ready(function(){&lt;br /&gt;
&lt;br /&gt;
		// Insert show/hide divs before all group wrapper divs&lt;br /&gt;
		$(&#039;&amp;lt;div class=&amp;quot;groupToggler&amp;quot;&amp;gt;&amp;lt;span&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;/div&amp;gt;&#039;).insertBefore(&#039;div[id^=&amp;quot;group-&amp;quot;]&#039;);&lt;br /&gt;
		&lt;br /&gt;
		// Add some text to the show/hide divs&lt;br /&gt;
		$(&#039;.groupToggler span&#039;).each(function(i) {&lt;br /&gt;
			($( this ).text(&#039;Show/Hide Group &#039;+(i+1)+&#039;&#039;));&lt;br /&gt;
		});&lt;br /&gt;
		&lt;br /&gt;
		// Add some styles to the show/hide divs&lt;br /&gt;
		$(&#039;.groupToggler&#039;).css({&lt;br /&gt;
			&#039;padding&#039;:&#039;5px 0 10px 0&#039;,&lt;br /&gt;
			&#039;text-align&#039;:&#039;center&#039;&lt;br /&gt;
		});&lt;br /&gt;
		$(&#039;.groupToggler span&#039;).css({&lt;br /&gt;
			&#039;text-decoration&#039;:&#039;underline&#039;,			&lt;br /&gt;
			&#039;cursor&#039;:&#039;pointer&#039;&lt;br /&gt;
		});&lt;br /&gt;
		&lt;br /&gt;
		// Add some hover effects to the show/hide divs&lt;br /&gt;
		$(&amp;quot;.groupToggler span&amp;quot;).hover(&lt;br /&gt;
			function () {&lt;br /&gt;
				$(this).css({&lt;br /&gt;
					&#039;text-decoration&#039;:&#039;none&#039;,&lt;br /&gt;
					&#039;font-weight&#039;:&#039;bold&#039;&lt;br /&gt;
				});&lt;br /&gt;
			}, &lt;br /&gt;
			function () {&lt;br /&gt;
				$(this).css({&lt;br /&gt;
					&#039;text-decoration&#039;:&#039;underline&#039;,&lt;br /&gt;
					&#039;font-weight&#039;:&#039;normal&#039;&lt;br /&gt;
				});&lt;br /&gt;
			}&lt;br /&gt;
		);&lt;br /&gt;
		&lt;br /&gt;
		// Initially hide all of the groups&lt;br /&gt;
		// Toggle their visibility when the show/hide is clicked&lt;br /&gt;
		$(&#039;.groupToggler span&#039;).click(function() {&lt;br /&gt;
			$(this).parent().next().toggle();&lt;br /&gt;
			return false;&lt;br /&gt;
		}).parent().next().hide();&lt;br /&gt;
		&lt;br /&gt;
		// Display any groups that have unanswered mandatories&lt;br /&gt;
		$(&#039;.errormandatory&#039;).parents(&#039;div[id^=&amp;quot;group-&amp;quot;]&#039;).show();&lt;br /&gt;
		&lt;br /&gt;
		// Some tidying up&lt;br /&gt;
		$(&#039;h1&#039;).next().next().hide();&lt;br /&gt;
		$(&#039;.surveywelcome&#039;).css({&#039;margin-bottom&#039;:&#039;10px&#039;});&lt;br /&gt;
		$(&#039;.surveywelcome&#039;).next().hide();&lt;br /&gt;
		$(&#039;.surveywelcome&#039;).next().next().hide();&lt;br /&gt;
&lt;br /&gt;
	});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Use jQuery Autocomplete plugin to suggest answers for text inputs=&lt;br /&gt;
&lt;br /&gt;
== 1.90 and previous versions==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 6/7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround uses the [http://docs.jquery.com/Plugins/Autocomplete jQuery Autocomplete] plugin to provide a respondent a list of suggested answers that the they can select from as they type in a text input.&lt;br /&gt;
&lt;br /&gt;
Although the plugin allows for much more complex applications, the two that I use most frequently are outlined below. The first method uses a relatively small list of suggestions that is stored in an array locally. The second is a little more complex - it uses a remote CSV file of suggestions that is accessed through AJAX an PHP.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve put together a small demonstration [http://www.partnersinc.biz/surveys//index.php?sid=78611&amp;amp;newtest=Y&amp;amp;lang=en here] and implementation is as follows.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Both methods:&#039;&#039;&#039;&lt;br /&gt;
*[http://docs.jquery.com/Plugins/Autocomplete Download the plugin]&lt;br /&gt;
*Place the files &#039;&#039;jquery.autocomplete.css&#039;&#039; and &#039;&#039;jquery.autocomplete.js&#039;&#039; in your template directory&lt;br /&gt;
*Add the following code inside the &amp;lt;head&amp;gt; element of startpage.pstpl&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;{TEMPLATEURL}jquery.autocomplete.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;link rel=&amp;quot;stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot; href=&amp;quot;{TEMPLATEURL}jquery.autocomplete.css&amp;quot; /&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Method 1 (&amp;quot;States&amp;quot; question in the demo):&#039;&#039;&#039;&lt;br /&gt;
*Create a text input question&lt;br /&gt;
*Add the following script to the source of the text question&lt;br /&gt;
*Replace &amp;quot;QQ&amp;quot; with the ID of the text input question&lt;br /&gt;
*Replace the states with your list of suggestions (comma separated)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
		var q1ID = QQ;&lt;br /&gt;
&lt;br /&gt;
		var states = &amp;quot;Alabama,Alaska,Arizona,Arkansas,California,Colorado,Connecticut,Delaware, District of Columbia,Florida,Georgia,Hawaii,Idaho,Illinois,Indiana,Iowa,Kansas,Kentucky, Louisiana,Maine,Montana,Nebraska,Nevada,New Hampshire,New Jersey,New Mexico,New York, North Carolina,North Dakota,Ohio,Oklahoma,Oregon,Maryland,Massachusetts,Michigan, Minnesota,Mississippi,Missouri,Pennsylvania,Rhode Island,South Carolina,South Dakota, Tennessee,Texas,Utah,Vermont,Virginia,Washington,West Virginia,Wisconsin,Wyoming&amp;quot;.split(&#039;,&#039;);&lt;br /&gt;
&lt;br /&gt;
		$(&#039;#question&#039;+q1ID+&#039; input.text&#039;).autocomplete(states, {&lt;br /&gt;
			matchContains: true,&lt;br /&gt;
			minChars: 0&lt;br /&gt;
		});&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Method 2 (&amp;quot;Countries&amp;quot; question in the demo):&#039;&#039;&#039;&lt;br /&gt;
*Place the CSV file of suggestions in your template directory. &lt;br /&gt;
*Place a PHP file containing the code below in your template directory&lt;br /&gt;
*Replace &amp;quot;countries2.csv&amp;quot; with your CSV filename (you could make this more universal by passing the filename in the URL)&lt;br /&gt;
*This file will grab the contents of the CSV and encode them in JSON format that the JavaScript can use&lt;br /&gt;
*Place the JavaScript code below in ths source of the text question&lt;br /&gt;
*Replace &amp;quot;QQ&amp;quot; with the ID of the text input question&lt;br /&gt;
*Replace &amp;quot;templates/yourTemplate/countries.php&amp;quot; with the path to the PHP file (from LimeSurvey root)&lt;br /&gt;
*This script will grab the jsonized data from the PHP file and load it into an array that the plugin can use&lt;br /&gt;
&lt;br /&gt;
PHP code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
	$countriesArr = array();&lt;br /&gt;
&lt;br /&gt;
	$file_handle = fopen(&amp;quot;countries2.csv&amp;quot;, &amp;quot;r&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	while (!feof($file_handle) ) {&lt;br /&gt;
		$line_of_text = fgetcsv($file_handle);&lt;br /&gt;
		array_push($countriesArr, $line_of_text[0]);&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	fclose($file_handle);&lt;br /&gt;
&lt;br /&gt;
	echo json_encode($countriesArr);&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
JavaScript code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
		var qID = QQ;&lt;br /&gt;
		var url = &amp;quot;templates/yourTemplate/countries.php&amp;quot;;&lt;br /&gt;
		var countriesArr = new Array();&lt;br /&gt;
&lt;br /&gt;
		$.getJSON(url,function(data){&lt;br /&gt;
&lt;br /&gt;
			$(data).each(function(i, item){&lt;br /&gt;
				countriesArr.push(item);&lt;br /&gt;
			});&lt;br /&gt;
&lt;br /&gt;
			$(&#039;#question&#039;+qID+&#039; input.text&#039;).autocomplete(countriesArr, {&lt;br /&gt;
				matchContains: true,&lt;br /&gt;
				minChars: 0&lt;br /&gt;
			});&lt;br /&gt;
		});&lt;br /&gt;
	});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 1.91 and later versions==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.91+, IE 6/7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround uses the [http://jqueryui.com/demos/autocomplete/ Autocomplete widget] included with jQuery UI to provide a respondent a list of suggested answers that the they can select from as they type in a text input.&lt;br /&gt;
&lt;br /&gt;
Although the plugin allows for much more complex applications, the two that I use most frequently are outlined below. The first method uses a relatively small list of suggestions that is stored in an array locally. The second is a little more complex - it uses a remote CSV file of suggestions that is accessed through AJAX an PHP.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Both methods:&#039;&#039;&#039;&lt;br /&gt;
*Add the following styles to the end of your &#039;template.css&#039; file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;css&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;/* Autocomplete styles */&lt;br /&gt;
&lt;br /&gt;
ul.ui-autocomplete {&lt;br /&gt;
	width: 250px !important;&lt;br /&gt;
	padding: 5px 10px;&lt;br /&gt;
	list-style: none;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Method 1 (use local JavaScript array for data):&#039;&#039;&#039;&lt;br /&gt;
*Create a text input question&lt;br /&gt;
*Add the following script to the source of the text question&lt;br /&gt;
*Replace &amp;quot;QQ&amp;quot; with the ID of the text input question&lt;br /&gt;
*Replace the states with your list of suggestions (comma separated)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
		var q1ID = &#039;QQ&#039;;&lt;br /&gt;
&lt;br /&gt;
		var states = &amp;quot;Alabama,Alaska,Arizona,Arkansas,California,Colorado,Connecticut,Delaware, District of Columbia,Florida,Georgia,Hawaii,Idaho,Illinois,Indiana,Iowa,Kansas,Kentucky, Louisiana,Maine,Montana,Nebraska,Nevada,New Hampshire,New Jersey,New Mexico,New York, North Carolina,North Dakota,Ohio,Oklahoma,Oregon,Maryland,Massachusetts,Michigan, Minnesota,Mississippi,Missouri,Pennsylvania,Rhode Island,South Carolina,South Dakota, Tennessee,Texas,Utah,Vermont,Virginia,Washington,West Virginia,Wisconsin,Wyoming&amp;quot;.split(&#039;,&#039;);&lt;br /&gt;
&lt;br /&gt;
		$(&#039;#question&#039;+q1ID+&#039; input.text&#039;).autocomplete({&lt;br /&gt;
			source: states&lt;br /&gt;
		});&lt;br /&gt;
&lt;br /&gt;
	});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Method 2 (use remote CSV file for data):&#039;&#039;&#039;&lt;br /&gt;
*Place the CSV file of suggestions in your template directory&lt;br /&gt;
*Place a PHP file containing the code below in your template directory&lt;br /&gt;
*Replace &amp;quot;countries2.csv&amp;quot; with your CSV filename (you could make this more universal by passing the filename in the URL)&lt;br /&gt;
*This file will grab the contents of the CSV and encode them in JSON format that the JavaScript can use&lt;br /&gt;
*Place the JavaScript code below in ths source of the text question&lt;br /&gt;
*Replace &amp;quot;QQ&amp;quot; with the ID of the text input question&lt;br /&gt;
*Replace &amp;quot;templates/yourTemplate/countries.php&amp;quot; with the path to the PHP file (from LimeSurvey root)&lt;br /&gt;
*This script will grab the jsonized data from the PHP file and load it into an array that the plugin can use&lt;br /&gt;
&lt;br /&gt;
PHP code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
	$countriesArr = array();&lt;br /&gt;
&lt;br /&gt;
	$file_handle = fopen(&amp;quot;countries2.csv&amp;quot;, &amp;quot;r&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	while (!feof($file_handle) ) {&lt;br /&gt;
		$line_of_text = fgetcsv($file_handle);&lt;br /&gt;
		array_push($countriesArr, $line_of_text[0]);&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	fclose($file_handle);&lt;br /&gt;
&lt;br /&gt;
	echo json_encode($countriesArr);&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
JavaScript code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
		var qID = QQ;&lt;br /&gt;
		var url = &amp;quot;templates/yourTemplate/countries.php&amp;quot;;&lt;br /&gt;
		var dataArr = [];&lt;br /&gt;
&lt;br /&gt;
		$.getJSON(url,function(data){&lt;br /&gt;
&lt;br /&gt;
			$.each(data,function(i, item){&lt;br /&gt;
				dataArr.push(item);&lt;br /&gt;
			});&lt;br /&gt;
&lt;br /&gt;
			$(&#039;#question&#039;+qID+&#039; input.text&#039;).autocomplete({&lt;br /&gt;
				source: dataArr&lt;br /&gt;
			});&lt;br /&gt;
&lt;br /&gt;
		});&lt;br /&gt;
&lt;br /&gt;
	});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
== Update for LimeSurvey 2.05+ ==&lt;br /&gt;
&#039;&#039;Tested with: 2.05+, Chrome 40, FireFox 36, Opera 27, IE 11&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;With LimeSurvey 2.05+ it is NOT necessary to:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;ol&amp;gt;&amp;lt;li&amp;gt;Download the jQuery Autocomplete widget&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Add special autocomplete styling to the survey template (tested with the Skeletonquest template by Denis Chenu)&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround builds on the previous examples, but is updated for use with newer versions of LimeSurvey. Note that the [http://jqueryui.com/demos/autocomplete/ Autocomplete widget] is already included in LimeSurvey, as part of jQuery UI.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
Autocomplete may be configured to use different types of data input, three of which will be demonstrated in the following: Plain text, CSV-files, and MySQL databases.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;1. Plain text input (the easiest, suitable for small lists or arrays).&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
To enable autocomplete of a list in plain text, simply add the following code to your question source. You will have to change qID to the question ID of the question you want the autocomplete to run in (this does not have to be the one you add the script to). In this case, the list has been added to the source directly, but you may also call the list as a predefined variable (see [http://jqueryui.com/demos/autocomplete/ jQuery website] for example):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
    $(document).ready(function() {&lt;br /&gt;
 &lt;br /&gt;
		var qID = 1;&lt;br /&gt;
 &lt;br /&gt;
		$(&#039;#question&#039;+qID+&#039; input[type=&amp;quot;text&amp;quot;]&#039;).autocomplete({&lt;br /&gt;
			minLength: 2, // This line is optional, signifies number of keystrokes before autocomplete is initiated&lt;br /&gt;
			source: [&amp;quot;Test1&amp;quot;,&amp;quot;Test2&amp;quot;,&amp;quot;Test3&amp;quot;]&lt;br /&gt;
		});&lt;br /&gt;
 &lt;br /&gt;
	});&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;2. Input from CSV file (a little trickier, requires several files. Suitable for larger lists and arrays).&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Please note that, with this method, all processing happens browser-side. Thus, the entire contents of your CSV file will be exposed, no matter where you &amp;quot;hide&amp;quot; it (it is not possible to request files from outside the webroot on your server using javascript). If any of this concerns you, please proceed to the next paragraph, which deals with autocomplete based on database queries. To enable autocomplete based on output from a CSV file, you will need the following:&lt;br /&gt;
&amp;lt;ol&amp;gt;&amp;lt;li&amp;gt;A comma-separated data file (CSV)&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;The [https://code.google.com/p/jquery-csv/ jquery.csv.js plugin] (v0.71)&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First, download the jquery.csv.js script, and place it in the template folder (may require manual FTP, rather than upload through the template manager). You will need to call this script in the head section of the survey page, which you find in startpage.pstpl. Make sure you call it &amp;lt;strong&amp;gt;before&amp;lt;/strong&amp;gt; {TEMPLATEJS}.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;{TEMPLATEURL}jquery.csv.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
To make the CSV file, you may use Microsoft Excel and &amp;quot;Save as CSV&amp;quot;. Note that Excel produces CSV files where the columns are separated by a &amp;lt;strong&amp;gt;semicolon&amp;lt;/strong&amp;gt;, not a comma. To make this work with the jquery.csv.js plugin, you will have to edit the jquery.csv.js file on line 43:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
41  $.csv = {&lt;br /&gt;
42    defaults: {&lt;br /&gt;
43      separator:&#039;,&#039;,  // Change this to: separator:&#039;;&#039;,&lt;br /&gt;
44      delimiter:&#039;&amp;quot;&#039;,&lt;br /&gt;
45      headers:true&lt;br /&gt;
46    },&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
Once the CSV file is in place, add the following javascript to your question source, using the correct question ID (qID) and url/filename for your CSV file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
                var qID = 1;&lt;br /&gt;
&lt;br /&gt;
		var surveyRoot = location.pathname.split(&#039;index.php&#039;)[0];&lt;br /&gt;
                var url = surveyRoot+&#039;datafile.csv&#039;;&lt;br /&gt;
&lt;br /&gt;
                // Create an array to hold the data&lt;br /&gt;
                var testArr = new Array();&lt;br /&gt;
&lt;br /&gt;
                // Grab the CSV contents&lt;br /&gt;
                $.get(url,function(data){&lt;br /&gt;
				&lt;br /&gt;
                        // Convert CSV contents to an array of arrays&lt;br /&gt;
                        fullArray = $.csv.toArrays(data);&lt;br /&gt;
&lt;br /&gt;
                        // Load the data array&lt;br /&gt;
                        $(fullArray).each(function(i, item){&lt;br /&gt;
                                testArr.push(item[0]);&lt;br /&gt;
			});&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
                        // Initialise the autocomplete plugin&lt;br /&gt;
                        $(&#039;#question&#039;+qID+&#039; input.text&#039;).autocomplete({&lt;br /&gt;
                                source: testArr&lt;br /&gt;
			});&lt;br /&gt;
						&lt;br /&gt;
			// console.log(data); This would be a gould place to put your debugging script. Remember to comment out or remove before going into production, to economize on server workload&lt;br /&gt;
                });&lt;br /&gt;
        });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
Now, the autocomplete should work. If not, see if your CSV file shows up under &amp;quot;Network&amp;quot; or &amp;quot;Resources&amp;quot; in your browser&#039;s inspector, and if it provides any output. Adding &amp;lt;strong&amp;gt;console.log(data);&amp;lt;/strong&amp;gt; to your javascript (as indicated) should output the data to the browser console (you&#039;ll see the contents of your CSV file), and may be useful for debugging. Note that only the data from the current function (the function, within which the text was placed) will be presented.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;3. Input from a MySQL database (trickiest, but also the most versatile and secure).&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br /&amp;gt;This method requires the following:&lt;br /&gt;
&amp;lt;ol&amp;gt;&amp;lt;li&amp;gt;Access to a MySQL database (tested with MySQL 5.5)&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;A PHP script to connect to and query the database&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First, paste the following script in your question source code, replacing for the correct question ID (qID) and the url/filename of your master PHP file (which in this case is autocomplete.php, see below):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    $(document).ready(function() {&lt;br /&gt;
		&lt;br /&gt;
		var qID = 1;&lt;br /&gt;
		&lt;br /&gt;
		$(&#039;#question&#039;+qID+&#039; input[type=&amp;quot;text&amp;quot;]&#039;).autocomplete({&lt;br /&gt;
			minLength: 2,  // This line is optional, signifies number of keystrokes before autocomplete is initiated&lt;br /&gt;
			source: &#039;autocomplete.php&#039;&lt;br /&gt;
		});&lt;br /&gt;
&lt;br /&gt;
	});&lt;br /&gt;
	&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
The structure of the database shouldn&#039;t matter too much, as long as you are using text fields. This example uses the UTF-8 character set. It is often a good idea to keep your login credentials in a separate file that you put outside of your webroot. In this case, I&#039;ve put them in a file called constant.php:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
// Login credentials&lt;br /&gt;
define(&#039;DB_SERVER&#039;, &amp;quot;localhost&amp;quot;);&lt;br /&gt;
define(&#039;DB_USER&#039;, &amp;quot;username&amp;quot;);&lt;br /&gt;
define(&#039;DB_PASSWORD&#039;, &amp;quot;password&amp;quot;);&lt;br /&gt;
define(&#039;DB_DATABASE&#039;, &amp;quot;database_name&amp;quot;);&lt;br /&gt;
define(&#039;DB_DRIVER&#039;, &amp;quot;mysql&amp;quot;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
The next file, database.php, deals with logging in to the database and performing the query that was requested through the javascript pasted above. Note that we&#039;re using the PDO convention rather than mysql_*, which has been deprecated for safety reasons (MySQLi remains a viable alternative, but is not shown here):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
// Connect and query MySQL database, using PDO&lt;br /&gt;
try {&lt;br /&gt;
  $db = new PDO(DB_DRIVER . &amp;quot;:dbname=&amp;quot; . DB_DATABASE . &amp;quot;;host=&amp;quot; . DB_SERVER . &amp;quot;;charset=utf8&amp;quot;, DB_USER, DB_PASSWORD);&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
catch(PDOException $e) {&lt;br /&gt;
    echo $e-&amp;gt;getMessage();&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
$return_arr = array();&lt;br /&gt;
 &lt;br /&gt;
if ($db)&lt;br /&gt;
{&lt;br /&gt;
	$ac_term = &amp;quot;%&amp;quot;.$_GET[&#039;term&#039;].&amp;quot;%&amp;quot;;&lt;br /&gt;
	$query = &amp;quot;SELECT * FROM table_name WHERE column_name LIKE :term&amp;quot;;&lt;br /&gt;
	$result = $db-&amp;gt;prepare($query);&lt;br /&gt;
	$result-&amp;gt;bindValue(&amp;quot;:term&amp;quot;,$ac_term); &lt;br /&gt;
	$result-&amp;gt;execute(); &lt;br /&gt;
 &lt;br /&gt;
// Fetch data and store in array&lt;br /&gt;
	while ($row = $result-&amp;gt;fetch(PDO::FETCH_ASSOC)) {&lt;br /&gt;
		$row_array[&#039;label&#039;] = $row[&#039;column_name&#039;];&lt;br /&gt;
		$row_array[&#039;value&#039;] = $row[&#039;column_name&#039;];&lt;br /&gt;
 &lt;br /&gt;
        array_push($return_arr,$row_array);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
Finally, a PHP file (autocomplete.php) to include the previous two files and complete the query. This is the file that is called by the javascript, and the only one placed in the webroot:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
// Include files outside of webroot&lt;br /&gt;
set_include_path(&#039;/var/www/surveys/test-survey&#039;);&lt;br /&gt;
&lt;br /&gt;
// Fetch database credentials&lt;br /&gt;
require_once (&#039;constant.php&#039;);&lt;br /&gt;
&lt;br /&gt;
// Connect to database and perform query&lt;br /&gt;
require_once (&#039;database.php&#039;);&lt;br /&gt;
&lt;br /&gt;
// Clear query&lt;br /&gt;
$db = null;  &lt;br /&gt;
 &lt;br /&gt;
// Encode results in JSON. This is required for jquery autocomplete&lt;br /&gt;
echo json_encode($return_arr);&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
This should complete your setup, but there are obviously a variety of pitfalls, at which point the previously outlined debugging techniques may be of help.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Use autocomplete to populate several fields==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.91+, IE 7/8/9, Firefox 18&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround uses the [http://jqueryui.com/demos/autocomplete/ Autocomplete widget] included with jQuery UI and the [https://code.google.com/p/jquery-csv/downloads/list jquery.csv.js] plugin to provide a respondent with a list of suggested answers as they type in a text input and then to automatically populate other fields depending on the selection.&lt;br /&gt;
&lt;br /&gt;
For example, if you have 3 questions - &amp;quot;Name&amp;quot;, &amp;quot;ID&amp;quot; and &amp;quot;Email&amp;quot; - you can use this workaround to autocomplete the &amp;quot;Name&amp;quot; question and then the &amp;quot;ID&amp;quot; and &amp;quot;Email&amp;quot; questions can be automatically populated with values associated with the selected name.&lt;br /&gt;
*Download the [https://code.google.com/p/jquery-csv/downloads/list jquery.csv.js] plugin and place it in your template folder&lt;br /&gt;
*If using LimeSurvey 1.9x, add the following line to your startpage.pstpl BEFORE the tag for template.js, if using 2.x, add it AFTER the {TEMPLATEJS} placeholder&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;{TEMPLATEURL}jquery.csv.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
*Create your CSV file with 3 columns (name, ID, email) as in this example and place it in your template folder&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;Bob,    Bob&#039;s ID,    Bob&#039;s email&lt;br /&gt;
&lt;br /&gt;
Andy,    Andy&#039;s ID,    Andy&#039;s email&lt;br /&gt;
&lt;br /&gt;
Sam,    Sam&#039;s ID,    Sam&#039;s email&lt;br /&gt;
&lt;br /&gt;
Tony,    Tony&#039;s ID,    Tony&#039;s email&lt;br /&gt;
&lt;br /&gt;
Fred,    Fred&#039;s ID,    Fred&#039;s email&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
*Create your 3 questions - &amp;quot;Name&amp;quot;, &amp;quot;ID&amp;quot; and &amp;quot;Email&amp;quot;. They must be in the same group/page.&lt;br /&gt;
*Add the following styles to the end of your &#039;template.css&#039; file&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;/* Autocomplete styles */&lt;br /&gt;
&lt;br /&gt;
ul.ui-autocomplete {&lt;br /&gt;
&lt;br /&gt;
   width: 250px !important;&lt;br /&gt;
&lt;br /&gt;
   padding: 5px 10px;&lt;br /&gt;
&lt;br /&gt;
   list-style: none;&lt;br /&gt;
&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
*Add the following script to the source of one of the questions&lt;br /&gt;
*Replace:&lt;br /&gt;
**&amp;quot;NN&amp;quot; with the &amp;quot;Name&amp;quot; question ID&lt;br /&gt;
**&amp;quot;II&amp;quot; with the &amp;quot;ID&amp;quot; question ID&lt;br /&gt;
**&amp;quot;EE&amp;quot; with the &amp;quot;Email&amp;quot; question ID&lt;br /&gt;
*Modify the path to your CSV file&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
		var qNameID = NN;&lt;br /&gt;
&lt;br /&gt;
		var qIDID = II;&lt;br /&gt;
&lt;br /&gt;
		var qEmailID = EE;&lt;br /&gt;
&lt;br /&gt;
		var url = &amp;quot;upload/templates/yourTemplate/yourCsvFile.csv&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		// Create an array to hold the names&lt;br /&gt;
		var namesArr = new Array();&lt;br /&gt;
&lt;br /&gt;
		// Grab the CSV contents&lt;br /&gt;
		$.get(url,function(data){&lt;br /&gt;
&lt;br /&gt;
			// Convert CSV contents to an array of arrays&lt;br /&gt;
			fullArray = $.csv.toArrays(data);&lt;br /&gt;
&lt;br /&gt;
			// Load the names array&lt;br /&gt;
			$(fullArray).each(function(i, item){&lt;br /&gt;
				namesArr.push(item[0]);&lt;br /&gt;
			});&lt;br /&gt;
&lt;br /&gt;
			// Initialise the autocomplete plugin&lt;br /&gt;
			$(&#039;#question&#039;+qNameID+&#039; input.text&#039;).autocomplete({&lt;br /&gt;
				source: namesArr,&lt;br /&gt;
				// Event fired when a selection is made (ui.item.value refers to the selected item)&lt;br /&gt;
				select: function(event, ui) {&lt;br /&gt;
					// Find the &amp;quot;ID&amp;quot; and &amp;quot;Email&amp;quot; values associated with the selected name value and load those questions&lt;br /&gt;
					$(fullArray).each(function(i, item){&lt;br /&gt;
						if(item[0] == ui.item.value) {&lt;br /&gt;
							// The value from column 2 of the CSV&lt;br /&gt;
							$(&#039;#question&#039;+qIDID+&#039; input.text&#039;).val(item[1]);&lt;br /&gt;
							// The value from column 3 of the CSV&lt;br /&gt;
							$(&#039;#question&#039;+qEmailID+&#039; input.text&#039;).val(item[2]);&lt;br /&gt;
						}&lt;br /&gt;
					});&lt;br /&gt;
				}&lt;br /&gt;
			});&lt;br /&gt;
		});&lt;br /&gt;
	});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Drag and Drop Rankings=&lt;br /&gt;
&lt;br /&gt;
{{Deprecated|2.0}}&lt;br /&gt;
&lt;br /&gt;
{{Hint|Text=In 2.0 and up, this system Ranking question use jqueryui-sortable. This workaround is deprecated. }} &lt;br /&gt;
&lt;br /&gt;
==Drag and Drop Ranking - Version 1.90 to 1.92==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+ &amp;amp; 1.91RC4, IE 6/7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{Hint|Text=In 2.0 and up, this system Ranking question use jqueryui-sortable. This workaround is deprecated. }} &lt;br /&gt;
&lt;br /&gt;
This workaround is a modification of the workaround below and also uses [http://jqueryui.com/demos/sortable/#connect-lists JQuery connected sortables]. Thanks to the author of that workaround.&lt;br /&gt;
&lt;br /&gt;
[[File:Untitled-12.png]]&lt;br /&gt;
&lt;br /&gt;
Modifications include:&lt;br /&gt;
*Allow for multiple drag-n-drop ranking questions on a page&lt;br /&gt;
*Handle minimum and maximum answers settings&lt;br /&gt;
*Allow double clicking of items to add or remove them from the ranking list&lt;br /&gt;
*Work with the new shipped jQuery UI&lt;br /&gt;
&lt;br /&gt;
There is a &#039;&#039;&#039;[http://www.partnersinc.biz/surveys//index.php?sid=36981&amp;amp;newtest=Y&amp;amp;lang=en demonstrated here]&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#[[Workarounds: Manipulating a survey at runtime using Javascript#How to use Script (eg. JavaScript etc.) in LimeSurvey?|Set up your survey to use JavaScript]].&lt;br /&gt;
#Place the large script below in your template.js file.&lt;br /&gt;
#Place the small script below in the source a ranking question, (this applies the &amp;quot;dragDropRank&amp;quot; function to the question). Replace &amp;quot;QQ&amp;quot; with the ranking [http://docs.limesurvey.org/SGQA+identifier&amp;amp;structure;=English+Instructions+for+LimeSurvey#General_Description question ID].&lt;br /&gt;
**Note: the LimeSurvey translations will be automatically used for the &amp;quot;Choices&amp;quot; and &amp;quot;Rankings&amp;quot; header labels but can be overridden with custom labels - see the example calls below.&lt;br /&gt;
#Insert the CSS below at the end of template.css (these styles are for the default template).&lt;br /&gt;
&lt;br /&gt;
NOTE: I have not tested this workaround with conditions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Code for template.js:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
function dragDropRank(qID, choiceText, rankText) {&lt;br /&gt;
&lt;br /&gt;
	if(!choiceText) {&lt;br /&gt;
		choiceText = $(&#039;#question&#039;+qID+&#039; td.label label&#039;).text();&lt;br /&gt;
	}&lt;br /&gt;
	if(!rankText) {&lt;br /&gt;
		rankText = $(&#039;#question&#039;+qID+&#039; td.output tr:first td:eq(1)&#039;).text();&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	//Add a class to the question&lt;br /&gt;
	$(&#039;#question&#039;+qID+&#039;&#039;).addClass(&#039;dragDropRanking&#039;);&lt;br /&gt;
	&lt;br /&gt;
	// Hide the original question in LimeSurvey (so that we can replace with drag and drop)&lt;br /&gt;
	$(&#039;#question&#039;+qID+&#039; .rank, #question&#039;+qID+&#039; .questionhelp&#039;).hide();&lt;br /&gt;
	&lt;br /&gt;
	// Turn off display of question (to override error checking built into LimeSurvey ranking question)&lt;br /&gt;
	//$(&#039;#display&#039;+qID).val(&#039;off&#039;);&lt;br /&gt;
	&lt;br /&gt;
	// Add connected sortables elements to the question&lt;br /&gt;
	var htmlCode = &#039;&amp;lt;table class=&amp;quot;dragDropTable&amp;quot;&amp;gt; \&lt;br /&gt;
		&amp;lt;tbody&amp;gt; \&lt;br /&gt;
			&amp;lt;tr&amp;gt; \&lt;br /&gt;
				&amp;lt;td&amp;gt; \&lt;br /&gt;
					&amp;lt;span class=&amp;quot;dragDropHeader choicesLabel&amp;quot;&amp;gt;&#039;+choiceText+&#039;&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt; \&lt;br /&gt;
					&amp;lt;div class=&amp;quot;ui-state-highlight dragDropChoices&amp;quot;&amp;gt; \&lt;br /&gt;
						&amp;lt;ul id=&amp;quot;sortable1&#039;+qID+&#039;&amp;quot; class=&amp;quot;connectedSortable&#039;+qID+&#039; dragDropChoiceList&amp;quot;&amp;gt; \&lt;br /&gt;
							&amp;lt;li&amp;gt;Choices&amp;lt;/li&amp;gt; \&lt;br /&gt;
						&amp;lt;/ul&amp;gt; \&lt;br /&gt;
					&amp;lt;/div&amp;gt; \&lt;br /&gt;
				&amp;lt;/td&amp;gt; \&lt;br /&gt;
				&amp;lt;td&amp;gt; \&lt;br /&gt;
					&amp;lt;span class=&amp;quot;dragDropHeader rankingLabel&amp;quot;&amp;gt;&#039;+rankText+&#039;&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt; \&lt;br /&gt;
					&amp;lt;div class=&amp;quot;ui-state-highlight dragDropRanks&amp;quot;&amp;gt; \&lt;br /&gt;
						&amp;lt;ol id=&amp;quot;sortable2&#039;+qID+&#039;&amp;quot; class=&amp;quot;connectedSortable&#039;+qID+&#039; dragDropRankList&amp;quot;&amp;gt; \&lt;br /&gt;
							&amp;lt;li&amp;gt;Ranks&amp;lt;/li&amp;gt; \&lt;br /&gt;
						&amp;lt;/ol&amp;gt; \&lt;br /&gt;
					&amp;lt;/div&amp;gt; \&lt;br /&gt;
				&amp;lt;/td&amp;gt; \&lt;br /&gt;
			&amp;lt;/tr&amp;gt; \&lt;br /&gt;
		&amp;lt;/tbody&amp;gt; \&lt;br /&gt;
					&amp;lt;/table&amp;gt;&#039;;&lt;br /&gt;
	$(htmlCode).insertAfter(&#039;#question&#039;+qID+&#039; table.rank&#039;);&lt;br /&gt;
	&lt;br /&gt;
	// Remove placeholder list items (have to have one item so that LimeSurvey doesn&amp;quot;t remove the &amp;lt;ul&amp;gt;)&lt;br /&gt;
	$(&#039;#sortable1&#039;+qID+&#039; li, #sortable2&#039;+qID+&#039; li&#039;).remove();&lt;br /&gt;
	&lt;br /&gt;
	// Load any previously-set values&lt;br /&gt;
	loadDragDropRank(qID);&lt;br /&gt;
	&lt;br /&gt;
	// Find the number of LimeSurvey ranking inputs (&amp;quot;Maximum answers&amp;quot;)&lt;br /&gt;
	var maxAnswer = $(&#039;#question&#039;+qID+&#039; td.output input.text&#039;).length;&lt;br /&gt;
	&lt;br /&gt;
	// Set up the connected sortable&lt;br /&gt;
	$(&#039;#sortable1&#039;+qID+&#039;, #sortable2&#039;+qID+&#039;&#039;).sortable({&lt;br /&gt;
		connectWith: &#039;.connectedSortable&#039;+qID+&#039;&#039;,&lt;br /&gt;
		placeholder: &#039;ui-sortable-placeholder&#039;,&lt;br /&gt;
		helper: &#039;clone&#039;,&lt;br /&gt;
		revert: 50,&lt;br /&gt;
		receive: function(event, ui) {&lt;br /&gt;
			if($(&#039;#sortable2&#039;+qID+&#039; li&#039;).length &amp;gt; maxAnswer) {&lt;br /&gt;
				alert (&#039;You can only rank a maximum of &#039;+maxAnswer+&#039; choices.&#039;);&lt;br /&gt;
				$(ui.sender).sortable(&#039;cancel&#039;);&lt;br /&gt;
			}&lt;br /&gt;
		},&lt;br /&gt;
		stop: function(event, ui) {&lt;br /&gt;
			$(&#039;#sortable1&#039;+qID+&#039;&#039;).sortable(&#039;refresh&#039;);&lt;br /&gt;
			$(&#039;#sortable2&#039;+qID+&#039;&#039;).sortable(&#039;refresh&#039;);&lt;br /&gt;
			updateDragDropRank(qID);&lt;br /&gt;
		}&lt;br /&gt;
	}).disableSelection();&lt;br /&gt;
	&lt;br /&gt;
	// Get the list of choices from the LimeSurvey question and copy them as items into the sortable choices list&lt;br /&gt;
	$(&#039;#CHOICES_&#039; + qID).children().each(function(index, Element) {&lt;br /&gt;
		var liCode = &#039;&amp;lt;li class=&amp;quot;ui-state-default&amp;quot; id=&amp;quot;choice_&#039; + $(this).attr(&amp;quot;value&amp;quot;) + &#039;&amp;quot;&amp;gt;&#039; + this.text + &#039;&amp;lt;/li&amp;gt;&#039;&lt;br /&gt;
		$(liCode).appendTo(&#039;#sortable1&#039;+qID+&#039;&#039;);&lt;br /&gt;
	});&lt;br /&gt;
	&lt;br /&gt;
	// Allow users to double click to move to selections from list to list&lt;br /&gt;
	$(&#039;#sortable1&#039;+qID+&#039; li&#039;).live(&#039;dblclick&#039;, function() {&lt;br /&gt;
		if($(&#039;#sortable2&#039;+qID+&#039; li&#039;).length == maxAnswer) {&lt;br /&gt;
			alert (&#039;You can only rank a maximum of &#039;+maxAnswer+&#039; choices.&#039;);&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
		else {&lt;br /&gt;
			$(this).appendTo(&#039;#sortable2&#039;+qID+&#039;&#039;);&lt;br /&gt;
			$(&#039;#sortable1&#039;+qID+&#039;&#039;).sortable(&#039;refresh&#039;);&lt;br /&gt;
			$(&#039;#sortable2&#039;+qID+&#039;&#039;).sortable(&#039;refresh&#039;);&lt;br /&gt;
			updateDragDropRank(qID);&lt;br /&gt;
		}&lt;br /&gt;
	});&lt;br /&gt;
	$(&#039;#sortable2&#039;+qID+&#039; li&#039;).live(&#039;dblclick&#039;, function() {&lt;br /&gt;
		$(this).appendTo(&#039;#sortable1&#039;+qID+&#039;&#039;);&lt;br /&gt;
		$(&#039;#sortable2&#039;+qID+&#039;&#039;).sortable(&#039;refresh&#039;);&lt;br /&gt;
		$(&#039;#sortable1&#039;+qID+&#039;&#039;).sortable(&#039;refresh&#039;);&lt;br /&gt;
		updateDragDropRank(qID);&lt;br /&gt;
	});&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// This function copies the drag and drop sortable data into the LimeSurvey ranking list.&lt;br /&gt;
function updateDragDropRank(qID) {&lt;br /&gt;
&lt;br /&gt;
	// Reload the LimeSurvey choices select element&lt;br /&gt;
	var rankees = [];&lt;br /&gt;
	$(&#039;#sortable2&#039;+qID+&#039; li&#039;).each(function(index) {&lt;br /&gt;
		$(this).attr(&#039;value&#039;, index+1);&lt;br /&gt;
		&lt;br /&gt;
		// Get value of ranked item&lt;br /&gt;
		var liID = $(this).attr(&amp;quot;id&amp;quot;);&lt;br /&gt;
		liIDArray = liID.split(&#039;_&#039;);&lt;br /&gt;
		&lt;br /&gt;
		// Save to an array&lt;br /&gt;
		rankees[rankees.length] = { &amp;quot;r_name&amp;quot;:$(this).text(),&amp;quot;r_value&amp;quot;:liIDArray[1] };&lt;br /&gt;
	});&lt;br /&gt;
	$(&#039;#question&#039;+qID+&#039; input[name&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&amp;quot;RANK_&amp;quot;]&#039;).each(function(index) {&lt;br /&gt;
		if (rankees.length &amp;gt; index) {&lt;br /&gt;
			$(this).val(rankees[index].r_name);&lt;br /&gt;
			$(this).next(&#039;input&#039;).attr(&#039;value&#039;, rankees[index].r_value);&lt;br /&gt;
		} else {&lt;br /&gt;
			$(this).val(&#039;&#039;);&lt;br /&gt;
			$(this).next().val(&#039;&#039;);&lt;br /&gt;
		}&lt;br /&gt;
	 });&lt;br /&gt;
	 &lt;br /&gt;
	// Reload the LimeSurvey choices select element (we need this for &amp;quot;Minimum answers&amp;quot; code)&lt;br /&gt;
	$(&#039;#question&#039;+qID+&#039; td.label select option&#039;).remove();&lt;br /&gt;
	$(&#039;#sortable1&#039;+qID+&#039; li&#039;).each(function(index) {&lt;br /&gt;
		var liText = $(this).text();&lt;br /&gt;
		var liID = $(this).attr(&#039;id&#039;);&lt;br /&gt;
		liIDArray = liID.split(&#039;_&#039;);&lt;br /&gt;
		var optionCode = &#039;&amp;lt;option value=&amp;quot;&#039;+liIDArray[1]+&#039;&amp;quot;&amp;gt;&#039;+liText+&#039;&amp;lt;/option&amp;gt;&#039;;&lt;br /&gt;
		$(optionCode).appendTo(&#039;#question&#039;+qID+&#039; td.label select&#039;);&lt;br /&gt;
	});&lt;br /&gt;
	&lt;br /&gt;
	// Hack for IE6&lt;br /&gt;
	if ($.browser.msie &amp;amp;&amp;amp; $.browser.version.substr(0,1)&amp;lt;7) {&lt;br /&gt;
		$(&#039;#question&#039;+qID+&#039; select&#039;).show();&lt;br /&gt;
		$(&#039;#question&#039;+qID+&#039; select&#039;).hide();&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// This function is called on page load to see if there are any items already ranked (from a previous visit&lt;br /&gt;
// or cached due to a page change.  If so, the already-ranked items are loaded into the sortable list&lt;br /&gt;
function loadDragDropRank(qID) {&lt;br /&gt;
&lt;br /&gt;
	var rankees = [];&lt;br /&gt;
	&lt;br /&gt;
	// Loop through each item in the built-in LimeSurvey ranking list looking for non-empty values&lt;br /&gt;
	$(&#039;#question&#039;+qID+&#039; input[name&amp;lt;/div&amp;gt;=&amp;quot;RANK_&amp;quot;]&#039;).each(function(index) {&lt;br /&gt;
	&lt;br /&gt;
		// Check to see if the current item has a value&lt;br /&gt;
		if ($(this).val()) {&lt;br /&gt;
		&lt;br /&gt;
			// Item has a value - save to the array&lt;br /&gt;
			// Use this element to contain the name and the next for the value (numeric)&lt;br /&gt;
			rankees[rankees.length] = { &amp;quot;r_name&amp;quot;:$(this).val(),&amp;quot;r_value&amp;quot;:$(this).next().val() };&lt;br /&gt;
		}&lt;br /&gt;
	});&lt;br /&gt;
	&lt;br /&gt;
	// Now that we have a list of all the pre-ranked items, populate the sortable list&lt;br /&gt;
	// Note that the items *won&amp;quot;t* appear in the main list because LimeSurvey has removed them.&lt;br /&gt;
	$.each(rankees, function(index, value) {&lt;br /&gt;
	&lt;br /&gt;
		// Create the items in the sortable&lt;br /&gt;
		var liCode = &#039;&amp;lt;li class=&amp;quot;ui-state-default&amp;quot; id=&amp;quot;choice_&#039; + value.r_value + &#039;&amp;quot;&amp;gt;&#039; + value.r_name + &#039;&amp;lt;/li&amp;gt;&#039;;&lt;br /&gt;
		$(liCode).appendTo(&#039;#sortable2&#039;+qID+&#039;&#039;);&lt;br /&gt;
	});&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Code in the source of the question(s) using the LimeSurvey translations for the &amp;quot;Choices&amp;quot; and &amp;quot;Rankings&amp;quot; element header labels&#039;&#039;&#039; (replace &amp;quot;QQ&amp;quot; with the ranking [http://docs.limesurvey.org/SGQA+identifier&amp;amp;structure;=English+Instructions+for+LimeSurvey#General_Description question ID]):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	$(document).ready(function() {&lt;br /&gt;
		dragDropRank(QQ);&lt;br /&gt;
	});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Fix for later versions of 1.91+&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In my version of LimeSurvey 1.91+, build 11026, this drag-n-drop workaround was not saving the selections properly. I&#039;m not sure if that&#039;s because of my template, or other jquery uses, but I fixed it by making the following modifications to the above code placed into template.js.&lt;br /&gt;
&lt;br /&gt;
If you&#039;re having problems (and it&#039;s definitely worth testing that the rankings are actually saving into your response table before proceeding with the survey) give this a try.&lt;br /&gt;
&lt;br /&gt;
In the &#039;updateDragDropRank(qID)&#039; function, replace the line:&lt;br /&gt;
&amp;lt;syntaxhighlight  lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
$(&#039;#question&#039;+qID+&#039; input[name&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&amp;quot;RANK_&amp;quot;]&#039;).each(function(index) {&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
with:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
$(&#039;#question&#039;+qID+&#039; input[name^=&amp;quot;RANK_&amp;quot;]&#039;).each(function(index) {&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;loadDragDropRank(qID) function, replace the line:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
$(&#039;#question&#039;+qID+&#039; input[name&amp;lt;/div&amp;gt;=&amp;quot;RANK_&amp;quot;]&#039;).each(function(index) {&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
with:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
$(&#039;#question&#039;+qID+&#039; input[name^=&amp;quot;RANK_&amp;quot;]&#039;).each(function(index) {&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Code in the source of the question(s) using custom text for the &amp;quot;Choices&amp;quot; and &amp;quot;Rankings&amp;quot; element header labels&#039;&#039;&#039; (replace &amp;quot;QQ&amp;quot; with the ranking [http://docs.limesurvey.org/SGQA+identifier&amp;amp;structure;=English+Instructions+for+LimeSurvey#General_Description question ID]):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	$(document).ready(function() {&lt;br /&gt;
		dragDropRank(QQ, &#039;Custom Choices Label&#039;, &#039;Custom Rankings Label&#039;);&lt;br /&gt;
	});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Styles for template.css:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;css&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
/* Drag-n-drop ranking styles */&lt;br /&gt;
.dragDropTable {&lt;br /&gt;
	border: 0 none;&lt;br /&gt;
	border-collapse: collapse;&lt;br /&gt;
	width: 100%;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.dragDropTable td {&lt;br /&gt;
	vertical-align: top;&lt;br /&gt;
	width: 50%;&lt;br /&gt;
	padding-right: 20px;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.dragDropTable .dragDropHeader {&lt;br /&gt;
	font-weight: bold;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.dragDropTable .dragDropChoices,&lt;br /&gt;
.dragDropTable .dragDropRanks {&lt;br /&gt;
	margin: 5px 0 0 0;&lt;br /&gt;
	background: transparent none;&lt;br /&gt;
	border: 0 none;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.dragDropTable .dragDropChoiceList,&lt;br /&gt;
.dragDropTable .dragDropRankList {&lt;br /&gt;
	float: left;&lt;br /&gt;
	width: 100%;&lt;br /&gt;
	min-height: 2.4em;&lt;br /&gt;
	_height: 2.4em; /* IE6 and below hack */&lt;br /&gt;
	margin: 0;&lt;br /&gt;
	padding: 0;&lt;br /&gt;
	list-style-type: none;&lt;br /&gt;
	background: #FBFBFB none;&lt;br /&gt;
	border: 1px solid #CCCCCC;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.dragDropTable .dragDropChoiceList li,&lt;br /&gt;
.dragDropTable .dragDropRankList li {&lt;br /&gt;
	margin: 3px;&lt;br /&gt;
	*margin-left: -13px; /* IE7 and below */&lt;br /&gt;
	padding: 3px;&lt;br /&gt;
	min-height: 1.3em;&lt;br /&gt;
	_height: 1.3em; /* IE6 and below hack */&lt;br /&gt;
	font-weight: normal;&lt;br /&gt;
	cursor: move;&lt;br /&gt;
	display: block; /* Force the li to full width */&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Drag and Drop Ranking using Images - Version 1.90 to 1.92==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+ &amp;amp; 1.91RC4, IE 6/7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{Hint|Text=In 2.0 and up, this system Ranking question use jqueryui-sortable. This workaround is deprecated. }}&lt;br /&gt;
&lt;br /&gt;
This workaround works in conjunction with the above workaround to allow ranking of images.&lt;br /&gt;
&lt;br /&gt;
[[File:Untitled-11.png]]&lt;br /&gt;
&lt;br /&gt;
There is a &#039;&#039;&#039;[http://www.partnersinc.biz/surveys//index.php?sid=36981&amp;amp;newtest=Y&amp;amp;lang=en demonstrated here]&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
&lt;br /&gt;
1) Follow the above workaround to get basic drag-n-drop functionality in your ranking question.&lt;br /&gt;
&lt;br /&gt;
2) Insert your images in the ranking question text or help section after any text that you wish to have there (we&#039;ll move them later with JavaScript).&lt;br /&gt;
&lt;br /&gt;
3) Give the images &#039;&#039;&#039;EXACTLY&#039;&#039;&#039; the same IDs as the answer code you would like them to be associated with:[[File:Untitled-8.png]]&lt;br /&gt;
&lt;br /&gt;
4) Place the first script below in your template.js file.&lt;br /&gt;
&lt;br /&gt;
5) Place the second script below in the source the ranking question &#039;&#039;&#039;AFTER&#039;&#039;&#039; the initial call for the dragDropRank function from the workaround above. Replace &amp;quot;QQ&amp;quot; with the ID of the ranking question (this applies the &amp;quot;dragDropRankImages&amp;quot; function to the question).&lt;br /&gt;
&lt;br /&gt;
6) Insert the CSS below at the end of template.css. Replace &amp;quot;11&amp;quot; with your question ID. These styles are for the default template using 50x50px images (as in the demo) and may need to be modified for other templates or image sizes.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Code for template.js:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
function dragDropRankImages(qID) {&lt;br /&gt;
&lt;br /&gt;
	$(&#039;.connectedSortable&#039;+qID+&#039; li&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
		// Remove any text in the sortable choice or rank items&lt;br /&gt;
		$(this).text(&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
		// Move the images into the appropriate sortable list item&lt;br /&gt;
		var liID = $(this).attr(&#039;id&#039;);&lt;br /&gt;
		liIDArray = liID.split(&#039;_&#039;);&lt;br /&gt;
		$(&#039;#question&#039;+qID+&#039; img#&#039;+liIDArray[1]+&#039;&#039;).appendTo(this);&lt;br /&gt;
	});&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Code in the source of the question(s):&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	$(document).ready(function() {&lt;br /&gt;
		dragDropRankImages(QQ);&lt;br /&gt;
	});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Styles for template.css:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;css&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* Drag-n-drop for ranking images */&lt;br /&gt;
#question11 .dragDropTable {&lt;br /&gt;
	width: auto;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#question11 .dragDropTable .dragDropChoiceList,&lt;br /&gt;
#question11 .dragDropTable .dragDropRankList {&lt;br /&gt;
	min-height: 60px;&lt;br /&gt;
	_height: 60px; /* IE6 and below hack */&lt;br /&gt;
	width: auto;&lt;br /&gt;
	min-width: 60px;&lt;br /&gt;
	_width: 60px; /* IE6 and below hack */&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#question11 .dragDropTable li {&lt;br /&gt;
	background: 0 none;&lt;br /&gt;
	border: 0 none;&lt;br /&gt;
	height: 50px;&lt;br /&gt;
	width: 50px;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#question11 .dragDropTable li img {&lt;br /&gt;
	margin: 0;&lt;br /&gt;
	padding: 0;&lt;br /&gt;
	border: 0 none;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Drag and Drop Ranking for iPad - Version 1.91 and newer==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: LimeSurvey 1.91, iPad 2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround extends the above workarounds to work with the touch interface on iPads.&lt;br /&gt;
&lt;br /&gt;
1) Follow the [[Workarounds: Manipulating a survey at runtime using Javascript#Drag and Drop Ranking - Version 1.90 and newer|Drag and Drop Ranking - Version 1.90 and newer]] workaround above to get basic drag-n-drop functionality in your ranking question.&lt;br /&gt;
&lt;br /&gt;
2) Download the [https://github.com/furf/jquery-ui-touch-punch jQuery.ui.touch-punch.js plugin] and save it in your template directory.&lt;br /&gt;
&lt;br /&gt;
3) Replace this line in your startpage.pstpl:&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;{TEMPLATEURL}template.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;With this:&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;{TEMPLATEURL}jquery.ui.touch-punch.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;{TEMPLATEURL}template.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Drag and Drop Ranking - Version 1.86==&lt;br /&gt;
&lt;br /&gt;
Tested with 1.86 on IE 7,8, FireFox 3, Chrome, and Safari 4&lt;br /&gt;
&lt;br /&gt;
{{Hint|Text=In 2.0 and up, this system Ranking question use jqueryui-sortable. This workaround is deprecated. }}&lt;br /&gt;
&lt;br /&gt;
This workaround uses [http://jqueryui.com/demos/sortable/#connect-lists JQuery connected sortables] to modify a ranking question and allow the survey taker to drag and drop choices instead of clicking.  The nice thing is that the choices can be easily re-arranged or removed from the ranking, all by drag and drop.&lt;br /&gt;
&lt;br /&gt;
I used it for a voting application and some of the element names reflect that use.&lt;br /&gt;
&lt;br /&gt;
It looks best when some CSS is added to control the appearance of the boxers around each choice.&lt;br /&gt;
&lt;br /&gt;
[[File:drag-n-drop.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
	// Question ID global variable&lt;br /&gt;
	var questionID;&lt;br /&gt;
	&lt;br /&gt;
	$(document).ready(function() {&lt;br /&gt;
	&lt;br /&gt;
		// Grab the question ID[[File:drag-n-drop.png]]&lt;br /&gt;
		// This is something with a class of &amp;quot;ranking&amp;quot; and an ID that starts with &amp;quot;questionXXXXX&amp;quot;.  The X&#039;s represent the question ID&lt;br /&gt;
		var entire_questionID = $(&amp;quot;.ranking[id^=&#039;question&#039;]&amp;quot;).attr(&#039;id&#039;);&lt;br /&gt;
		&lt;br /&gt;
		// Get just the question number (ID)&lt;br /&gt;
		var patt=/\d+$/;&lt;br /&gt;
		questionID=patt.exec(entire_questionID);&lt;br /&gt;
		&lt;br /&gt;
		// Hide the original quetion in LimeSurvey (so that we can replace with drag and drop)&lt;br /&gt;
		$(&amp;quot;.rank, .questionhelp&amp;quot;).hide();&lt;br /&gt;
		&lt;br /&gt;
		// Turn off display of question (to override error checking built into LimeSurvey ranking question)&lt;br /&gt;
		$(&amp;quot;#display&amp;quot;+questionID).val(&amp;quot;off&amp;quot;);&lt;br /&gt;
		&lt;br /&gt;
		// Add connected sortables to the question&lt;br /&gt;
		var html_code = &amp;quot;&amp;lt;table style=&#039;border: medium none ; width: 770px; margin-left: auto; \&lt;br /&gt;
								margin-right: auto;&#039;&amp;gt;&amp;lt;tbody&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td style=&#039;width: 590px; vertical-align: top;&#039;&amp;gt;&amp;lt;h3&amp;gt;List of Candidates:&amp;lt;/h3&amp;gt; \&lt;br /&gt;
								&amp;lt;div class=&#039;ui-state-highlight&#039; style=&#039;margin: 5px; float: left;&#039; id=&#039;ballot_list&#039;&amp;gt; \&lt;br /&gt;
								&amp;lt;ul id=&#039;sortable1&#039; class=&#039;connectedSortable&#039;&amp;gt;&amp;lt;li&amp;gt;Candidates&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/td&amp;gt; \&lt;br /&gt;
								&amp;lt;td style=&#039;vertical-align: top;&#039;&amp;gt;&amp;lt;h3&amp;gt;Your selections:&amp;lt;/h3&amp;gt;&amp;lt;div class=&#039;ui-state-highlight&#039; \&lt;br /&gt;
								style=&#039;margin: 5px; float: left;&#039; id=&#039;voting_selections&#039;&amp;gt;&amp;lt;ol id=&#039;sortable2&#039; class=&#039;connectedSortable&#039;&amp;gt; \&lt;br /&gt;
								&amp;lt;li&amp;gt;Voting Area&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/tbody&amp;gt;&amp;lt;/table&amp;gt;&amp;quot;;&lt;br /&gt;
		$(html_code).appendTo(&amp;quot;#question&amp;quot; + questionID);&lt;br /&gt;
		&lt;br /&gt;
		// Remove list items (have to have one item so that LimeSurvey doesn&#039;t remove the &amp;lt;ul&amp;gt;)&lt;br /&gt;
		$(&amp;quot;#sortable1 li, #sortable2 li&amp;quot;).remove();&lt;br /&gt;
		&lt;br /&gt;
		// Load any previously-set values&lt;br /&gt;
		loadRanking();&lt;br /&gt;
		&lt;br /&gt;
		// Load jQuery UI&lt;br /&gt;
		$.getScript(&amp;quot;/scripts/jquery/jquery-ui.js&amp;quot;, function() {&lt;br /&gt;
		&lt;br /&gt;
			// After JQuery UI finishes loading, set up the connected sortable.&lt;br /&gt;
			$(&amp;quot;#sortable1, #sortable2&amp;quot;).sortable({&lt;br /&gt;
				connectWith: &#039;.connectedSortable&#039;,&lt;br /&gt;
				placeholder: &#039;ui-sortable-placeholder&#039;,&lt;br /&gt;
				stop: function(event, ui) {&lt;br /&gt;
					$(&amp;quot;#sortable1&amp;quot;).sortable(&amp;quot;refresh&amp;quot;);&lt;br /&gt;
					$(&amp;quot;#sortable2&amp;quot;).sortable(&amp;quot;refresh&amp;quot;);&lt;br /&gt;
					updateRanking();&lt;br /&gt;
					}&lt;br /&gt;
			}).disableSelection();&lt;br /&gt;
			&lt;br /&gt;
			// Get the list of candidates from the built-in LimeSurvey question and copy them as items in sortable1&lt;br /&gt;
			$(&amp;quot;#CHOICES_&amp;quot; + questionID).children().each(function(index, Element) {&lt;br /&gt;
				li_tag = &amp;quot;&amp;lt;li class=&#039;ui-state-default&#039; id=&#039;choice_&amp;quot; + $(this).attr(&#039;value&#039;) + &amp;quot;&#039;&amp;gt;&amp;quot; + this.text + &amp;quot;&amp;lt;/li&amp;gt;&amp;quot;&lt;br /&gt;
				$(li_tag).appendTo(&amp;quot;#sortable1&amp;quot;); }	);&lt;br /&gt;
				&lt;br /&gt;
			// Make sure the submit button is showing&lt;br /&gt;
			$(&amp;quot;:submit[value|=&#039; Submit&#039;]&amp;quot;).show();&lt;br /&gt;
			&lt;br /&gt;
			// Show a confirmation alert upon submit&lt;br /&gt;
			$(&amp;quot;form&amp;quot;).submit(function() {&lt;br /&gt;
			&lt;br /&gt;
				// Override the built-in &amp;quot;disable navigation buttons&amp;quot; feature&lt;br /&gt;
				$(&#039;#moveprevbtn, #movenextbtn, #movesubmitbtn&#039;).attr(&#039;disabled&#039;, &#039;&#039;);&lt;br /&gt;
				var validated = confirm(&amp;quot;Cast your ballot now?&amp;quot;);&lt;br /&gt;
				if (validated) { return true; } else { return false; }&lt;br /&gt;
			});&lt;br /&gt;
			&lt;br /&gt;
			// Allow users to double click to move to selection list&lt;br /&gt;
			$(&amp;quot;#sortable1 li&amp;quot;).assignDblClick();&lt;br /&gt;
		});  // End of JQuery UI loading&lt;br /&gt;
		&lt;br /&gt;
	}); // End of JQuery ready function&lt;br /&gt;
	&lt;br /&gt;
// Define the actions when an item is double clicked&lt;br /&gt;
$.fn.assignDblClick = function() {&lt;br /&gt;
	$(this).dblclick(function(){&lt;br /&gt;
		$(this).appendTo(&#039;#sortable2&#039;);&lt;br /&gt;
		$(&amp;quot;#sortable1&amp;quot;).sortable(&amp;quot;refresh&amp;quot;);&lt;br /&gt;
		$(&amp;quot;#sortable2&amp;quot;).sortable(&amp;quot;refresh&amp;quot;);&lt;br /&gt;
		updateRanking();&lt;br /&gt;
	});&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// This function copies the drag and drop sortable data into the standard LimeSurvey ranking structure.&lt;br /&gt;
function updateRanking() {&lt;br /&gt;
	var rankees = [];&lt;br /&gt;
	$(&#039;#sortable2 li&#039;).each(function(index) {&lt;br /&gt;
	$(this).attr(&amp;quot;value&amp;quot;, index+1);&lt;br /&gt;
	&lt;br /&gt;
		// Get value of person&lt;br /&gt;
		li_tag = $(this).attr(&#039;id&#039;);&lt;br /&gt;
		li_tag_array = li_tag.split(&amp;quot;_&amp;quot;);&lt;br /&gt;
		&lt;br /&gt;
		// Save to an array&lt;br /&gt;
		rankees[rankees.length] = { &#039;r_name&#039;:$(this).text(),&#039;r_value&#039;:li_tag_array[1] };&lt;br /&gt;
	});&lt;br /&gt;
	$(&amp;quot;input[name&amp;lt;/div&amp;gt;=&#039;RANK_&#039;]&amp;quot;).each(function(index) {&lt;br /&gt;
		if (rankees.length &amp;gt; index) {&lt;br /&gt;
			$(this).val(rankees[index].r_name);&lt;br /&gt;
			$(this).next().val(rankees[index].r_value);&lt;br /&gt;
		} else {&lt;br /&gt;
			$(this).val(&amp;quot;&amp;quot;);&lt;br /&gt;
			$(this).next().val(&amp;quot;&amp;quot;);&lt;br /&gt;
		}&lt;br /&gt;
	 });&lt;br /&gt;
	 &lt;br /&gt;
	// Re-assign double click action to first list items and remove&lt;br /&gt;
	// double click action from section list items&lt;br /&gt;
	$(&#039;#sortable1 li&#039;).unbind(&#039;dblclick&#039;).assignDblClick();&lt;br /&gt;
	$(&#039;#sortable2 li&#039;).unbind(&#039;dblclick&#039;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// This function is called on page load to see if there are any items already ranked (from a previous visit&lt;br /&gt;
// or cached due to a page change.  If so, the already-ranked items are loaded into the sortable list&lt;br /&gt;
function loadRanking() {&lt;br /&gt;
	var rankees = [];&lt;br /&gt;
	&lt;br /&gt;
	// Loop through each item in the built-in LimeSurvey ranking list looking for non-empty values&lt;br /&gt;
	$(&amp;quot;input[name&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&#039;RANK_&#039;]&amp;quot;).each(function(index) {&lt;br /&gt;
	&lt;br /&gt;
		// Check to see if the current item has a value&lt;br /&gt;
		if ($(this).val()) {&lt;br /&gt;
			// Item has a value - save to the array&lt;br /&gt;
			// Use this element to contain the name and the next for the value (numeric)&lt;br /&gt;
			rankees[rankees.length] = { &#039;r_name&#039;:$(this).val(),&#039;r_value&#039;:$(this).next().val() };&lt;br /&gt;
		}&lt;br /&gt;
	});&lt;br /&gt;
	&lt;br /&gt;
	// Now that we have a list of all the pre-ranked items, populate the sortable list&lt;br /&gt;
	// Note that the items *won&#039;t* appear in the main list because LimeSurvey has removed them.&lt;br /&gt;
	$.each(rankees, function(index, value) {&lt;br /&gt;
		// Create the items in the sortable&lt;br /&gt;
		li_tag = &amp;quot;&amp;lt;li class=&#039;ui-state-default&#039; id=&#039;choice_&amp;quot; + value.r_value + &amp;quot;&#039;&amp;gt;&amp;quot; + value.r_name + &amp;quot;&amp;lt;/li&amp;gt;&amp;quot;;&lt;br /&gt;
		$(li_tag).appendTo(&amp;quot;#sortable2&amp;quot;);&lt;br /&gt;
	});&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Create MaxDiff question type=&lt;br /&gt;
&lt;br /&gt;
See the [[Workarounds: Question design, layout and templating|Question design, layout and templating]] section for a workaround that uses JavaScript to convert an &#039;&#039;&#039;&#039;&#039;Array (flexible labels) by column&#039;&#039;&#039;&#039;&#039; question into a [http://en.wikipedia.org/wiki/MaxDiff MaxDiff] question type.&lt;br /&gt;
&lt;br /&gt;
[[File:max_diff_596x253.gif]]&lt;br /&gt;
&lt;br /&gt;
=In a checkbox matrix, have the &#039;none&#039; option in a row disable all other columns in that row=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: LimeSurvey 1.90+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The questionId parameter is the base ID of the question matrix (multiflexible).&lt;br /&gt;
&lt;br /&gt;
numColumns and numRows speak for themselves&lt;br /&gt;
&lt;br /&gt;
specialColumns is an array of the columns that have the special ability that when one of them&lt;br /&gt;
&lt;br /&gt;
is checked, none of the others can be checked. E.g., a &#039;none of these&#039; and/or a &#039;do now know&#039; option.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
numColumns=13;&lt;br /&gt;
&lt;br /&gt;
numRows=18;&lt;br /&gt;
&lt;br /&gt;
questionId=&#039;28417X2X24&#039;;&lt;br /&gt;
&lt;br /&gt;
specialColumns=[1,12,13];&lt;br /&gt;
&lt;br /&gt;
function action(obj){&lt;br /&gt;
&lt;br /&gt;
   locator=obj.id.replace(&#039;cbox_&#039;+questionId, &#039;&#039;).split(&#039;_&#039;);&lt;br /&gt;
&lt;br /&gt;
   row=locator[0];&lt;br /&gt;
&lt;br /&gt;
   column=locator[1];&lt;br /&gt;
&lt;br /&gt;
   //alert(&#039;Action for row,column=&#039;+row+&#039;,&#039;+column);&lt;br /&gt;
&lt;br /&gt;
   my_id=&#039;#cbox_&#039;+questionId+row+&#039;_&#039;+column+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
   if($(my_id).attr(&#039;checked&#039;) == false) {&lt;br /&gt;
&lt;br /&gt;
       for( var i=1; i&amp;lt;=numColumns; i++ ) {&lt;br /&gt;
&lt;br /&gt;
           if(i==column) continue;&lt;br /&gt;
&lt;br /&gt;
           id=&#039;#cbox_&#039;+questionId+row+&#039;_&#039;+i&lt;br /&gt;
&lt;br /&gt;
           $(id).attr(&#039;disabled&#039;,false);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   } else {&lt;br /&gt;
&lt;br /&gt;
       for( var i=1; i&amp;lt;=numColumns; i++ ) {&lt;br /&gt;
&lt;br /&gt;
           if(i==column) continue;&lt;br /&gt;
&lt;br /&gt;
           id=&#039;#cbox_&#039;+questionId+row+&#039;_&#039;+i&lt;br /&gt;
&lt;br /&gt;
           aid=&#039;#answer&#039;+questionId+row+&#039;_&#039;+i&lt;br /&gt;
&lt;br /&gt;
           $(aid).val(0);&lt;br /&gt;
&lt;br /&gt;
           $(id).attr(&#039;checked&#039;,false);&lt;br /&gt;
&lt;br /&gt;
           $(id).attr(&#039;disabled&#039;,true);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function customOnLoad(){&lt;br /&gt;
&lt;br /&gt;
   for( var row=1; row&amp;lt;=numRows; row++ ) {&lt;br /&gt;
&lt;br /&gt;
       for( var k=0; k&amp;lt;specialColumns.length; k++ )&lt;br /&gt;
&lt;br /&gt;
       {&lt;br /&gt;
&lt;br /&gt;
           column=specialColumns[k];&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#cbox_&#039;+questionId+row+&#039;_&#039;+column).change(function() {&lt;br /&gt;
&lt;br /&gt;
               action(this);&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
jQuery(document).ready(&lt;br /&gt;
&lt;br /&gt;
   function(){&lt;br /&gt;
&lt;br /&gt;
   customOnLoad();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Last Option In Array (Numbers) (Checkboxes) Row Excludes All Others=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 2.05, IE 7-10, Firefox&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround uses JavaScript/jQuery to make the last option of each Array (Numbers) (Checkboxes) row exclude all other options in the same row.&lt;br /&gt;
&lt;br /&gt;
The script will uncheck all options in a row if the last option is checked and uncheck the last option in a row if any other options are checked.&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#[[Workarounds: Manipulating a survey at runtime using Javascript#How to use Script (eg. JavaScript etc.) in LimeSurvey?|Set up your survey to use JavaScript]].&lt;br /&gt;
#Place the following script in the source of the array question.&lt;br /&gt;
&lt;br /&gt;
NOTE: Care should be taken when using this script and conditional questions on the same page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;	&lt;br /&gt;
	$(document).ready(function() {&lt;br /&gt;
		// Call the exclude function using question ID&lt;br /&gt;
		excludeOpt ({QID});&lt;br /&gt;
	});&lt;br /&gt;
	&lt;br /&gt;
	// A function to make the last option in each array row exclusive&lt;br /&gt;
	function excludeOpt (qID) {&lt;br /&gt;
		&lt;br /&gt;
		var thisQuestion = $(&#039;#question&#039;+qID)&lt;br /&gt;
&lt;br /&gt;
		// Add some classes to the checkbox cells&lt;br /&gt;
		$(&#039;table.subquestions-list tbody td&#039;, thisQuestion).addClass(&#039;normalOpt&#039;);&lt;br /&gt;
		$(&#039;table.subquestions-list tbody tr&#039;, thisQuestion).each(function(i) {&lt;br /&gt;
			$(&#039;.normalOpt:last&#039;, this).removeClass(&#039;normalOpt&#039;).addClass(&#039;exlusiveOpt&#039;)&lt;br /&gt;
		});&lt;br /&gt;
&lt;br /&gt;
		// A listener on the checkbox cells&lt;br /&gt;
		$(&#039;table.subquestions-list tbody td&#039;, thisQuestion).click(function (event) {&lt;br /&gt;
			&lt;br /&gt;
			// Set some vars&lt;br /&gt;
			var thisRow = $(this).closest(&#039;tr&#039;);&lt;br /&gt;
&lt;br /&gt;
			// Uncheck the appropriate boxes in a row&lt;br /&gt;
			if ($(this).hasClass(&#039;normalOpt&#039;)) {&lt;br /&gt;
				$(&#039;.exlusiveOpt input[type=checkbox]&#039;, thisRow).attr(&#039;checked&#039;, false);&lt;br /&gt;
			}&lt;br /&gt;
			else {&lt;br /&gt;
				$(&#039;.normalOpt input[type=checkbox]&#039;, thisRow).attr(&#039;checked&#039;, false);&lt;br /&gt;
			}&lt;br /&gt;
		});&lt;br /&gt;
&lt;br /&gt;
		// A listener on the checkboxes&lt;br /&gt;
		$(&#039;table.subquestions tbody td input[type=checkbox]&#039;, thisQuestion).click(function (event) {&lt;br /&gt;
			&lt;br /&gt;
			// Set some vars&lt;br /&gt;
			var thisRow = $(this).closest(&#039;tr&#039;);&lt;br /&gt;
			var thisCell = $(this).closest(&#039;td&#039;);&lt;br /&gt;
&lt;br /&gt;
			// Uncheck the appropriate boxes in a row&lt;br /&gt;
			if ($(thisCell).hasClass(&#039;normalOpt&#039;)) {&lt;br /&gt;
				$(&#039;.exlusiveOpt input[type=checkbox]&#039;, thisRow).attr(&#039;checked&#039;, false);&lt;br /&gt;
			}&lt;br /&gt;
			else {&lt;br /&gt;
				$(&#039;.normalOpt input[type=checkbox]&#039;, thisRow).attr(&#039;checked&#039;, false);&lt;br /&gt;
			}&lt;br /&gt;
		});&lt;br /&gt;
	}	&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Add Navigation Buttons (Next and Previous) To Top Of Page=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Add the following to the end of template.js. It will insert a new div after the progress bar and then insert clones of the nav buttons in the new div.&lt;br /&gt;
&lt;br /&gt;
This example is for the default template in 1.90 or 1.91. The placement of the new div may need to be modified for other templates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
		// Insert a new div after the progress bar&lt;br /&gt;
		$(&#039;&amp;lt;div id=&amp;quot;navigator2&amp;quot; /&amp;gt;&#039;).insertAfter(&#039;#progress-wrapper&#039;);&lt;br /&gt;
&lt;br /&gt;
		// Style the new div&lt;br /&gt;
		$(&#039;#navigator2&#039;).css({&lt;br /&gt;
			&#039;text-align&#039;:&#039;center&#039;&lt;br /&gt;
		});&lt;br /&gt;
&lt;br /&gt;
		// Insert clones of the nav buttons in the new div&lt;br /&gt;
		$(&#039;input.submit:eq(0)&#039;).clone().appendTo(&#039;#navigator2&#039;);&lt;br /&gt;
		$(&#039;input.submit:eq(2)&#039;).clone().appendTo(&#039;#navigator2&#039;);&lt;br /&gt;
&lt;br /&gt;
		// Give the new buttons some new IDs&lt;br /&gt;
		$(&#039;#navigator2 input.submit&#039;).each(function(i) {&lt;br /&gt;
			var oldID = $(this).attr(&#039;id&#039;);&lt;br /&gt;
			var newID = oldID + &#039;2&#039;;&lt;br /&gt;
			$(this).attr(&#039;id&#039;, newID)&lt;br /&gt;
		});&lt;br /&gt;
	});&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:extra_buttons.png]]&lt;br /&gt;
&lt;br /&gt;
=How to &#039;&#039;add&#039;&#039; an opt out link to your survey=&lt;br /&gt;
&lt;br /&gt;
Tested with: 1.91+, Firefox 5.0&lt;br /&gt;
&lt;br /&gt;
This javascript inserts a link to opt out of the survey above the progress bar.&lt;br /&gt;
&lt;br /&gt;
[[Workarounds: Manipulating a survey at runtime using Javascript#How to use Script (eg. JavaScript etc.) in LimeSurvey?|How to use script here]]&lt;br /&gt;
&lt;br /&gt;
Then insert the following code into to the source of a group description or a question. I used the group description.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt; &amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
		// Find the survey ID&lt;br /&gt;
		if($(&#039;input#fieldnames&#039;).length != 0) {&lt;br /&gt;
			var fieldNames = $(&#039;input#fieldnames&#039;).attr(&#039;value&#039;);&lt;br /&gt;
			var tmp = fieldNames.split(&#039;X&#039;);&lt;br /&gt;
			var sID = tmp[0];&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		// Insert a new div after the progress bar&lt;br /&gt;
		$(&#039;&amp;lt;div id=&amp;quot;optOutLink&amp;quot; /&amp;gt;&#039;).insertBefore(&#039;#progress-wrapper&#039;);&lt;br /&gt;
&lt;br /&gt;
		// Style the new div&lt;br /&gt;
		$(&#039;#optOutLink&#039;).css({&lt;br /&gt;
			&#039;text-align&#039;:&#039;center&#039;&lt;br /&gt;
		});&lt;br /&gt;
&lt;br /&gt;
		// Insert opt out url in the new div&lt;br /&gt;
		$(&#039;#optOutLink&#039;).html(&#039;&amp;lt;p&amp;gt;&amp;lt;a href=&amp;quot;optout.php?lang=en&amp;amp;sid;=&#039;+sID+&#039;&amp;amp;token;={TOKEN}&amp;quot;&amp;gt;Click here to opt out of this survey.&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;&amp;lt;br&amp;gt;&#039;);&lt;br /&gt;
&lt;br /&gt;
	});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Anonymously track respondents answers across multiple surveys=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.91+ and 1.92+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround uses JavaScript/jQuery to enable tracking of respondents across multiple surveys ensuring anonymity (it does not use tokens).&lt;br /&gt;
&lt;br /&gt;
To do this you have to use this question in all the surveys you want to link respondents answers.&lt;br /&gt;
&lt;br /&gt;
This workaround create an ID by asking some partial personal information (like initials, birth month ...). The ID will be encrypted using a one-way function (in this case SHA-1) and stored in a short text answer.&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#[[Workarounds: Manipulating a survey at runtime using Javascript#How to use Script (eg. JavaScript etc.) in LimeSurvey?|Set up your survey to use JavaScript]].&lt;br /&gt;
#Place the following code in the source of a short text question.&lt;br /&gt;
#Optional: you can also add other select field to avoid collisions (e.g. for large population sample)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;This answers are used to generate your ID. These information will be encrypted, it will not be possible in any case to identify you neither from your answers nor from your ID.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;Initial of your name&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;select id=&amp;quot;field1&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;&amp;quot;&amp;gt;&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;A&amp;quot;&amp;gt;A&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;B&amp;quot;&amp;gt;B&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;C&amp;quot;&amp;gt;C&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;D&amp;quot;&amp;gt;D&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;E&amp;quot;&amp;gt;E&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;F&amp;quot;&amp;gt;F&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;G&amp;quot;&amp;gt;G&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;H&amp;quot;&amp;gt;H&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;I&amp;quot;&amp;gt;I&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;J&amp;quot;&amp;gt;J&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;K&amp;quot;&amp;gt;K&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;L&amp;quot;&amp;gt;L&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;M&amp;quot;&amp;gt;M&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;N&amp;quot;&amp;gt;N&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;O&amp;quot;&amp;gt;O&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;P&amp;quot;&amp;gt;P&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;Q&amp;quot;&amp;gt;Q&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;R&amp;quot;&amp;gt;R&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;S&amp;quot;&amp;gt;S&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;T&amp;quot;&amp;gt;T&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;U&amp;quot;&amp;gt;U&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;V&amp;quot;&amp;gt;V&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;W&amp;quot;&amp;gt;W&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;X&amp;quot;&amp;gt;X&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;Y&amp;quot;&amp;gt;Y&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;Z&amp;quot;&amp;gt;Z&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/select&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;Your birth month&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;select id=&amp;quot;field2&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;&amp;quot;&amp;gt;&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;01&amp;quot;&amp;gt;January&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;02&amp;quot;&amp;gt;February&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;03&amp;quot;&amp;gt;March&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;04&amp;quot;&amp;gt;April&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;05&amp;quot;&amp;gt;May&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;06&amp;quot;&amp;gt;June&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;07&amp;quot;&amp;gt;July&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;08&amp;quot;&amp;gt;August&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;09&amp;quot;&amp;gt;September&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;10&amp;quot;&amp;gt;October&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;11&amp;quot;&amp;gt;November&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;12&amp;quot;&amp;gt;December&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/select&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;http://crypto-js.googlecode.com/svn/tags/3.0.2/build/rollups/sha1.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
   $(&amp;quot;#answer{SGQ}&amp;quot;).attr(&#039;readonly&#039;, &#039;readonly&#039;);&lt;br /&gt;
&lt;br /&gt;
   //$(&amp;quot;#answer{SGQ}&amp;quot;).css(&#039;display&#039;, &#039;none&#039;); //uncomment this line for not displaying the code&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
$(&#039;#field1, #field2&#039;).bind(&#039;change keyup&#039;, function() {&lt;br /&gt;
&lt;br /&gt;
   if ($(&amp;quot;#field1&amp;quot;).val()==&#039;&#039; || $(&amp;quot;#field2&amp;quot;).val()==&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
       $(&amp;quot;#answer{SGQ}&amp;quot;).val(&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
   else {&lt;br /&gt;
&lt;br /&gt;
       var sha1 = CryptoJS.algo.SHA1.create();&lt;br /&gt;
&lt;br /&gt;
       sha1.update($(&amp;quot;#field1&amp;quot;).val());&lt;br /&gt;
&lt;br /&gt;
       sha1.update($(&amp;quot;#field2&amp;quot;).val());&lt;br /&gt;
&lt;br /&gt;
       // sha1.update($(&amp;quot;#otherfield&amp;quot;).val());&lt;br /&gt;
&lt;br /&gt;
       var hash = sha1.finalize();&lt;br /&gt;
&lt;br /&gt;
       $(&amp;quot;#answer{SGQ}&amp;quot;).val(hash);&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Check validity of international phone number in subquestion=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.91+, Firefox 8, Chrome 15&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
As of version 1.92, you can use the core Validation querstion option to validate multiple short text and array text questions. Any question that fails that validation check will have its background color changed to red.&lt;br /&gt;
&lt;br /&gt;
Note, the below workaround will fail in version 1.92 because it contains a regular expression with curly braces.  However, as described above, support for this feature is now built-in to version 1.92&lt;br /&gt;
&lt;br /&gt;
This workaround uses javascript to check the validity of an international phone number in a subquestion of multiple short text.&lt;br /&gt;
&lt;br /&gt;
Add the following code to the source of your question.&lt;br /&gt;
&lt;br /&gt;
Replace &amp;quot;QQ&amp;quot; with the question ID and &amp;quot;NN&amp;quot; with the row number that you want to validate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Call the phone function with the question ID and the row number&lt;br /&gt;
&lt;br /&gt;
       phoneTest(QQ, NN);&lt;br /&gt;
&lt;br /&gt;
       function phoneTest(qID, inputNum) {&lt;br /&gt;
&lt;br /&gt;
           // Interrupt next/submit function&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#movenextbtn, #movesubmitbtn&#039;).click(function(){&lt;br /&gt;
&lt;br /&gt;
               // Some vars - modify as required&lt;br /&gt;
&lt;br /&gt;
               var phoneMatch = /^[0-9,+,(), ,]{1,}(,[0-9]+){0,}$/;&lt;br /&gt;
&lt;br /&gt;
               var msg1 = &#039;Please enter a valid phone number.&#039;;&lt;br /&gt;
&lt;br /&gt;
               // Test the input&lt;br /&gt;
&lt;br /&gt;
               var phoneInput = $(&#039;#question&#039;+qID+&#039; li:eq(&#039;+(inputNum-1)+&#039;) input.text&#039;).val();&lt;br /&gt;
&lt;br /&gt;
               if(phoneInput != &#039;&#039; &amp;amp;&amp;amp; !phoneMatch.test(phoneInput)) {&lt;br /&gt;
&lt;br /&gt;
                   alert(msg1);&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;#question&#039;+qID+&#039; li:eq(&#039;+(inputNum-1)+&#039;) input.text&#039;).css({ &#039;background&#039;:&#039;pink&#039; });&lt;br /&gt;
&lt;br /&gt;
                   return false;&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               else {&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;#question&#039;+qID+&#039; li:eq(&#039;+(inputNum-1)+&#039;) input.text&#039;).css({ &#039;background&#039;:&#039;&#039; });&lt;br /&gt;
&lt;br /&gt;
                   return true;&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The regex is from: [http://www.regexlib.com/REDetails.aspx?regexp_id=1136 regexlib.com blank]&lt;br /&gt;
&lt;br /&gt;
=Check validity of email address in subquestion=&lt;br /&gt;
&lt;br /&gt;
&#039;Tested with: 1.91+, Firefox 8, Chrome 15&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, you can use the core Validation querstion option to validate multiple short text and array text questions. Any question that fails that validation check will have its background color changed to red.&amp;lt;br /&amp;gt;Note, the below workaround will fail in version 1.92 because it contains a regular expression with curly braces.  However, as described above, support for this feature is now built-in to version 1.92&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround uses javascript to check the validity of an email address in a subquestion of multiple short text.&lt;br /&gt;
&lt;br /&gt;
Add the following code to the source of your question.&lt;br /&gt;
&lt;br /&gt;
Replace &amp;quot;QQ&amp;quot; with the question ID and &amp;quot;NN&amp;quot; with the row number that you want to validate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Call the email function with the question ID and the row number&lt;br /&gt;
&lt;br /&gt;
       emailTest(QQ, NN);&lt;br /&gt;
&lt;br /&gt;
       function emailTest(qID, inputNum) {&lt;br /&gt;
&lt;br /&gt;
           // Interrupt next/submit function&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#movenextbtn, #movesubmitbtn&#039;).click(function(){&lt;br /&gt;
&lt;br /&gt;
               // Some vars - modify as required&lt;br /&gt;
&lt;br /&gt;
               var emailMatch = /^[a-zA-Z0-9\_\-]+[a-zA-Z0-9\.\_\-]*@([a-zA-Z0-9\_\-]+\.)+([a-zA-Z]{2,4}|travel|museum)$/;&lt;br /&gt;
&lt;br /&gt;
               var msg1 = &#039;Please enter a valid email address.&#039;;&lt;br /&gt;
&lt;br /&gt;
               // Test the input&lt;br /&gt;
&lt;br /&gt;
               var emailInput = $(&#039;#question&#039;+qID+&#039; li:eq(&#039;+(inputNum-1)+&#039;) input.text&#039;).val();&lt;br /&gt;
&lt;br /&gt;
               if(emailInput != &#039;&#039; &amp;amp;&amp;amp; !emailMatch.test(emailInput)) {&lt;br /&gt;
&lt;br /&gt;
                   alert(msg1);&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;#question&#039;+qID+&#039; li:eq(&#039;+(inputNum-1)+&#039;) input.text&#039;).css({ &#039;background&#039;:&#039;pink&#039; });&lt;br /&gt;
&lt;br /&gt;
                   return false;&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               else {&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;#question&#039;+qID+&#039; li:eq(&#039;+(inputNum-1)+&#039;) input.text&#039;).css({ &#039;background&#039;:&#039;&#039; });&lt;br /&gt;
&lt;br /&gt;
                   return true;&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The regex is from: [http://www.regexlib.com/REDetails.aspx?regexp_id=1653 regexlib.com blank]&lt;br /&gt;
&lt;br /&gt;
=Hiding the help-text when it&#039;s empty=&lt;br /&gt;
&lt;br /&gt;
Tested with: 1.91+&lt;br /&gt;
&lt;br /&gt;
I had made a style in my template putting a border around my help-text. To avoid empty help-text to show up (and have lines instead of just &#039;nothing&#039; when there was no help text, I used this piece of code in question.pstpl:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
                   var questionhelp=&amp;quot;{QUESTIONHELP}&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
                   if (questionhelp==&amp;quot;&amp;quot;) {&lt;br /&gt;
&lt;br /&gt;
                          document.write(&amp;quot;&amp;quot;);}&lt;br /&gt;
&lt;br /&gt;
                   else {&lt;br /&gt;
&lt;br /&gt;
                   document.write(&#039;&amp;lt;tr&amp;gt;&amp;lt;td class=&amp;quot;survey-question-help&amp;quot;&amp;gt;&#039;+ questionhelp +&#039;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&#039;);}&lt;br /&gt;
&lt;br /&gt;
               &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
it can probably be optimized but it worked for me&lt;br /&gt;
&lt;br /&gt;
=Disable or hide selected fields in a matrix question=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.92+, IE 7/8/9, FireFox 12/13&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
TASK&lt;br /&gt;
&lt;br /&gt;
Hide or disable selected fields in a Matrix, so that users cannot make any input.&lt;br /&gt;
&lt;br /&gt;
(See example, where users should not make input into red framed fields)&lt;br /&gt;
&lt;br /&gt;
[[File:snap035.gif]]&lt;br /&gt;
&lt;br /&gt;
Fig. 1: Prevent users from input into first two fields (as an example)&lt;br /&gt;
&lt;br /&gt;
SOLUTION&lt;br /&gt;
&lt;br /&gt;
First find the name of the fields you want to hide / disable. In my case I used Firebug with firefox to figure that out.&lt;br /&gt;
&lt;br /&gt;
[[File:snap037.gif]]&lt;br /&gt;
&lt;br /&gt;
Fig. 2: Figure out the name(s) of the field(s)&lt;br /&gt;
&lt;br /&gt;
Then put the following script-code into the HTML-source code as described above:&lt;br /&gt;
&lt;br /&gt;
Note: you have to change the code to match the names of your fields!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input[name=&amp;quot;69965X2X10SQ001_SQ001&amp;quot;]&#039;).attr(&#039;disabled&#039;, &#039;disabled&#039;);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input[name=&amp;quot;69965X2X10SQ001_SQ002&amp;quot;]&#039;).attr(&#039;hidden&#039;, &#039;hidden&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:snap039.gif]]&lt;br /&gt;
&lt;br /&gt;
Fig. 3: Result: first field is diabled (&amp;quot;greyed out&amp;quot;), second one is completely hidden&lt;br /&gt;
&lt;br /&gt;
I think this way one can apply many other attributes to a field like color etc. But did not try that myself.&lt;br /&gt;
&lt;br /&gt;
Thanks to roB2009 for the input in the forum!&lt;br /&gt;
&lt;br /&gt;
=Add prefix or suffix to question type &amp;quot;Array (Texts)&amp;quot;=&lt;br /&gt;
&lt;br /&gt;
TASK&lt;br /&gt;
&lt;br /&gt;
Add a prefix or suffix to the text fields in questions of the &amp;quot;Array (Texts)&amp;quot; type.&lt;br /&gt;
&lt;br /&gt;
[[File:suffix.png]]&lt;br /&gt;
&lt;br /&gt;
Fig. 1: Suffix&lt;br /&gt;
&lt;br /&gt;
[[File:prefix.png]]&lt;br /&gt;
&lt;br /&gt;
Fig. 1: Prefix&lt;br /&gt;
&lt;br /&gt;
SOLUTION&lt;br /&gt;
*Set up your survey to use JavaScript.&lt;br /&gt;
*Add the following script to the source of the array. Replace &amp;quot;12345&amp;quot; with the array question ID and modify the suffixes/prefixes as required.&lt;br /&gt;
*The function call must consist of a question ID followed by the suffixes for each column. Suffixes/Prefixes must be enclosed in quotes and comma separated.&lt;br /&gt;
*In this example question ID 12345 will get an &amp;quot;in &amp;amp;euro;&amp;quot; suffix in the first column and an &amp;quot;in %&amp;quot; in the next 3 columns.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Call the function with the question ID followed by a comma-separated list of suffixes&lt;br /&gt;
&lt;br /&gt;
       addSuffix(12345, &#039;in &amp;amp;euro;&#039;, &#039;in %&#039;, &#039;in %&#039;, &#039;in %&#039;);&lt;br /&gt;
&lt;br /&gt;
       function addSuffix() {&lt;br /&gt;
&lt;br /&gt;
           var qID = $(arguments)[0];&lt;br /&gt;
&lt;br /&gt;
           // Assign some column-specific classes&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qID+&#039; table.question tbody tr&#039;).each(function(i){&lt;br /&gt;
&lt;br /&gt;
               $(&#039;td&#039;, this).each(function(i){&lt;br /&gt;
&lt;br /&gt;
                   $(this).addClass(&#039;answerCol-&#039;+(i+1)+&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
               });&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Some styling&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qID+&#039; table.question tbody input[type=&amp;quot;text&amp;quot;]&#039;).css({&lt;br /&gt;
&lt;br /&gt;
               &#039;width&#039;: &#039;50%&#039;&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Insert the suffixes&lt;br /&gt;
&lt;br /&gt;
           $(arguments).each(function(i, val){&lt;br /&gt;
&lt;br /&gt;
               if(i &amp;gt; 0) {&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;#question&#039;+qID+&#039; td.answerCol-&#039;+i+&#039; label&#039;).append(val);&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For adding a prefix you need to substitute the following line in the code&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;$(&#039;#question&#039;+qID+&#039; td.answerCol-&#039;+i+&#039; label&#039;).append(val);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with this&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;$(&#039;#question&#039;+qID+&#039; td.answerCol-&#039;+i+&#039; label&#039;).prepend(val);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Time question (Date question-like)=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.92+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround uses JavaScript/jQuery to build a Time question just like to the Date one.&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#Download the file at [http://trentrichardson.com/examples/timepicker/jquery-ui-timepicker-addon.js trentrichardson.com/examples/timepicker/jquery-ui-timepicker-addon.js] and upload it to your survey.&lt;br /&gt;
#[[Workarounds: Manipulating a survey at runtime using Javascript#How to use Script (eg. JavaScript etc.) in LimeSurvey?|Set up your survey to use JavaScript]].&lt;br /&gt;
#Place the following code in the source of a short text question.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;/upload/surveys/{SID}/jquery-ui-timepicker-addon.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	$(document).ready(function(){&lt;br /&gt;
&lt;br /&gt;
		$(&#039;#answer{SGQ}&#039;).timepicker({&lt;br /&gt;
			timeText: &#039;Time&#039;, //here translation&lt;br /&gt;
			hourText: &#039;hour&#039;, //here translation&lt;br /&gt;
			minuteText: &#039;minute&#039;, //here translation&lt;br /&gt;
			closeText: &#039;Done&#039; //here translation&lt;br /&gt;
		});&lt;br /&gt;
&lt;br /&gt;
		$(&#039;#answer{SGQ}&#039;).attr(&#039;readonly&#039;, &#039;readonly&#039;);&lt;br /&gt;
&lt;br /&gt;
		$( &amp;quot;&amp;lt;style&amp;gt;&amp;quot;&lt;br /&gt;
		+&amp;quot;.ui-widget-header, .ui-datepicker-current { display:none; }&amp;quot;&lt;br /&gt;
		+&amp;quot;.ui-timepicker-div dl dt { height: 25px; margin-bottom: -25px; }&amp;quot;&lt;br /&gt;
		+&amp;quot;.ui-timepicker-div dl dd { margin: 0 10px 10px 65px; }&amp;quot;&lt;br /&gt;
		+&amp;quot; }&amp;quot;&lt;br /&gt;
		+&amp;quot;&amp;lt;/style&amp;gt;&amp;quot;).appendTo( &amp;quot;head&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
	});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Calculating date difference=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.92+ Build 120909&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround explains how calculate difference between two dates (in: days, weeks, months and years) and is based on this [http://ditio.net/2010/05/02/javascript-date-difference-calculation/ resource external].&lt;br /&gt;
&lt;br /&gt;
Requieres 2 groups and &#039;group by group&#039; or &#039;question by question&#039; presentation.&lt;br /&gt;
&lt;br /&gt;
Group 1 (2 date questions)&lt;br /&gt;
*1st question - Question code: &amp;quot;DD&amp;quot;&lt;br /&gt;
*2nd question - Question code: &amp;quot;D2&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Group 2&lt;br /&gt;
*1 numerical input question.&lt;br /&gt;
&lt;br /&gt;
This question retrieves the number of days between the 2 dates, and check if D2 is posterior than DD.&lt;br /&gt;
&lt;br /&gt;
All the requiered code have to be added in the source of this numerical question.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
&lt;br /&gt;
Adapted from http://ditio.net/2010/05/02/javascript-date-difference-calculation/&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
var DateDiff = {&lt;br /&gt;
&lt;br /&gt;
   inDays: function(d1, d2) {&lt;br /&gt;
&lt;br /&gt;
       var t2 = d2.getTime();&lt;br /&gt;
&lt;br /&gt;
       var t1 = d1.getTime();&lt;br /&gt;
&lt;br /&gt;
       return parseInt[[t2-t1)/(24*3600*1000]];&lt;br /&gt;
&lt;br /&gt;
   },&lt;br /&gt;
&lt;br /&gt;
   inWeeks: function(d1, d2) {&lt;br /&gt;
&lt;br /&gt;
       var t2 = d2.getTime();&lt;br /&gt;
&lt;br /&gt;
       var t1 = d1.getTime();&lt;br /&gt;
&lt;br /&gt;
       return parseInt[[t2-t1)/(24*3600*1000*7]];&lt;br /&gt;
&lt;br /&gt;
   },&lt;br /&gt;
&lt;br /&gt;
   inMonths: function(d1, d2) {&lt;br /&gt;
&lt;br /&gt;
       var d1Y = d1.getFullYear();&lt;br /&gt;
&lt;br /&gt;
       var d2Y = d2.getFullYear();&lt;br /&gt;
&lt;br /&gt;
       var d1M = d1.getMonth();&lt;br /&gt;
&lt;br /&gt;
       var d2M = d2.getMonth();&lt;br /&gt;
&lt;br /&gt;
       return (d2M+12*d2Y)-(d1M+12*d1Y);&lt;br /&gt;
&lt;br /&gt;
   },&lt;br /&gt;
&lt;br /&gt;
   inYears: function(d1, d2) {&lt;br /&gt;
&lt;br /&gt;
       return d2.getFullYear()-d1.getFullYear();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
d1 = new Date({substr(DD,0,4)}, {substr(DD,5,2)}, {substr(DD,8,2)});&lt;br /&gt;
&lt;br /&gt;
d2 = new Date({substr(D2,0,4)}, {substr(D2,5,2)}, {substr(D2,8,2)});&lt;br /&gt;
&lt;br /&gt;
// Displays result&lt;br /&gt;
&lt;br /&gt;
document.write(&amp;quot;&amp;lt;br /&amp;gt;Number of &amp;lt;b&amp;gt;days&amp;lt;/b&amp;gt;: &amp;quot;+DateDiff.inDays(d1, d2));&lt;br /&gt;
&lt;br /&gt;
document.write(&amp;quot;&amp;lt;br /&amp;gt;Number of &amp;lt;b&amp;gt;weeks&amp;lt;/b&amp;gt;: &amp;quot;+DateDiff.inWeeks(d1, d2));&lt;br /&gt;
&lt;br /&gt;
document.write(&amp;quot;&amp;lt;br /&amp;gt;Number of &amp;lt;b&amp;gt;months&amp;lt;/b&amp;gt;: &amp;quot;+DateDiff.inMonths(d1, d2));&lt;br /&gt;
&lt;br /&gt;
document.write(&amp;quot;&amp;lt;br /&amp;gt;Number of &amp;lt;b&amp;gt;years&amp;lt;/b&amp;gt;: &amp;quot;+DateDiff.inYears(d1, d2));&lt;br /&gt;
&lt;br /&gt;
// filled the numerical input with number of days (or nights)&lt;br /&gt;
&lt;br /&gt;
var nDays = +DateDiff.inDays(d1, d2);&lt;br /&gt;
&lt;br /&gt;
    jQuery(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       $(&amp;quot;.numeric:eq(0) input.text&amp;quot;).val(nDays);&lt;br /&gt;
&lt;br /&gt;
               $(&amp;quot;.numeric:eq(0) input.text&amp;quot;).attr(&#039;readonly&#039;,&#039;readonly&#039;);&lt;br /&gt;
&lt;br /&gt;
// check if d2 &amp;gt; d1&lt;br /&gt;
&lt;br /&gt;
               $(&#039;#movenextbtn&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
               $(&#039;#movesubmitbtn&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
               if(nDays &amp;gt;= 0){&lt;br /&gt;
&lt;br /&gt;
       // automatic submit (uncomment if needed)&lt;br /&gt;
&lt;br /&gt;
               // document.limesurvey.submit();&lt;br /&gt;
&lt;br /&gt;
               // $(&#039;body&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
                 }&lt;br /&gt;
&lt;br /&gt;
               else alert(&amp;quot;Check out date must be posterior than Check in\nPlease return to the previous page and edit your answers&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=How to set minDate/maxDate based on other Datequestions=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039; tested with Version 2.00+ Build 130708&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
QQ1 and QQ2 are the question identifiers. QQ2 gets as maxDate today and as minDate the date set in QQ1. The onClose event is needed because on document.ready the value of QQ1 is not yet known, although the value of today is.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
    $(document).ready(function () {&lt;br /&gt;
        &#039;use strict&#039;;&lt;br /&gt;
        var qID1 = QQ1,&lt;br /&gt;
            qID2 = QQ2,&lt;br /&gt;
            q1 = $(&#039;#question&#039; + &#039;QQ1&#039; + &#039; .popupdate&#039;), &lt;br /&gt;
            q2 = $(&#039;#question&#039; + &#039;QQ2&#039; + &#039; .popupdate&#039;);&lt;br /&gt;
	&lt;br /&gt;
        //if q1 loses focus, its value is taken and used as minDate in q2   &lt;br /&gt;
        q1.datepicker(&amp;quot;option&amp;quot;, &amp;quot;onClose&amp;quot;, function (datum){&lt;br /&gt;
            q2.datepicker( &amp;quot;option&amp;quot;, &amp;quot;minDate&amp;quot;, datum );&lt;br /&gt;
        });&lt;br /&gt;
        //q2 gets today as its maxDate&lt;br /&gt;
        q2.datepicker( &#039;option&#039;, &#039;maxDate&#039;, new Date() );&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Remove Question Help if empty=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Version 2.00+ Build 130513&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Change your question.pstpl in your Template Editor so that the line looks like below. I&#039;ve added the ID tag help_{question_number}.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td class=&amp;quot;survey-question-help&amp;quot; id=help_{QUESTION_NUMBER}&amp;gt;{QUESTIONHELP}&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can then add the following javascript at the end of question.pstpl. If the contents of the help tag is empty then hide the element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
$(document).ready(function(){&lt;br /&gt;
  if($(&#039;#help_{QUESTION_NUMBER}&#039;).is(&#039;:empty&#039;)){&lt;br /&gt;
  $(&#039;#help_{QUESTION_NUMBER}&#039;).hide();&lt;br /&gt;
  }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Implicit Association Test (IAT)=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 2.0, IE 7-10, Firefox, Chrome, iPad&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround uses JavaScript to insert an IAT interface into an Array (Texts) question. The workaround prompts respondents to assign words or phrases using the &amp;quot;E&amp;quot; or &amp;quot;I&amp;quot; keys. In mobile devices, &amp;quot;E&amp;quot; and &amp;quot;I&amp;quot; buttons are provided.&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Iat_1.png]]&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download a [[Media:Demo_IAT_Concept.zip|working template]] and [[Media:Demo_iat_concept.lss|working survey]].&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
&lt;br /&gt;
1) [[Workarounds: Manipulating a survey at runtime using Javascript#How to use Script (eg. JavaScript etc.) in LimeSurvey?|Set up your survey to use JavaScript]].&lt;br /&gt;
&lt;br /&gt;
2) Create your Array (Texts) with sub-questions as follows:&amp;lt;br /&amp;gt;&lt;br /&gt;
- Y scale - all of your &amp;quot;attribut&amp;quot; words or phrases&amp;lt;br /&amp;gt;&lt;br /&gt;
- X scale - &amp;quot;Key Pressed&amp;quot; and &amp;quot;Elapsed Time (ms)&amp;quot;&amp;lt;br /&amp;gt;&lt;br /&gt;
[[File:Iat_2.jpg]]&lt;br /&gt;
&lt;br /&gt;
3) Insert your association terms and the other text elements for the interface into the Question Help section as depicted below. The text strings must be separated with &amp;quot;double pipes&amp;quot; (||) and you will need to place them in the following order:&amp;lt;br /&amp;gt;&lt;br /&gt;
- Left association term&amp;lt;br /&amp;gt;&lt;br /&gt;
- Right association term&amp;lt;br /&amp;gt;&lt;br /&gt;
- Instructional text&amp;lt;br /&amp;gt;&lt;br /&gt;
- Finished text&amp;lt;br /&amp;gt;&lt;br /&gt;
[[File:Iat_3.png]]&lt;br /&gt;
&lt;br /&gt;
4) Add the following to the end of template.js:&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
// A plugin to insert an IAT interface&lt;br /&gt;
function implicitAssociation(el, showAnswers) {&lt;br /&gt;
		&lt;br /&gt;
	$(el).each(function() {&lt;br /&gt;
			&lt;br /&gt;
		var thisQuestion = $(this);&lt;br /&gt;
		var thisQuestionHelp = $(&#039;img[src$=&amp;quot;help.gif&amp;quot;]&#039;, thisQuestion).parent();&lt;br /&gt;
		var thisQuestionAnswers = $(&#039;table.question&#039;, thisQuestion).parent();&lt;br /&gt;
		var startTime = &#039;&#039;;&lt;br /&gt;
		var endTime = &#039;&#039;;	&lt;br /&gt;
		var agent = navigator.userAgent.toLowerCase();&lt;br /&gt;
		var mobile = false;&lt;br /&gt;
		if( /android|webos|iphone|ipad|ipod|blackberry/i.test(navigator.userAgent) ) { // Mobile devices&lt;br /&gt;
			mobile = true;&lt;br /&gt;
		}&lt;br /&gt;
		mobile = true;&lt;br /&gt;
		&lt;br /&gt;
		// Some classes&lt;br /&gt;
		$(thisQuestion).addClass(&#039;iatQuestion&#039;);&lt;br /&gt;
		$(&#039;.subquestion-list&#039;).addClass(&#039;unanswered&#039;);&lt;br /&gt;
		&lt;br /&gt;
		// Hide the question help element&lt;br /&gt;
		$(thisQuestionHelp).hide();&lt;br /&gt;
		&lt;br /&gt;
		// Hide the answers&lt;br /&gt;
		if(showAnswers != true) {&lt;br /&gt;
			$(&#039;table.question&#039;, thisQuestion).hide();&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		// Insert IAT display&lt;br /&gt;
		var iatTexts = $(thisQuestionHelp).text().split(&#039;||&#039;);&lt;br /&gt;
		var iatDisplayHTML = &#039;&amp;lt;div class=&amp;quot;iatWrapper&amp;quot;&amp;gt;\&lt;br /&gt;
								&amp;lt;div class=&amp;quot;iatLeftLabel&amp;quot;&amp;gt;&#039;+iatTexts[0]+&#039;&amp;lt;/div&amp;gt;\&lt;br /&gt;
								&amp;lt;div class=&amp;quot;iatRightLabel&amp;quot;&amp;gt;&#039;+iatTexts[1]+&#039;&amp;lt;/div&amp;gt;\&lt;br /&gt;
								&amp;lt;div class=&amp;quot;iatWord&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;\&lt;br /&gt;
								&amp;lt;div class=&amp;quot;iatInstructions&amp;quot;&amp;gt;&#039;+iatTexts[2]+&#039;&amp;lt;/div&amp;gt;\&lt;br /&gt;
							&amp;lt;/div&amp;gt;\&lt;br /&gt;
							&amp;lt;div class=&amp;quot;iatMobileButtonWrapper&amp;quot;&amp;gt;\&lt;br /&gt;
								&amp;lt;div class=&amp;quot;iatButton iatLeftButton&amp;quot;&amp;gt;E&amp;lt;/div&amp;gt;\&lt;br /&gt;
								&amp;lt;div class=&amp;quot;iatButton iatRightButton&amp;quot;&amp;gt;I&amp;lt;/div&amp;gt;\&lt;br /&gt;
								&amp;lt;div style=&amp;quot;width:100%; clear:both;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;\&lt;br /&gt;
							&amp;lt;/div&amp;gt;&#039;;&lt;br /&gt;
		$(thisQuestionAnswers).prepend(iatDisplayHTML);&lt;br /&gt;
		&lt;br /&gt;
		// Show a word&lt;br /&gt;
		function iatShowWord() {&lt;br /&gt;
			$(&#039;div.iatWord&#039;, thisQuestion).text($(&#039;.subquestion-list.unanswered:first .answertext&#039;, thisQuestion).text());&lt;br /&gt;
			startTime = new Date();&lt;br /&gt;
			&lt;br /&gt;
			$(document).bind(&#039;keypress.iatKeypress&#039;, function(e) {&lt;br /&gt;
				if(e.which == 101 || e.which == 105) {&lt;br /&gt;
					var thisRow = $(&#039;.subquestion-list.unanswered:eq(0)&#039;, thisQuestion);&lt;br /&gt;
					$(thisRow).removeClass(&#039;unanswered&#039;);&lt;br /&gt;
					endTime = new Date();&lt;br /&gt;
					$(&#039;input[type=&amp;quot;text&amp;quot;]:eq(1)&#039;, thisRow).val(endTime.valueOf() - startTime.valueOf());&lt;br /&gt;
					if(e.which == 101) {&lt;br /&gt;
						$(&#039;input[type=&amp;quot;text&amp;quot;]:eq(0)&#039;, thisRow).val(&#039;E&#039;);&lt;br /&gt;
					}&lt;br /&gt;
					else {&lt;br /&gt;
						$(&#039;input[type=&amp;quot;text&amp;quot;]:eq(0)&#039;, thisRow).val(&#039;I&#039;);&lt;br /&gt;
					}&lt;br /&gt;
					$(document).unbind(&#039;keypress.iatKeypress&#039;);&lt;br /&gt;
					if($(&#039;.subquestion-list.unanswered&#039;, thisQuestion).length &amp;gt; 0) {&lt;br /&gt;
						iatShowWord();&lt;br /&gt;
					}&lt;br /&gt;
					else {&lt;br /&gt;
						$(&#039;.iatLeftLabel, .iatWord, .iatRightLabel, .iatInstructions&#039;, thisQuestion).fadeOut(&#039;slow&#039;, function() {&lt;br /&gt;
							$(&#039;div.iatWord&#039;, thisQuestion).text(iatTexts[3]);&lt;br /&gt;
							$(&#039;.iatWord&#039;, thisQuestion).addClass(&#039;done&#039;).fadeIn(&#039;slow&#039;);&lt;br /&gt;
						});&lt;br /&gt;
					}&lt;br /&gt;
				}&lt;br /&gt;
			});&lt;br /&gt;
		}&lt;br /&gt;
		function iatShowWordMobile() {&lt;br /&gt;
			$(&#039;div.iatWord&#039;, thisQuestion).text($(&#039;.subquestion-list.unanswered:first .answertext&#039;, thisQuestion).text());&lt;br /&gt;
			startTime = new Date();&lt;br /&gt;
			&lt;br /&gt;
			$(&#039;.iatButton&#039;, thisQuestion).bind(&#039;click.iatButtonClick&#039;, function(e) {&lt;br /&gt;
				var thisRow = $(&#039;.subquestion-list.unanswered:eq(0)&#039;, thisQuestion);&lt;br /&gt;
				$(thisRow).removeClass(&#039;unanswered&#039;);&lt;br /&gt;
				endTime = new Date();&lt;br /&gt;
				$(&#039;input[type=&amp;quot;text&amp;quot;]:eq(1)&#039;, thisRow).val(endTime.valueOf() - startTime.valueOf());&lt;br /&gt;
				$(&#039;input[type=&amp;quot;text&amp;quot;]:eq(0)&#039;, thisRow).val($(this).text());&lt;br /&gt;
				$(&#039;.iatButton&#039;, thisQuestion).unbind(&#039;click.iatButtonClick&#039;);&lt;br /&gt;
				if($(&#039;.subquestion-list.unanswered&#039;, thisQuestion).length &amp;gt; 0) {&lt;br /&gt;
					iatShowWordMobile();&lt;br /&gt;
				}&lt;br /&gt;
				else {&lt;br /&gt;
					$(&#039;.iatLeftLabel, .iatWord, .iatRightLabel, .iatInstructions, .iatMobileButtonWrapper&#039;, thisQuestion).fadeOut(&#039;slow&#039;, function() {&lt;br /&gt;
						$(&#039;div.iatWord&#039;, thisQuestion).text(iatTexts[3]);&lt;br /&gt;
						$(&#039;.iatWord&#039;, thisQuestion).addClass(&#039;done&#039;).fadeIn(&#039;slow&#039;);&lt;br /&gt;
					});&lt;br /&gt;
				}&lt;br /&gt;
			});&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		// Start the IAT display&lt;br /&gt;
		if(mobile == true) { // Mobile devices&lt;br /&gt;
			$(&#039;.iatMobileButtonWrapper&#039;, thisQuestion).show();&lt;br /&gt;
			$(&#039;.iatButton&#039;, thisQuestion).bind(&#039;click.iatStartMobile&#039;, function(e) {&lt;br /&gt;
				$(&#039;.iatButton&#039;, thisQuestion).unbind(&#039;click.iatStartMobile&#039;);&lt;br /&gt;
				iatShowWordMobile();&lt;br /&gt;
			});&lt;br /&gt;
		}&lt;br /&gt;
		else {&lt;br /&gt;
			$(document).bind(&#039;keypress.iatStart&#039;, function(e) { // Non-mobile devices&lt;br /&gt;
				if(e.which == 101 || e.which == 105) {&lt;br /&gt;
					$(document).unbind(&#039;keypress.iatStart&#039;);&lt;br /&gt;
					iatShowWord();&lt;br /&gt;
				}&lt;br /&gt;
			});&lt;br /&gt;
		}&lt;br /&gt;
	});&lt;br /&gt;
} &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;5) Add the following to the end of template.css:&amp;lt;syntaxhighlight lang=&amp;quot;css&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
/* IAT questions */&lt;br /&gt;
&lt;br /&gt;
.iatWrapper {&lt;br /&gt;
	position: relative;&lt;br /&gt;
	width: 600px;&lt;br /&gt;
	height: 300px;&lt;br /&gt;
	color: #FFFFFF;&lt;br /&gt;
	background-color: #000000;&lt;br /&gt;
	font-size: 21px;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.iatLeftLabel {&lt;br /&gt;
	float: left;&lt;br /&gt;
	padding: 10px;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.iatRightLabel {&lt;br /&gt;
	float: right;&lt;br /&gt;
	padding: 10px;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.iatWord {&lt;br /&gt;
	position: absolute;&lt;br /&gt;
	width: 100%;&lt;br /&gt;
	top: 35%;&lt;br /&gt;
	text-align: center;&lt;br /&gt;
	font-size: 36px;&lt;br /&gt;
	color:#0F0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.iatWord.done {&lt;br /&gt;
	color:#FFFFFF;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.iatInstructions {&lt;br /&gt;
	position: absolute;&lt;br /&gt;
	width: 100%;&lt;br /&gt;
	bottom: 0px;&lt;br /&gt;
	padding-bottom: 10px;&lt;br /&gt;
	text-align: center;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.iatMobileButtonWrapper {&lt;br /&gt;
	display: none;&lt;br /&gt;
	position: relative;&lt;br /&gt;
	width: 600px;&lt;br /&gt;
	font-size: 36px;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.iatButton {&lt;br /&gt;
	float: left;&lt;br /&gt;
	margin: 20px;&lt;br /&gt;
	width: 100px;&lt;br /&gt;
	padding: 2px 0 5px 0;&lt;br /&gt;
	border: 5px solid #999;&lt;br /&gt;
	-moz-border-radius: 10px;&lt;br /&gt;
	-webkit-border-radius: 10px;&lt;br /&gt;
	-khtml-border-radius: 10px;&lt;br /&gt;
	border-radius: 10px;&lt;br /&gt;
	text-align: center;&lt;br /&gt;
	line-height: normal;&lt;br /&gt;
	cursor: pointer;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.iatLeftButton {&lt;br /&gt;
	float: left;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.iatRightButton {&lt;br /&gt;
	float: right;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;6) To apply the plugin, add one of the two scripts below to the question source:&amp;lt;br /&amp;gt;&lt;br /&gt;
- With hidden answer table (for normally activated survey)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;	&lt;br /&gt;
	$(document).ready(function() {&lt;br /&gt;
		// Apply the IAT plugin to this question&lt;br /&gt;
		implicitAssociation(&#039;#question{QID}&#039;);&lt;br /&gt;
	});	&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
- With visible answer table (for testing purposes)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;	&lt;br /&gt;
	$(document).ready(function() {&lt;br /&gt;
		// Apply the IAT plugin to this question&lt;br /&gt;
		implicitAssociation(&#039;#question{QID}&#039;, true);&lt;br /&gt;
	});	&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Make multiple choice easier=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with Version 2.00 in Chrome, FF, Safar, IE&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The problem:&lt;br /&gt;
We often have multiple choice question, where the user has to select 4 elements out of 78 possible answers or 3 out of 25 and so on.&lt;br /&gt;
If we use pen and paper version for this questions, we noticed that the participants go through the whole list and if an answer doesn&#039;t suit on the first sight, they cross it out.&lt;br /&gt;
&lt;br /&gt;
The solution:&lt;br /&gt;
The script gives the participant the possibility to cross out this answers in a digital way. The script adds a small &amp;quot;X&amp;quot; before the checkbox. When it is clicked, the label text of the checkbox turns grey.&lt;br /&gt;
(see the attached screenshot for an example)&lt;br /&gt;
&lt;br /&gt;
Here is the script, just add it to help text&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
/**&lt;br /&gt;
* Small script that adds a &amp;quot;X&amp;quot; before a checkbox. &lt;br /&gt;
* On click the text color of the label of the checkbox turns grey&lt;br /&gt;
* If the user has to choose some answers from many options, he can &amp;quot;delete&amp;quot; answers, that on first sight looks wrong&lt;br /&gt;
* Add the script to the question in Limesurvey (for example within the source code of the help text)&lt;br /&gt;
*/&lt;br /&gt;
 &lt;br /&gt;
//Define the X (standard is a X in capitals)&lt;br /&gt;
var x = &amp;quot;X&amp;quot;;&lt;br /&gt;
css_class = &amp;quot;x&amp;quot;;&lt;br /&gt;
 &lt;br /&gt;
/*&lt;br /&gt;
* Define the style of the X&lt;br /&gt;
* Of course you can define the style in the stylesheet - if so, the script ignores the following settings&lt;br /&gt;
* If there is a style, than set style var to 1&lt;br /&gt;
*/&lt;br /&gt;
var style = 0;&lt;br /&gt;
var size = &amp;quot;12px&amp;quot;;&lt;br /&gt;
var weight = &amp;quot;bold&amp;quot;;&lt;br /&gt;
var color = &amp;quot;red&amp;quot;;&lt;br /&gt;
var cursor = &amp;quot;pointer&amp;quot;;&lt;br /&gt;
 &lt;br /&gt;
//element type - standard is a span element&lt;br /&gt;
var type = &amp;quot;span&amp;quot;;&lt;br /&gt;
 &lt;br /&gt;
//Define the new font color of the checkbox label&lt;br /&gt;
label_color = &amp;quot;#bfbfbf&amp;quot;;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
//End of configuration - start of the function&lt;br /&gt;
 &lt;br /&gt;
//Define the element that is added&lt;br /&gt;
if(style == 1) {&lt;br /&gt;
	ele = &amp;quot;&amp;lt;&amp;quot;+type+&amp;quot; class=&#039;&amp;quot;+css_class+&amp;quot;&#039;&amp;gt;&amp;quot;+x+&amp;quot;&amp;lt;/&amp;quot;+type+&amp;quot;&amp;gt;&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
	ele = &amp;quot;&amp;lt;&amp;quot;+type+&amp;quot; class=&#039;&amp;quot;+css_class+&amp;quot;&#039; style=&#039;font-size:&amp;quot;+size+&amp;quot;; font-weight:&amp;quot;+weight+&amp;quot;; color:&amp;quot;+color+&amp;quot;; cursor:&amp;quot;+cursor+&amp;quot;;&#039;&amp;gt;&amp;quot;+x+&amp;quot;&amp;lt;/&amp;quot;+type+&amp;quot;&amp;gt;&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
//Get the standard font-color of the used style&lt;br /&gt;
st_color = $(&amp;quot;label&amp;quot;).css(&amp;quot;color&amp;quot;);&lt;br /&gt;
 &lt;br /&gt;
//insert the X before the checkboxes&lt;br /&gt;
$(document).ready(function() { &lt;br /&gt;
	$(&amp;quot;li&amp;quot;).each(function(){&lt;br /&gt;
		$(this).prepend(ele);&lt;br /&gt;
	});&lt;br /&gt;
});&lt;br /&gt;
 &lt;br /&gt;
//bind an eventhandler on the X (delegate is used, because Limesurvey uses an old jQuery version)&lt;br /&gt;
var css_class_c = &amp;quot;.&amp;quot;+css_class;&lt;br /&gt;
$(document).delegate(css_class_c,&amp;quot;click&amp;quot;,function() {&lt;br /&gt;
	var color_check = $(this).siblings(&amp;quot;label&amp;quot;).data(&amp;quot;color&amp;quot;);&lt;br /&gt;
	if(color_check != &amp;quot;true&amp;quot;) {&lt;br /&gt;
    	$(this).siblings(&amp;quot;label&amp;quot;).css(&amp;quot;color&amp;quot;,label_color).data(&amp;quot;color&amp;quot;,&amp;quot;true&amp;quot;);&lt;br /&gt;
    	$(this).siblings(&#039;input&#039;).attr(&#039;checked&#039;, false);&lt;br /&gt;
 &lt;br /&gt;
	}&lt;br /&gt;
	else {&lt;br /&gt;
		$(this).siblings(&amp;quot;label&amp;quot;).css(&amp;quot;color&amp;quot;,st_color).data(&amp;quot;color&amp;quot;,&amp;quot;false&amp;quot;);&lt;br /&gt;
 &lt;br /&gt;
	}&lt;br /&gt;
});&lt;br /&gt;
 &lt;br /&gt;
$(&amp;quot;.checkbox&amp;quot;).click(function () {&lt;br /&gt;
	$(this).siblings(&amp;quot;label&amp;quot;).css(&amp;quot;color&amp;quot;,st_color).data(&amp;quot;color&amp;quot;,&amp;quot;false&amp;quot;);&lt;br /&gt;
});&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Prevent the survey from being submitted when users press enter=&lt;br /&gt;
&lt;br /&gt;
By default HTML forms are submitted when the user presses enter in any text field. This can be annoying with long survey pages or if your users are inexperienced with keyboard shortcuts.&lt;br /&gt;
&lt;br /&gt;
To disable this behavior, add the following code snippet to template.js:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;$(document).ready(function(){&lt;br /&gt;
    $(&#039;input&#039;).keypress(&lt;br /&gt;
    function(event){&lt;br /&gt;
     if (event.which == &#039;13&#039;) {&lt;br /&gt;
        event.preventDefault();&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
});&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Card Sorting=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 2.05, IE 8-11, Firefox, Chrome, iPad&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround uses JavaScript to allow dragging items into &amp;quot;buckets&amp;quot; to &amp;quot;card sort&amp;quot; them. A multiple-short-text question is used with sub-questions being the draggable items. The data recorded for each item is the &amp;quot;bucket&amp;quot; number that it was dropped in. &amp;quot;Buckets&amp;quot; are pre-defined in a list in the &amp;quot;Help&amp;quot; section of the question.&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Card_sort_1.png]]&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;DOWNLOADS:&#039;&#039;&#039;&amp;lt;br /&amp;gt;&lt;br /&gt;
- [[Media:Card_Sort.zip|Demo template]]&amp;lt;br /&amp;gt;&lt;br /&gt;
- [[Media:Card_Sort.lss|Demo survey]].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPLEMENTATION:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1) [[Workarounds: Manipulating a survey at runtime using Javascript#How to use Script (eg. JavaScript etc.) in LimeSurvey?|Set up your survey to use JavaScript]].&lt;br /&gt;
&lt;br /&gt;
2) Create your multiple-short-text with sub-questions.&lt;br /&gt;
&lt;br /&gt;
3) Insert the &amp;quot;bucket&amp;quot; labels into an unordered list in the Question Help section.&lt;br /&gt;
&lt;br /&gt;
4) Add the following to the end of template.js:&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
function cardSort(qID) {&lt;br /&gt;
 &lt;br /&gt;
	// Define some stuff...&lt;br /&gt;
	var thisQuestion = $(&#039;#question&#039;+qID);&lt;br /&gt;
	var thisQuestionHelp = $(&#039;img[alt=&amp;quot;Help&amp;quot;]&#039;, thisQuestion).parent();	&lt;br /&gt;
	thisQuestion.addClass(&#039;card-sort-question&#039;);&lt;br /&gt;
 &lt;br /&gt;
	// Hide the &amp;quot;Help&amp;quot; section&lt;br /&gt;
	thisQuestionHelp.hide();&lt;br /&gt;
 &lt;br /&gt;
	//Insert the &amp;quot;card sort&amp;quot; elements&lt;br /&gt;
	$(&#039;ul.questions-list&#039;, thisQuestion).parent().prepend(&#039;&amp;lt;div class=&amp;quot;droppable items-start&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;div class=&amp;quot;items-end-wrapper&amp;quot; /&amp;gt;&#039;);&lt;br /&gt;
	$(&#039;ul:eq(0) li&#039;, thisQuestionHelp).each(function(i) {&lt;br /&gt;
		$(&#039;.items-end-wrapper&#039;, thisQuestion).append(&#039;&amp;lt;div class=&amp;quot;items-end-inner&amp;quot;&amp;gt;\&lt;br /&gt;
													&amp;lt;div class=&amp;quot;items-end-text&amp;quot;&amp;gt;&#039;+$(this).html()+&#039;&amp;lt;/div&amp;gt;\&lt;br /&gt;
													&amp;lt;div class=&amp;quot;droppable items-end items-end-&#039;+(i+1)+&#039;&amp;quot; data-items-end=&amp;quot;&#039;+(i+1)+&#039;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;\&lt;br /&gt;
												&amp;lt;/div&amp;gt;&#039;)});&lt;br /&gt;
 &lt;br /&gt;
	// Insert the &amp;quot;cards&amp;quot;&lt;br /&gt;
	$(&#039;li.answer-item&#039;, thisQuestion).each(function(i) {&lt;br /&gt;
		var thisSGQA = $(this).attr(&#039;id&#039;).replace(/javatbd/, &#039;&#039;);&lt;br /&gt;
		var thisCode = $(this).attr(&#039;id&#039;).split(&#039;X&#039;+qID)[1];&lt;br /&gt;
		var thisHTML = $(&#039;label&#039;, this).html();&lt;br /&gt;
		$(&#039;div.items-start&#039;).append(&#039;&amp;lt;div class=&amp;quot;card draggable&amp;quot; data-sgqa=&amp;quot;&#039;+thisSGQA+&#039;&amp;quot; data-code=&amp;quot;&#039;+thisCode+&#039;&amp;quot;&amp;gt;\&lt;br /&gt;
										&#039;+thisHTML+&#039;\&lt;br /&gt;
									&amp;lt;/div&amp;gt;&#039;);&lt;br /&gt;
	});			&lt;br /&gt;
 &lt;br /&gt;
	// Make the &amp;quot;cards&amp;quot; draggable&lt;br /&gt;
	$(&#039;.draggable&#039;).draggable({ &lt;br /&gt;
		revert: &amp;quot;invalid&amp;quot;, &lt;br /&gt;
		zIndex: 2700, &lt;br /&gt;
		helper: &#039;original&#039;,&lt;br /&gt;
		start: function( event, ui ) {&lt;br /&gt;
			$(ui.helper).addClass(&#039;ui-draggable-helper&#039;);&lt;br /&gt;
		},&lt;br /&gt;
		stop: function( event, ui ) {&lt;br /&gt;
		}&lt;br /&gt;
	});&lt;br /&gt;
 &lt;br /&gt;
	// Set the targets for the draggables&lt;br /&gt;
	$(&#039;.droppable.items-start&#039;).droppable({ &lt;br /&gt;
		hoverClass: &#039;target-hover&#039;, &lt;br /&gt;
		accept: &#039;.draggable.moved&#039; &lt;br /&gt;
	});&lt;br /&gt;
	$(&#039;.droppable.items-end&#039;).droppable({ &lt;br /&gt;
		hoverClass: &#039;target-hover&#039;, &lt;br /&gt;
		accept: &#039;.draggable&#039; &lt;br /&gt;
	});&lt;br /&gt;
 &lt;br /&gt;
	// After dropped&lt;br /&gt;
	$(&#039;.droppable&#039;).bind(&#039;drop&#039;, function(event, ui) {&lt;br /&gt;
 &lt;br /&gt;
		// Physically move the draggable to the target &lt;br /&gt;
		// (the plugin just visually moves it)&lt;br /&gt;
		// (need to use a clone here to fake out iPad)&lt;br /&gt;
		var newDraggable = $(ui.draggable).clone();&lt;br /&gt;
		$(newDraggable).appendTo(this);&lt;br /&gt;
		$(ui.draggable).remove();&lt;br /&gt;
		if($(this).hasClass(&#039;items-end&#039;)) {&lt;br /&gt;
			$(newDraggable).addClass(&#039;moved&#039;);&lt;br /&gt;
		}&lt;br /&gt;
		else {&lt;br /&gt;
			$(newDraggable).removeClass(&#039;moved&#039;);&lt;br /&gt;
		}&lt;br /&gt;
		$(newDraggable).removeClass(&#039;ui-draggable-helper ui-draggable-dragging&#039;).css({&lt;br /&gt;
			&#039;z-index&#039;:&#039;&#039;,&lt;br /&gt;
			&#039;top&#039;:&#039;auto&#039;, &lt;br /&gt;
			&#039;left&#039;:&#039;auto&#039;&lt;br /&gt;
		});&lt;br /&gt;
 &lt;br /&gt;
		// Now, make this new clone draggable&lt;br /&gt;
		$(newDraggable).draggable({ &lt;br /&gt;
			revert: &amp;quot;invalid&amp;quot;, &lt;br /&gt;
			zIndex: 2700, &lt;br /&gt;
			helper: &#039;original&#039;,&lt;br /&gt;
			start: function( event, ui ) {&lt;br /&gt;
				$(ui.helper).addClass(&#039;ui-draggable-helper&#039;);&lt;br /&gt;
			},&lt;br /&gt;
			stop: function( event, ui ) {&lt;br /&gt;
			}&lt;br /&gt;
		});&lt;br /&gt;
	});&lt;br /&gt;
 &lt;br /&gt;
	// Initial &amp;quot;card&amp;quot; positions&lt;br /&gt;
	$(&#039;li.question-item input.text&#039;, thisQuestion).each(function(i) {&lt;br /&gt;
		if($(this).val() &amp;gt; 0) {&lt;br /&gt;
			$(&#039;.items-end[data-items-end=&amp;quot;&#039;+$(this).val()+&#039;&amp;quot;]&#039;).append($(&#039;.card[data-sgqa=&amp;quot;&#039;+$(this).attr(&#039;name&#039;)+&#039;&amp;quot;]&#039;));&lt;br /&gt;
			$(&#039;.card[data-sgqa=&amp;quot;&#039;+$(this).attr(&#039;name&#039;)+&#039;&amp;quot;]&#039;).appendTo($(&#039;.items-end[data-items-end=&amp;quot;&#039;+$(this).val()+&#039;&amp;quot;]&#039;)).addClass(&#039;moved&#039;);&lt;br /&gt;
		}&lt;br /&gt;
	});&lt;br /&gt;
 &lt;br /&gt;
	// Interrupt the Next/Submit function and load the inputs&lt;br /&gt;
	$(&#039;form#limesurvey&#039;).submit(function(){&lt;br /&gt;
		$(&#039;.question-item input.text&#039;, thisQuestion).val(0);&lt;br /&gt;
		$(&#039;.droppable.items-end .card&#039;, thisQuestion).each(function(i) {&lt;br /&gt;
			var thisItemsEnd = $(this).closest(&#039;.droppable.items-end&#039;).attr(&#039;data-items-end&#039;);&lt;br /&gt;
			var thisID = $(this).attr(&#039;data-sgqa&#039;);&lt;br /&gt;
			$(&#039;#answer&#039;+thisID+&#039;&#039;).val(thisItemsEnd);&lt;br /&gt;
		});&lt;br /&gt;
	});&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;5) Add the following to the end of template.css:&amp;lt;syntaxhighlight lang=&amp;quot;css&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
/* Card Sort */&lt;br /&gt;
 &lt;br /&gt;
.card-sort-question ul.subquestions-list {&lt;br /&gt;
	/*display: none;&lt;br /&gt;
	clear: both;*/&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
.card-sort-question .items-start {&lt;br /&gt;
	float: left;&lt;br /&gt;
	width: 340px;&lt;br /&gt;
	height: 317px;&lt;br /&gt;
	margin-top: 8px;&lt;br /&gt;
	border: 1px solid #666;&lt;br /&gt;
	-moz-border-radius: 6px;&lt;br /&gt;
	-webkit-border-radius: 6px;&lt;br /&gt;
	-khtml-border-radius: 6px;&lt;br /&gt;
	border-radius: 6px;&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
.card-sort-question .items-start.target-hover {&lt;br /&gt;
	background:#C9C9C9;&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
.card-sort-question .items-end-wrapper {&lt;br /&gt;
	float: left;&lt;br /&gt;
	margin-left: 20px;&lt;br /&gt;
	width: 340px;&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
.card-sort-question .items-end {&lt;br /&gt;
	width: 338px;&lt;br /&gt;
	min-height: 73px;&lt;br /&gt;
	margin-bottom: 10px;&lt;br /&gt;
	padding-bottom: 5px;&lt;br /&gt;
	border: 1px solid #666;&lt;br /&gt;
	-moz-border-radius: 6px;&lt;br /&gt;
	-webkit-border-radius: 6px;&lt;br /&gt;
	-khtml-border-radius: 6px;&lt;br /&gt;
	border-radius: 6px;&lt;br /&gt;
	background: #EBEBEB;&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
.card-sort-question .items-end.target-hover {&lt;br /&gt;
	background: #C9C9C9;&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
.card-sort-question .items-end.ui-state-disabled {&lt;br /&gt;
    opacity: 1;&lt;br /&gt;
	filter:alpha(opacity=100);&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
.card-sort-question .items-end-text {&lt;br /&gt;
	width: 338px;&lt;br /&gt;
	padding-bottom: 5px;&lt;br /&gt;
	background: #FFFFFF;&lt;br /&gt;
	font-size: 110%;&lt;br /&gt;
	font-weight: bold;&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
.card-sort-question .card  {&lt;br /&gt;
	display: inline-block;&lt;br /&gt;
	width: 140px;&lt;br /&gt;
	height: auto;&lt;br /&gt;
	margin: 5px 8px;&lt;br /&gt;
	padding: 3px;&lt;br /&gt;
    border: 2px solid #2F4354;&lt;br /&gt;
	-moz-border-radius: 8px;&lt;br /&gt;
	-webkit-border-radius: 8px;&lt;br /&gt;
	-khtml-border-radius: 8px;&lt;br /&gt;
	border-radius: 8px;&lt;br /&gt;
	background-color: #43b3d1;&lt;br /&gt;
	color: #2f4354;&lt;br /&gt;
	font-weight: bold;&lt;br /&gt;
	text-align: center;&lt;br /&gt;
	line-height: normal;&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
.card-sort-question .items-end .card  {&lt;br /&gt;
	margin: 5px 7px;&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
.card-sort-question  div.answer {&lt;br /&gt;
	clear: both;&lt;br /&gt;
	padding-top: 1px;&lt;br /&gt;
	margin-top: 0;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;6) Add this to the source of the question to apply the function.&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;	&lt;br /&gt;
	$(document).ready(function() {&lt;br /&gt;
		cardSort({QID});&lt;br /&gt;
    });&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Text Input (e.g. &amp;quot;short free text&amp;quot;, &amp;quot;huge free text&amp;quot;): Force UpperCase + onBlur Trim=&lt;br /&gt;
Add this to the source of the question to apply the function.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
	$(document).ready( function() {&lt;br /&gt;
		var my_surveyId=&#039;{SID}&#039;;&lt;br /&gt;
		var my_groupId=&#039;{self.gid}&#039;;&lt;br /&gt;
		var my_quesitonId=&#039;{self.qid}&#039;;&lt;br /&gt;
		var my_self=&#039;{self.SGQA}&#039;;&lt;br /&gt;
 &lt;br /&gt;
//		Operate for its appearance only (but have no effect to modify its intrinsic value):  Display as UpperCase&lt;br /&gt;
		$(&#039;#answer{self.SGQA}&#039;).css(&#039;text-transform&#039;, &#039;uppercase&#039;);&lt;br /&gt;
 &lt;br /&gt;
		$(&#039;#answer{self.SGQA}&#039;).blur(function(){&lt;br /&gt;
//			Operate for its intrinsic value:  Trim + Transform to Uppercase&lt;br /&gt;
			$(this).val( $.trim( $(this).val().toUpperCase() ) );&lt;br /&gt;
		});&lt;br /&gt;
	});&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Holch</name></author>
	</entry>
	<entry>
		<id>https://www.limesurvey.org/manual/index.php?title=Workarounds:_Manipulating_a_survey_at_runtime_using_Javascript&amp;diff=3789</id>
		<title>Workarounds: Manipulating a survey at runtime using Javascript</title>
		<link rel="alternate" type="text/html" href="https://www.limesurvey.org/manual/index.php?title=Workarounds:_Manipulating_a_survey_at_runtime_using_Javascript&amp;diff=3789"/>
		<updated>2012-07-06T22:50:29Z</updated>

		<summary type="html">&lt;p&gt;Holch: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
Often you want to manipulate certain elements of a survey at runtime. The only solution without touching the source code is to use Javascript or jQuery which is shipped with Limesurvey. Here are some examples to hide and style elements, validate user input or do calculations at runtime.&lt;br /&gt;
&lt;br /&gt;
Non Javascript workarounds can be found at&lt;br /&gt;
* [http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Survey+behaviour&amp;amp;structure;=English+Instructions+for+LimeSurvey Workarounds - Survey Behavior]&lt;br /&gt;
* [http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Question+design%2C+layout+and+templating Workarounds - Question design, layout and templating]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;&amp;lt;center&amp;gt;&#039;&#039;&#039;Please keep in mind that the workarounds published here are no official Limesurvey extensions but solutions that other users created for themselves.&amp;lt;br/&amp;gt;&amp;lt;span style=&#039;color:#EE0000,#FFFFFF&#039;&amp;gt;Therefore we can&#039;t give support for any solution on this page.&amp;lt;/span&amp;gt;&amp;lt;br/&amp;gt;Please contact the users that, thankfully, shared their solutions with the community if you have any questions.&#039;&#039;&#039;&amp;lt;/center&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;Note:  Version 1.92 implements many new features that make some existing workarounds obsolete.  You can continue to use existing workarounds, but may want to consider switching over to using the new features (since those new features are officially supported, and the workarounds are not).  Please review below for details of which are no longer needed.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;Also Note:  Version 1.92&#039;s Expression Manager (EM) may cause some of these work-arounds to fail.  Any custom javascript included as a .js file will be fine.  However, if you in-line your JavaScript code, you must make sure that you have a space after every opening (left) curly brace, and a space before every closing (right) curly brace.  Otherwise, EM will think that the content between the curly braces is something it should parse and understand.  I have fixed all of the work-arounds below that can be fixed (many did not follow those rules).  However, some will continue to break.  If a work-around contains a regular expression which contains curly braces (to indicate a range of repeats of a sub-expression), EM will try to process those curly braces, and thus break your regular expression.  Strategies to continue to support that work-around functionality are discussed below.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=How to &#039;&#039;add&#039;&#039; a javascript workaround solution to this Wiki page?=&lt;br /&gt;
&lt;br /&gt;
Well, this is pretty easy. Click the edit icon and create your own headline within the javascript section starting with &amp;quot;&#039;&#039;&#039;!&#039;&#039;&#039;&amp;quot;. Then add a short note about the version you have used when creating your workaround, you can copy/paste this code snippet &amp;lt;nowiki&amp;gt;&#039;&#039;Tested with: (enter Limesurvey version and maybe browser)&#039;&#039;&amp;lt;/nowiki&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Finally it&#039;s imported to mark all your code with code tags, other wise you might break this page.&lt;br /&gt;
*Start tag: &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
*End tag: &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=How to &#039;&#039;use&#039;&#039; Script (eg. JavaScript etc.) in LimeSurvey?=&lt;br /&gt;
&lt;br /&gt;
To use JavaScript within Limesurvey, the XSS filter must be turned off and the code inserted in the source of a question or a group description.&lt;br /&gt;
*Go to Global settings --&amp;gt; Security and set &amp;quot;Filter HTML for XSS&amp;quot; to &amp;quot;Off&amp;quot;.&lt;br /&gt;
* [http://docs.limesurvey.org/tiki-index.php?page=Adding+A+Question Add a new question]&lt;br /&gt;
* Edit the question and click the &amp;quot;Source&amp;quot; button in the editor toolbar:&lt;br /&gt;
&lt;br /&gt;
   [[File:editor_1.gif]]&lt;br /&gt;
* Enter your script after the question text:&lt;br /&gt;
&lt;br /&gt;
   [[File:editor_2.gif]]&lt;br /&gt;
* Save the question&lt;br /&gt;
&lt;br /&gt;
A simple test to see if JavaScript is enabled is to echo an alert. Use this code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   alert(&amp;quot;Test!&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is a good practice to use the jQuery $(document).ready function to prevent the code from executing until the page is fully loaded:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       alert(&amp;quot;Test!&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Sum up input values using Javascript=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, this is easier to do using the sum() function in [[Expression Manager|Expression Manager]].  See this [[Expression Manager HowTos|#Calculate assessment values at runtime and store the results in the survey data|HowTo example]].&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is from a survey that is a invitation to a longer party, when the user clicks to the next page, the calculated results will be shown.&lt;br /&gt;
&lt;br /&gt;
If you wonder what the {INSERTANS:1X6X12} stuff is, look at [http://docs.limesurvey.org/tiki-index.php?page=SGQA+Identifier SGQA identifier] and [http://docs.limesurvey.org/tiki-index.php?page=Adding+a+Question#Information_from_previous_answers Using information from previous answers].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;text-align: left&amp;quot;&amp;gt;These are your answers:&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;u&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;u&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;u&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;u&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;script LANGUAGE=&amp;quot;JavaScript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
partyprice = 3;&lt;br /&gt;
&lt;br /&gt;
beadclothprice = 3;&lt;br /&gt;
&lt;br /&gt;
breakfastprice = 7;&lt;br /&gt;
&lt;br /&gt;
lunchprice = 8;&lt;br /&gt;
&lt;br /&gt;
dinnerprice = 10;&lt;br /&gt;
&lt;br /&gt;
foodtotal = 0;&lt;br /&gt;
&lt;br /&gt;
var isreallytrue = &amp;quot;Yes&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
var noanswer = &amp;quot;No answer&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
document.write( &amp;quot;Can you come? = {INSERTANS:45251X1X1}&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
if (&amp;quot;{INSERTANS:45251X1X1}&amp;quot; == isreallytrue )&lt;br /&gt;
&lt;br /&gt;
  {&lt;br /&gt;
&lt;br /&gt;
   if (&amp;quot;{INSERTANS:45251X1X3}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
   else { answer = &amp;quot;{INSERTANS:45251X1X3}&amp;quot;; }&lt;br /&gt;
&lt;br /&gt;
   partypeople = parseInt(answer);&lt;br /&gt;
&lt;br /&gt;
   partytotal = partyprice * partypeople;&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;It&#039;s {INSERTANS:45251X1X3} persons who will come = &amp;quot; + partytotal + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   if (&amp;quot;{INSERTANS:45251X1X4}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
   else { answer = &amp;quot;{INSERTANS:45251X1X4}&amp;quot;;}&lt;br /&gt;
&lt;br /&gt;
   beadcloths = parseInt(answer);&lt;br /&gt;
&lt;br /&gt;
   beadclothtotal = beadclothprice * beadcloths;&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;You want to borrow {INSERTANS:45251X1X4} beadcloths = &amp;quot; + beadclothtotal + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;Will you be there thursday? = {INSERTANS:45251X1X5}&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;On friday you will have these meals: &amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   if (&amp;quot;{INSERTANS:45251X1X71}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
   else { answer = &amp;quot;{INSERTANS:45251X1X71}&amp;quot;;}&lt;br /&gt;
&lt;br /&gt;
   breakfastfriday = parseInt(answer) * breakfastprice;&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; breakfeasts = &amp;quot; + breakfastfriday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   if (&amp;quot;{INSERTANS:45251X1X72}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
   else { answer = &amp;quot;{INSERTANS:45251X1X72}&amp;quot;;}&lt;br /&gt;
&lt;br /&gt;
   lunchfriday = parseInt(answer) * lunchprice ;&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; lunches = &amp;quot; + lunchfriday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   if (&amp;quot;{INSERTANS:45251X1X73}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
   else { answer = &amp;quot;{INSERTANS:45251X1X73}&amp;quot;;}&lt;br /&gt;
&lt;br /&gt;
   dinnerfriday = parseInt(answer)* dinnerprice ;&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; dinners = &amp;quot; + dinnerfriday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   foodtotal = breakfastfriday + lunchfriday + dinnerfriday;&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;Will you be there saturday? = {INSERTANS:45251X1X8}&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   if (&amp;quot;{INSERTANS:45251X1X8}&amp;quot; == isreallytrue )&lt;br /&gt;
&lt;br /&gt;
      {&lt;br /&gt;
&lt;br /&gt;
       document.write( &amp;quot;On saturday you will have these meals: &amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
       if (&amp;quot;{INSERTANS:45251X1X91}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
       else { answer = &amp;quot;{INSERTANS:45251X1X91}&amp;quot;; }&lt;br /&gt;
&lt;br /&gt;
       breakfastsaturday = parseInt(answer) * breakfastprice ;&lt;br /&gt;
&lt;br /&gt;
       document.write(&amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; breakfeasts = &amp;quot; + breakfastsaturday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
       if (&amp;quot;{INSERTANS:45251X1X92}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
       else { answer = &amp;quot;{INSERTANS:45251X1X92}&amp;quot;; }&lt;br /&gt;
&lt;br /&gt;
       lunchsaturday = parseInt(answer) * lunchprice ;&lt;br /&gt;
&lt;br /&gt;
       document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; lunches = &amp;quot; + lunchsaturday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
       if (&amp;quot;{INSERTANS:45251X1X93}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
       else { answer = &amp;quot;{INSERTANS:45251X1X93}&amp;quot;; }&lt;br /&gt;
&lt;br /&gt;
       dinnersaturday = parseInt(answer) * dinnerprice ;&lt;br /&gt;
&lt;br /&gt;
       document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; dinners = &amp;quot; + dinnersaturday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
       foodtotal = foodtotal + breakfastsaturday + lunchsaturday + dinnersaturday;&lt;br /&gt;
&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;Will you be there sunday? = {INSERTANS:45251X1X10}&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   if (&amp;quot;{INSERTANS:45251X1X10}&amp;quot; == isreallytrue )&lt;br /&gt;
&lt;br /&gt;
      {&lt;br /&gt;
&lt;br /&gt;
       document.write( &amp;quot;On sunday you will have these meals: &amp;lt;br&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
       if (&amp;quot;{INSERTANS:45251X1X111}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
       else { answer = &amp;quot;{INSERTANS:45251X1X111}&amp;quot;; }&lt;br /&gt;
&lt;br /&gt;
       breakfastsunday = parseInt(answer) * breakfastprice ;&lt;br /&gt;
&lt;br /&gt;
       document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; breakfeasts = &amp;quot; + breakfastsunday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot;  );&lt;br /&gt;
&lt;br /&gt;
       if (&amp;quot;{INSERTANS:45251X1X112}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
       else { answer = &amp;quot;{INSERTANS:45251X1X112}&amp;quot;; }&lt;br /&gt;
&lt;br /&gt;
       lunchsunday = parseInt(answer) * lunchprice ;&lt;br /&gt;
&lt;br /&gt;
       document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; lunches = &amp;quot; + lunchsunday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
       if (&amp;quot;{INSERTANS:45251X1X113}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
       else { answer = &amp;quot;{INSERTANS:45251X1X113}&amp;quot;; }&lt;br /&gt;
&lt;br /&gt;
       dinnersunday = parseInt(answer) * dinnerprice ;&lt;br /&gt;
&lt;br /&gt;
       document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; dinners = &amp;quot; + dinnersunday + &amp;quot;&amp;amp;euro;&amp;lt;p&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
       foodtotal = foodtotal + breakfastsunday + lunchsunday + dinnersunday;&lt;br /&gt;
&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
   total = partytotal + beadclothtotal + foodtotal;&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;&amp;lt;h3&amp;gt;In total it will cost you &amp;quot; + total + &amp;quot;&amp;amp;euro;&amp;lt;/h3&amp;gt;&amp;lt;BR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   Put that sum in this bank account 1234 5678 9012&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/SCRIPT&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Multiple Question Validation=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, this is easier to do using the min/max/equals_num_value attributes (to validate sums), or the em_validation_q function, which lets you refer to other variables when you validate the current question [[Expression Manager|Expression Manager]].  Such validations also work on the current page, and properly handle array_filter and cascading relevance.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround is in case you need to do some validation involving more than one question, it implies a very little JavaScript programming and the use of SQGA Identifiers; this should work on almost any version of LimeSurvey.&lt;br /&gt;
&lt;br /&gt;
Is easy to explain with an example, we need to do a survey of the percentage of males and females and we want to be sure that the sum is 100, to do this follow this steps (the necessary data that is not indicated in these instructions are not important i.e. question codes, etc.):&lt;br /&gt;
#Create a new survey of type &amp;amp;ldquo;group by group&amp;amp;rdquo;, set the &amp;amp;ldquo;Show |&amp;lt;&amp;lt; Prev| button&amp;amp;rdquo; to yes and note the SID.&lt;br /&gt;
#Add a new group called &amp;amp;ldquo;Group 1&amp;amp;rdquo; and note the GID.&lt;br /&gt;
#Add a new question &amp;amp;ldquo;Percent of males&amp;amp;rdquo; of type &amp;amp;ldquo;numeric&amp;amp;rdquo;, make it mandatory and note the QID (we will refer to this as QID1).&lt;br /&gt;
#Add a new question &amp;amp;ldquo;Percent of females&amp;amp;rdquo; of type &amp;amp;ldquo;numeric&amp;amp;rdquo;, make it mandatory and note the QID (we will refer to this as QID2).&lt;br /&gt;
#Add a new group called &amp;amp;ldquo;Group 2&amp;amp;rdquo;&lt;br /&gt;
#Add a new non mandatory question, here is the trick the question text has to be (be sure to replace the SID, GID, QID1 and QID2&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
function validation()&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   if [[{INSERTANS:SIDXGIDXQID1}+{INSERTANS:SIDXGIDXQID2}) != 100)&lt;br /&gt;
&lt;br /&gt;
   {&lt;br /&gt;
&lt;br /&gt;
     alert(&amp;quot;Your responses don&#039;t sum 100! Check them&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
     document.limesurvey.move.value = &#039;moveprev&#039;;&lt;br /&gt;
&lt;br /&gt;
     document.limesurvey.submit();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   else&lt;br /&gt;
&lt;br /&gt;
   {&lt;br /&gt;
&lt;br /&gt;
     document.limesurvey.move.value = &#039;movelast&#039;;&lt;br /&gt;
&lt;br /&gt;
     document.limesurvey.submit();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 setTimeout(&amp;quot;validation()&amp;quot;,250);&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 But this will show shortly the question and will jump to the end page, a little weird for the survey taker but works.&lt;br /&gt;
&lt;br /&gt;
 This is a proof of concept, and may have some problems, please if you notice something or improve it send me an e-mail to leochaton-limesurvey at yahoo dot com.&lt;br /&gt;
&lt;br /&gt;
 This will work for 2 questions that you want to be the same.  Works well for email and confirm email questions&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  function validation() {&lt;br /&gt;
&lt;br /&gt;
  if (&amp;quot;{INSERTANS:SIDXGIDXQID}&amp;quot; != &amp;quot;{INSERTANS:SIDXGIDXQID}&amp;quot;) {&lt;br /&gt;
&lt;br /&gt;
     alert(&amp;quot;Your responses don&#039;t match Check them&amp;quot;); document.limesurvey.move.value = &#039;moveprev&#039;;&lt;br /&gt;
&lt;br /&gt;
     document.limesurvey.submit();&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  setTimeout(&amp;quot;validation()&amp;quot;,250);&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 =Alternate exit=&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with: &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 Using the same idea of the previous post, you can implement an alternate exit of your survey.&lt;br /&gt;
&lt;br /&gt;
 This script should be in the first question to be displayed in a next page after the question that should trigger the alternate exit. In this example the question that trigger the alternate exit is a Yes/No question, if the user chooses no, he is redirected to another page.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 if (&amp;quot;{INSERTANS:SIDXGIDXQID}&amp;quot; == &amp;quot;No&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
&lt;br /&gt;
   window.location=&amp;quot;http://www.limesurvey.org&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 =Custom onload function=&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with: &#039;All browsers&#039;, LimeSurvey 1.70 and up&lt;br /&gt;
&lt;br /&gt;
 ==General==&lt;br /&gt;
&lt;br /&gt;
 This simple workaround describes how to &#039;&#039;&#039;add a custom Javascript code&#039;&#039;&#039; that is triggered right after the page is loaded. It may have numerous applications, especially when you deal with a custom JS/HTML code. It may be used to hide form elements (&amp;lt;input&amp;gt;  tags), make them read-only, display alert messages, etc.&lt;br /&gt;
&lt;br /&gt;
 To run any Javascript code right after page load use the Query ready() function. It will be executed when the page is being loaded. For example when you add the following code to one of your question definitions...:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 jQuery(document).ready(&lt;br /&gt;
&lt;br /&gt;
    function(){&lt;br /&gt;
&lt;br /&gt;
        alert(&#039;onload alert!&#039;);&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
 );&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ...it will display a pop-up message immediately after the page has been loaded.&lt;br /&gt;
&lt;br /&gt;
 Some of the applications of this trick I&#039;ve explored are:&lt;br /&gt;
&lt;br /&gt;
 a) Hiding the form elements by calling in your Custom_On_Load:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;document.getElementById(&amp;quot;answer73166X16X54&amp;quot;).style.display=&#039;none&#039;;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 Note: As of svn build 9755, you can now dynamically reference the questions input fields by using the {SGQ} keyword. You can rewrite the previous example like this:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;document.getElementById(&amp;quot;answer{SGQ}&amp;quot;).style.display=&#039;none&#039;;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 this makes it a little easier when exporting surveys, so you don&#039;t have to worry about manually entering each questions SurveyGroupQuestion ID.&lt;br /&gt;
&lt;br /&gt;
 b) Making the elements read only:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;document.getElementById(&amp;quot;answer73166X16X54&amp;quot;).readOnly=true;&amp;lt;/syntaxhighlight&amp;gt; where the &amp;quot;answer73166X16X54&amp;quot; structure has been described in one of other workarounds above.&lt;br /&gt;
&lt;br /&gt;
 c) For Hiding by a lot of elements by calling in your Customer_On_Load&lt;br /&gt;
&lt;br /&gt;
 jQuery searchs in html document for input-fields with radio type, if his answer text empty then do the display css set to none.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 jQuery(document).ready(&lt;br /&gt;
&lt;br /&gt;
            function() {&lt;br /&gt;
&lt;br /&gt;
              jQuery(&#039;input:radio&#039;).each(&lt;br /&gt;
&lt;br /&gt;
                function() {&lt;br /&gt;
&lt;br /&gt;
                  var s = jQuery(this);&lt;br /&gt;
&lt;br /&gt;
                  var c = s.parent().children(&#039;.answertext&#039;);&lt;br /&gt;
&lt;br /&gt;
                  for(var i=0; i &amp;lt; c.length; i++) {&lt;br /&gt;
&lt;br /&gt;
                    var a = jQuery(c[i]]);&lt;br /&gt;
&lt;br /&gt;
                    if(this.id &amp;lt;/u&amp;gt; a.attr(&#039;for&#039;) &amp;amp;&amp;amp; a.text() == &#039;&#039;) {&lt;br /&gt;
&lt;br /&gt;
                      s.css({ &#039;display&#039; : &#039;none&#039; });&lt;br /&gt;
&lt;br /&gt;
                      a.css({ &#039;display&#039; : &#039;none&#039; });&lt;br /&gt;
&lt;br /&gt;
                      break;&lt;br /&gt;
&lt;br /&gt;
                    }&lt;br /&gt;
&lt;br /&gt;
                  }&lt;br /&gt;
&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
              )&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
          );&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ==Advanced usage==&lt;br /&gt;
&lt;br /&gt;
 If you want to place global Javascript code using the above jQuery(document).ready function then the best place to do this is the template javascript file template.js. You can edit this file using the template editor. Please be aware that placing it in the template javascript file will make the function available to all surveys using that template. If needed just create a new template copy for your survey.&lt;br /&gt;
&lt;br /&gt;
 Alternatively you can place the jQuery(document).ready function in the group description to make a Javascript function only available to a certain question group.&lt;br /&gt;
&lt;br /&gt;
 ==Language-specific Javascript code==&lt;br /&gt;
&lt;br /&gt;
 There is an easy way to find out the current language and execute according Javascript using jQuery: The &amp;lt;html&amp;gt; tag of any survey pages contains an &#039;lang&#039; attribute which holds the current language code. You can read that language code by using the followin code&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 jQuery(document).ready(&lt;br /&gt;
&lt;br /&gt;
    function(){&lt;br /&gt;
&lt;br /&gt;
        languagecode=$(&#039;html&#039;).attr(&#039;lang&#039;);&lt;br /&gt;
&lt;br /&gt;
        alert(&#039;This is the current language code: &#039;+languagecode);&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
 );&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 For an English survey the above code would show a messagebox with &amp;quot;This is the current language code: en&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 =Custom onload function in multi-language survey=&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with: 1.85+ (7253), IE 6/7, FireFox 3.0, Safari 3.2,&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 To use custom onload functions, as above, in multi-language surveys you must define the functions in the question source for &#039;&#039;&#039;all&#039;&#039;&#039; languages.&lt;br /&gt;
&lt;br /&gt;
 While this initially seems to be a bit tedious, it actually can be useful - you can alter your onload functions depending on the language in use. For example, you can dynamically display alerts or element contents in the current language.&lt;br /&gt;
&lt;br /&gt;
 =Skipping the welcome page=&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with: 1.85 (second code snippet)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;Note: As of version 1.91, there is a survey option letting you skip the welcome page, so this workaround is not needed.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Solution 1:&#039;&#039;&#039; Include this Javascript in your welcome template, in the file welcome.pstpl for all welcome page, or in the source of the welcome text for one survey:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 jQuery(document).ready(function($) {&lt;br /&gt;
&lt;br /&gt;
 document.limesurvey.move.value = &#039;movenext&#039;;&lt;br /&gt;
&lt;br /&gt;
 document.limesurvey.submit(); });&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 It will reproduce the onclick event of the submit button and submit the form.&lt;br /&gt;
&lt;br /&gt;
 Drawback of course is that users will see the page flashing up.&lt;br /&gt;
&lt;br /&gt;
 Therefore, you may want to announce &amp;quot;... loading survey ...&amp;quot; as a description of your welcome page (in the admin interface when creating the survey), to pretend loading something big.&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Solution 2:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 function custom_on_load(){&lt;br /&gt;
&lt;br /&gt;
   document.limesurvey.move.value = &#039;movenext&#039;;&lt;br /&gt;
&lt;br /&gt;
   document.limesurvey.submit();&lt;br /&gt;
&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 window.setTimeout( &#039;custom_on_load()&#039;,1);&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 =Filter answers of a question with the answer of another=&lt;br /&gt;
&lt;br /&gt;
 ===Method 1===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with: 1.70 - 1.72&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, this is easier to do using the the array_filter attribute, or relevance equations in general.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 If you want to filter the answer of a question with another answer, you can use this workaround.&lt;br /&gt;
&lt;br /&gt;
 First, use answer code like that: XX for the first question, and XXYYY for the second one.&lt;br /&gt;
&lt;br /&gt;
 Answer of the second question filter if the 2 first letters are the answer of the first question.&lt;br /&gt;
&lt;br /&gt;
 We use 1000X1X1 and 1000X1X2 for the example, question had to be on separate page (question by question for example).The second question had to be a dropdown list (we can do similar workaround, but droplis is the best). You can do this using JQuery.  It leaves the answer in the select box, but disables it.  You could also replace &amp;quot;disable&amp;quot; with &amp;quot;remove&amp;quot; to get rid of it altogether.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 var previousQuestionAnswer = &amp;quot;{INSERTANS:1000X1X1}&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
 var currentQuestionID = &amp;quot;#answer1000X1X1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
    // See if the answer for the previous question matches an answer in the current question&lt;br /&gt;
&lt;br /&gt;
    // (other than &#039;No Answer&#039;)&lt;br /&gt;
&lt;br /&gt;
    // If so, disable it.&lt;br /&gt;
&lt;br /&gt;
    if (previousQuestionAnswer!=&#039;No Answer&#039;) {&lt;br /&gt;
&lt;br /&gt;
        $(currentQuestionID).children().each(function(index, Element)&lt;br /&gt;
&lt;br /&gt;
        {&lt;br /&gt;
&lt;br /&gt;
            if ($(this).attr(&#039;text&#039;) == previousQuestionAnswer)&lt;br /&gt;
&lt;br /&gt;
                { $(this).attr(&#039;disabled&#039;, true); }&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
        );}&lt;br /&gt;
&lt;br /&gt;
 }); // End of JQuery ready function&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ===Method 2===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with 1.92 + Firefox 9.0&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 If you have a country, state, and city set of questions (or similar), you could code answer options as:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Q1 Country&#039;&#039;&#039; &#039;&#039;Single choice list (ratio, dropdown)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 X country#&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Q2 State&#039;&#039;&#039; &#039;&#039;Single choice list (dropdown)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 XY state#&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Q3 City&#039;&#039;&#039; &#039;&#039;Single choice list (dropdown)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 XYZZ city#&lt;br /&gt;
&lt;br /&gt;
 Now you must put the following Javascript code in the source of question 2 (State):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
        // Get the countryCode (first character of the country)&lt;br /&gt;
&lt;br /&gt;
        var countryCode = &#039;{INSERTANS:1000X1X1}&#039;.substr(0, 1).toUpperCase();&lt;br /&gt;
&lt;br /&gt;
        // Loop through all dropdown options and remove those with codes not starting with the countryCode&lt;br /&gt;
&lt;br /&gt;
        $(&#039;select[id&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&amp;quot;answer&amp;quot;] option&#039;).each(function(i){&lt;br /&gt;
&lt;br /&gt;
            if($(this).attr(&#039;value&#039;)  &amp;amp;&amp;amp; $(this).attr(&#039;value&#039;).substr(0, 1).toUpperCase() != countryCode) {&lt;br /&gt;
&lt;br /&gt;
                $(this).remove();&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
        });&lt;br /&gt;
&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 And the following code in the source of question 3 (City):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
        // Get the stateCode (two first characters of the state)&lt;br /&gt;
&lt;br /&gt;
        var stateCode = &#039;{INSERTANS:1000X1X2}&#039;.substr(0, 2).toUpperCase();&lt;br /&gt;
&lt;br /&gt;
        // Loop through all dropdown options and remove those with codes not starting with the stateCode&lt;br /&gt;
&lt;br /&gt;
        $(&#039;select[id&amp;lt;/div&amp;gt;=&amp;quot;answer&amp;quot;] option&#039;).each(function(i){&lt;br /&gt;
&lt;br /&gt;
            if($(this).attr(&#039;value&#039;)  &amp;amp;&amp;amp; $(this).attr(&#039;value&#039;).substr(0, 2).toUpperCase() != stateCode) {&lt;br /&gt;
&lt;br /&gt;
                $(this).remove();&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
        });&lt;br /&gt;
&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 Each question must be in different pages of survey to work, i.e. in a question by question survey, or in diferent groups in a group by group survey.&lt;br /&gt;
&lt;br /&gt;
 Note that if you choose a two characters answer option code in the State question, i.e. a XYY answer option code, you must change the &#039;&#039;substr(0, 2)&#039;&#039; part of code in question 3 to &#039;&#039;substr(0, 3)&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 =Filter answers of a multiple numeric type question=&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with: 1.90+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, this is easier to do using the the array_filter attribute, or relevance equations in general.  In 1.92, array_filter works with all questions that have sub-questions (e.g. also works for multiple numeric and multiple short text).&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 If you want to filter a question of type &amp;quot;multiple numeric&amp;quot;, you have to modify the workaround.&lt;br /&gt;
&lt;br /&gt;
 Note that this workaround assumes that the code for each of the subquestions are a numeric sequence 1,2,3...&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $(document).ready(function(){&lt;br /&gt;
&lt;br /&gt;
    // Match elements with labels using htmlFor and a loop&lt;br /&gt;
&lt;br /&gt;
    var labels = document.getElementsByTagName(&#039;LABEL&#039;);&lt;br /&gt;
&lt;br /&gt;
    for (var i = 0; i &amp;lt; labels.length; i++) {&lt;br /&gt;
&lt;br /&gt;
        if (labels[i].htmlFor != &#039;&#039;) {&lt;br /&gt;
&lt;br /&gt;
             var elem = document.getElementById(labels[i].htmlFor);&lt;br /&gt;
&lt;br /&gt;
             if (elem)&lt;br /&gt;
&lt;br /&gt;
                elem.label = labels[i];&lt;br /&gt;
&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    var answerFilter=&amp;quot;{INSERTANS:96553X63X759}&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
    for (i=0; i&amp;lt;30; i++){&lt;br /&gt;
&lt;br /&gt;
      var iLabel = document.getElementById(&#039;answer96553X63X760&#039;+(i+1]].label.innerHTML;&lt;br /&gt;
&lt;br /&gt;
     if (answerFilter.search(iLabel) == -1){&lt;br /&gt;
&lt;br /&gt;
       // Hide element&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question760&#039;).find(&#039;li&#039;).eq(i).hide();&lt;br /&gt;
&lt;br /&gt;
       // Set value of hidden elements to zero&lt;br /&gt;
&lt;br /&gt;
       document.getElementById(&#039;answer96553X63X760&#039;+(i+1)).value = 0;&lt;br /&gt;
&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
 });&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Use an answer to prefill another question (default value)=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.72&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;And tested with: 1.91+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, this is easier to do using the enhanced defaults feature, which lets you pre-fill most question types with default values.  In 1.91, you could set defaults for list and multiple choice questions.  In 1.92, you can set defaults for any text-entry question too.  Moreover, the defaults can be [[Expression Manager|Expression Manager]] compatible equations or tailored text.  Finally, with 1.92, defaults are properly managed even when set on the same page.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround gives you the ablility to use an answer to fill the default value for another question. It&#039;s explained for free text question type but can be adapted for another question type.&lt;br /&gt;
&lt;br /&gt;
We use SGQA identifier. For example, we use SGQA 1000X10X20 and 1000X10X21 to prefill 1000X11X30 and 1000X11X31. For the script to work, the question has to be on a different page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
 $(&#039;#answer1000X11X30&#039;).val(&#039;{INSERTANS:1000X10X20}&#039;);&lt;br /&gt;
&lt;br /&gt;
 $(&#039;#answer1000X11X31&#039;).val(&#039;{INSERTANS:1000X10X21}&#039;);&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want use two times the value of an integer input, you can also use this to prefill a question that you hide via CSS.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
 $(&#039;#answer1000X2X2&#039;).val(parseInt(&#039;{INSERTANS:1000X1X1}&#039;)*2);&lt;br /&gt;
&lt;br /&gt;
 $(&amp;quot;#question2&amp;quot;).hide();&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you can use {INSERTANS:1000X2X2} for giving you twice the value of the user input from question 1.&lt;br /&gt;
&lt;br /&gt;
=Dynamic Sum=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, this is easier to do with [[Expression Manager|Expression Manager]] using the sum() function.  Not only will sums be dynamic, but they wille exclude irrelevant values, so you can array_filter a multiple numeric question and get the sum of just the answers that are visible.  This [[Expression Manager HowTos|#Calculate assessment values at runtime and store the results in the survey data|HowTo example]] demonstrates the dynamic sum feature.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;Also note, as of version 1.92, the following workaround will fail, since it includes a a regular expression containing curly braces.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This script is used with a &amp;quot;Multiple Options&amp;quot; type question calculate a total price based on how which checkboxes are selected. The prices are listed as part of the answer. The answers are set up like this: &amp;quot;USB Mouse ($20)&amp;quot;. The script uses the number between the &amp;quot;($&amp;quot; and the &amp;quot;)&amp;quot; as the price for that item. You can adapt the script to if you need to change the currency or need to sum something other than money.&lt;br /&gt;
&lt;br /&gt;
This script works when used in a question-by-question format.  It does not work when there are more than one question on a page. I think it can be adapted to work, but I haven&#039;t done the coding yet.&lt;br /&gt;
&lt;br /&gt;
Put the following code into body of your question:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script language=Javascript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// General definitions&lt;br /&gt;
&lt;br /&gt;
// Define a regular expression to match the labels containing information about an answer&lt;br /&gt;
&lt;br /&gt;
// In LimeSurvey, these labels start with &amp;quot;answer...&amp;quot;&lt;br /&gt;
&lt;br /&gt;
var answerRegex = /^answer/;&lt;br /&gt;
&lt;br /&gt;
// Find all answer checkboxes in the document and set their&lt;br /&gt;
&lt;br /&gt;
// onchange events to updatePrice&lt;br /&gt;
&lt;br /&gt;
function Custom_On_Load()&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   // Find all input elements&lt;br /&gt;
&lt;br /&gt;
   var inputList=document.getElementsByTagName(&amp;quot;input&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
   // Loop through each, looking for checkboxes&lt;br /&gt;
&lt;br /&gt;
   var i;&lt;br /&gt;
&lt;br /&gt;
   for( i=0; i&amp;lt; inputList.length;i++ )&lt;br /&gt;
&lt;br /&gt;
   {&lt;br /&gt;
&lt;br /&gt;
       // If input item does not have an ID, skip&lt;br /&gt;
&lt;br /&gt;
       if (! (inputList[i].id)) { continue; }&lt;br /&gt;
&lt;br /&gt;
       // Skip to next if ID doesn&#039;t start with &amp;quot;answer&amp;quot;&lt;br /&gt;
&lt;br /&gt;
       if (!answerRegex.test(inputList[i].id)) { continue; }&lt;br /&gt;
&lt;br /&gt;
       // Skip to next if not a checkbox&lt;br /&gt;
&lt;br /&gt;
       if (inputList[i].type.toUpperCase()!=&#039;CHECKBOX&#039;)  { continue; }&lt;br /&gt;
&lt;br /&gt;
       // This is an answer checkbox!&lt;br /&gt;
&lt;br /&gt;
       // Setup onchange event&lt;br /&gt;
&lt;br /&gt;
       inputList[i].onclick = updatePrice;&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
       // Load initial sum&lt;br /&gt;
&lt;br /&gt;
   updatePrice();&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function updatePrice()&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
var labels=document.getElementsByTagName(&amp;quot;LABEL&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
// Define a regular expression to match a price inside parenthesis&lt;br /&gt;
&lt;br /&gt;
// For example: ($29) or ($29.54).&lt;br /&gt;
&lt;br /&gt;
// Set up&lt;br /&gt;
&lt;br /&gt;
priceRegex = /\(\$(\d*\.{0,1}\d+)\)/;&lt;br /&gt;
&lt;br /&gt;
// Loop through all the labels, looking for labels corresponding to&lt;br /&gt;
&lt;br /&gt;
// answers that have a price in them.&lt;br /&gt;
&lt;br /&gt;
var i;&lt;br /&gt;
&lt;br /&gt;
var total = 0;&lt;br /&gt;
&lt;br /&gt;
for( i=0; i&amp;lt;labels.length;i++ )&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   var myArray;    // Define array used for regex matching&lt;br /&gt;
&lt;br /&gt;
   var inputID;    // Define field element&lt;br /&gt;
&lt;br /&gt;
   // Get the ID of the field corresponding to the label using the&lt;br /&gt;
&lt;br /&gt;
   // &amp;quot;htmlFor&amp;quot; attribute&lt;br /&gt;
&lt;br /&gt;
   // (FYI, there are some labels that will have to be screened out&lt;br /&gt;
&lt;br /&gt;
   // because they don&#039;t correspond to an answer)&lt;br /&gt;
&lt;br /&gt;
   // Does the label start with &amp;quot;answer&amp;quot;?&lt;br /&gt;
&lt;br /&gt;
   // If not: exit.&lt;br /&gt;
&lt;br /&gt;
   if (!answerRegex.test(labels[i].htmlFor)) { continue; }&lt;br /&gt;
&lt;br /&gt;
   // First make sure this element exists&lt;br /&gt;
&lt;br /&gt;
   // If it doesn&#039;t, go to the next element&lt;br /&gt;
&lt;br /&gt;
   // If it does, it will be defined in inputID&lt;br /&gt;
&lt;br /&gt;
   if (! (inputID = document.getElementById(labels[i].htmlFor)) ) { continue; }&lt;br /&gt;
&lt;br /&gt;
   // See if the corresponding answer is a checkbox that is checked.&lt;br /&gt;
&lt;br /&gt;
   // If not, go to next label&lt;br /&gt;
&lt;br /&gt;
   if (inputID.type.toUpperCase()!=&#039;CHECKBOX&#039;)  { continue; }&lt;br /&gt;
&lt;br /&gt;
   if (!inputID.checked) { continue; }&lt;br /&gt;
&lt;br /&gt;
   // This is label for an answer.&lt;br /&gt;
&lt;br /&gt;
   // The innerHTML will give us the text of the label&lt;br /&gt;
&lt;br /&gt;
   // The price information will be in the form ($XX.XX)&lt;br /&gt;
&lt;br /&gt;
   // which in contained in the label text.&lt;br /&gt;
&lt;br /&gt;
   // Find a match for a decimal number inside the pattern &amp;quot;($&amp;quot; and &amp;quot;)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   if [[myArray = priceRegex.exec(labels[i].innerHTML]] != null)&lt;br /&gt;
&lt;br /&gt;
   {&lt;br /&gt;
&lt;br /&gt;
       // Keep a running tally&lt;br /&gt;
&lt;br /&gt;
       total += parseFloat(myArray[1]);&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
  // Update total price on form&lt;br /&gt;
&lt;br /&gt;
  document.getElementById(&amp;quot;totalPrice&amp;quot;).value = &amp;quot;$&amp;quot; + formatCurrency(total);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function formatCurrency(num) {&lt;br /&gt;
&lt;br /&gt;
  num = isNaN(num) || num &amp;lt;u&amp;gt; &#039;&#039; || num &amp;lt;/u&amp;gt; null ? 0.00 : num;&lt;br /&gt;
&lt;br /&gt;
  return parseFloat(num).toFixed(2);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Put the following code in the help section (or wherever you want the sum to appear):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;Total Cost for selected accessories: &amp;lt;input type=&amp;quot;readonly&amp;quot; value=&amp;quot;&amp;quot; id=&amp;quot;totalPrice&amp;quot; /&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Focus on the first Input field=&lt;br /&gt;
&lt;br /&gt;
(&#039;&#039;Tested with: Limesurvey 1.80 / IE6/7, Firefox 3, Safari, Opera, chrome&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.91, there is a built-in JavaScript function called  focusFirst() to focus on the first visible element.  It uses jQuery, so is more robust than this example.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again an onload Function is needed for this tasks. I have done it the DOM way with compatibility to IE6/7.&lt;br /&gt;
&lt;br /&gt;
Put the following code into the startpage.pstpl of your template, right before the &amp;lt;/head&amp;gt; closing tag:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   function focusFirst(Event)&lt;br /&gt;
&lt;br /&gt;
   {&lt;br /&gt;
&lt;br /&gt;
       var i=0;&lt;br /&gt;
&lt;br /&gt;
       while(document.forms[0].elements[i].type == &amp;quot;hidden&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
       {&lt;br /&gt;
&lt;br /&gt;
           i++;&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       document.forms[0].elements[i].focus();&lt;br /&gt;
&lt;br /&gt;
       return;&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   if(ie)&lt;br /&gt;
&lt;br /&gt;
   { window.attachEvent(&amp;quot;onload&amp;quot;, focusFirst); }&lt;br /&gt;
&lt;br /&gt;
   else&lt;br /&gt;
&lt;br /&gt;
   { document.addEventListener(&amp;quot;load&amp;quot;, focusFirst, true); }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; I am using this with version 1.80. As changes happened to the templates in the last release, you might need to add the following before the code, if your template is older than 1.80 stable and does not include this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   var ie = false;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will need this for the var ie to be set. Without this var, the function will not work with ie.&lt;br /&gt;
&lt;br /&gt;
=Answer questions by keypress=&lt;br /&gt;
&lt;br /&gt;
(&#039;&#039;Tested with: IE7, Firefox 3&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
This workaround allow to answer the question on key 0-9 (0 is for the 10 answer).&lt;br /&gt;
&lt;br /&gt;
Follow issues are supported at the moment:&lt;br /&gt;
*Yes-No Questions&lt;br /&gt;
*List Questions (radio)&lt;br /&gt;
*other radio questions&lt;br /&gt;
&lt;br /&gt;
In lists the answer limit is ten.&lt;br /&gt;
&lt;br /&gt;
You supply the template &amp;quot;endpage&amp;quot; of your template with the following script.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
jQuery(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
   jQuery(document).bind(&#039;keypress&#039;, function(e){&lt;br /&gt;
&lt;br /&gt;
       if (48 &amp;lt;= e.which &amp;amp;&amp;amp; e.which &amp;lt;= 57) {&lt;br /&gt;
&lt;br /&gt;
           jQuery(&#039;input:radio&#039;).each(function() {&lt;br /&gt;
&lt;br /&gt;
               var v = jQuery(this).val();&lt;br /&gt;
&lt;br /&gt;
               var c = (e.which &amp;lt;u&amp;gt; 48) ? 10 : e.which - 48;&lt;br /&gt;
&lt;br /&gt;
               if(v &amp;lt;/u&amp;gt; &#039;Y&#039; || v &amp;lt;u&amp;gt; &#039;N&#039;) {&lt;br /&gt;
&lt;br /&gt;
                   v = (v &amp;lt;/u&amp;gt; &#039;Y&#039;) ? 1 : 2;&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               if(v == c) {&lt;br /&gt;
&lt;br /&gt;
                   jQuery(this).click();&lt;br /&gt;
&lt;br /&gt;
                   jQuery(&#039;#limesurvey input:submit&#039;).click();&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   })&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Math notation in LimeSurvey=&lt;br /&gt;
#download the js file from [http://mathcs.chapman.edu/~jipsen/mathml/asciimathdownload.html AsciiMath script]&lt;br /&gt;
#copy it in the /scripts/ folder in your installation&lt;br /&gt;
#modify the startpage.psptl of the template you want to use adding the reference to the script (if you use an older version make sure that you copy the template folder first!) for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;ASCIIMathML.js&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the notation where you need it!&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; If you use internet explorer or safari you will need to download the plugin as well, but firefox does the lot for you.&lt;br /&gt;
&lt;br /&gt;
Finally, if you are confident with the limesurvey structure you could add the editor which support math notation and change the reference to the editor you want to use in the configuration file. here is the [http://www.imathas.com/editordemo/demo.html link for a TinyMCE with math support].&lt;br /&gt;
&lt;br /&gt;
=Reverse array_filter (for pre-1.90)=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.85+ (7253), IE 6/7, FireFox 3.0, Safari 3.2, Chrome 2.0&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;Note: Version 1.91 natively supports this functionality via the array_filter_exclude advanced quation option.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This can be used to filter the answers of an array question to be displayed based on the answers of a multi option question that were &#039;&#039;&#039;NOT&#039;&#039;&#039; selected. A possible application would be to have a multi-option question asking which products were purchased, followed by 2 array questions - one asking to rate the purchased products and another asking why the remaining products were not purchased. Another would be to ask about sessions attended at a conference as in [http://www.limesurvey.org/en/support/forums/5-can-i-do-this-with-limesurvey/27970-reverse-of-arrayfilter.html this forum thread] and pictured below. There is a live [http://www.partnersinc.biz/surveys//index.php?sid=43358&amp;amp;newtest;=Y&amp;amp;lang;=en demo here]&lt;br /&gt;
&lt;br /&gt;
[[File:sessions_645x344.gif]]&lt;br /&gt;
&lt;br /&gt;
We&#039;ll use the above example to explain the process as follows:&lt;br /&gt;
#In group 1 - Create a &#039;&#039;SessionsAttended&#039;&#039; multi-options question&lt;br /&gt;
#In group 1 - Create a &#039;&#039;SessionsNotAttended&#039;&#039; multi-options question with identical answers as &#039;&#039;SessionsAttended&#039;&#039; and hide it with styles or conditions&lt;br /&gt;
#In group 2 - Create a &#039;&#039;RateSessionsAttended&#039;&#039; array question with an [http://docs.limesurvey.org/tiki-index.php?page=Question+attributes&amp;amp;structure;=English+Instructions+for+LimeSurvey#array_filter array_filter] based on &#039;&#039;SessionsAttended&#039;&#039;&lt;br /&gt;
#In group 2 - Create a &#039;&#039;ReasonNotAttended&#039;&#039; array question with an [http://docs.limesurvey.org/tiki-index.php?page=Question+attributes&amp;amp;structure;=English+Instructions+for+LimeSurvey#array_filter array_filter] based on &#039;&#039;SessionsNotAttended&#039;&#039;&lt;br /&gt;
#In group 1 - Place JavaScript/jQeury listeners on each of the checkboxes in &#039;&#039;SessionsAttended&#039;&#039; that would toggle the corresponding checkbox in &#039;&#039;SessionsNotAttended&#039;&#039; to the opposite state&lt;br /&gt;
&lt;br /&gt;
The JavaScript/jQuery code used would be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
       // The toggle function&lt;br /&gt;
&lt;br /&gt;
   function toggle(q1, q2) {&lt;br /&gt;
&lt;br /&gt;
       if ($(q1).attr(&#039;checked&#039;) == false ) {&lt;br /&gt;
&lt;br /&gt;
           $(q2).attr(&#039;checked&#039;, true);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       else {&lt;br /&gt;
&lt;br /&gt;
           $(q2).attr(&#039;checked&#039;, false);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   // Initialize the SessionNotAttended checkboxes to &amp;quot;checked&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   toggle (&#039;#answer11111X22X331&#039;, &#039;#answer11111X22X441&#039;);&lt;br /&gt;
&lt;br /&gt;
   toggle (&#039;#answer11111X22X332&#039;, &#039;#answer11111X22X442&#039;);&lt;br /&gt;
&lt;br /&gt;
   toggle (&#039;#answer11111X22X333&#039;, &#039;#answer11111X22X443&#039;);&lt;br /&gt;
&lt;br /&gt;
   toggle (&#039;#answer11111X22X334&#039;, &#039;#answer11111X22X444&#039;);&lt;br /&gt;
&lt;br /&gt;
   // The jQuery listeners on the SessionAttended checkboxes&lt;br /&gt;
&lt;br /&gt;
   // that toggle the SessionNotAttended checkboxes&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#answer11111X22X331&#039;).change(function() {&lt;br /&gt;
&lt;br /&gt;
       toggle (&#039;#answer11111X22X331&#039;, &#039;#answer11111X22X441&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#answer11111X22X332&#039;).change(function() {&lt;br /&gt;
&lt;br /&gt;
       toggle (&#039;#answer11111X22X332&#039;, &#039;#answer11111X22X442&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#answer11111X22X333&#039;).change(function() {&lt;br /&gt;
&lt;br /&gt;
       toggle (&#039;#answer11111X22X333&#039;, &#039;#answer11111X22X443&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#answer11111X22X334&#039;).change(function() {&lt;br /&gt;
&lt;br /&gt;
       toggle (&#039;#answer11111X22X334&#039;, &#039;#answer11111X22X444&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some notes about the code:&lt;br /&gt;
*The code is in an onload function defined in the first question of group 1 - see [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#Custom_onload_function workarounds here]&lt;br /&gt;
*Both &#039;&#039;SessionsAttended&#039;&#039; and &#039;&#039;SessionsNotAttended&#039;&#039; must be in the same group for the toggling to work&lt;br /&gt;
*This case only uses 4 checkboxes but could be expanded as required&lt;br /&gt;
*In this case the survey ID is 11111, the group ID is 22, &#039;&#039;SessionsAttended&#039;&#039; ID is 33 and SessionsNotAttended ID is 44 - these would need to be modified for your survey&lt;br /&gt;
*The toggle function looks for the state of a checkbox in &#039;&#039;SessionsAttended&#039;&#039; and sets the corresponding checkbox in &#039;&#039;SessionsNotAttended&#039;&#039; to the opposite state&lt;br /&gt;
*The &amp;quot;Initialize&amp;quot; section sets the state of &#039;&#039;SessionsNotAttended&#039;&#039; checkboxes whenever we navigate to the group&lt;br /&gt;
*The &amp;quot;Listener&amp;quot; section uses jQuery listeners to detect any change in the &#039;&#039;SessionsAttended&#039;&#039; checkboxes and then toggle the corresponding &#039;&#039;SessionsNotAttended&#039;&#039; checkbox&lt;br /&gt;
&lt;br /&gt;
Some general notes about the questions:&lt;br /&gt;
*CSS can be used to hide &#039;&#039;SessionsNotAttended&#039;&#039; (div#question44 { display: none; }) if you don&#039;t want to use conditions (because maybe you&#039;ve got [http://docs.limesurvey.org/tiki-index.php?page=Optional+settings&amp;amp;structure;=English+Instructions+for+LimeSurvey#Survey_Behavior $deletenonvalues set to 1])&lt;br /&gt;
*&#039;&#039;RateSessionsAttended&#039;&#039; and &#039;&#039;ReasonNotAttended&#039;&#039; are another group to avoid things popping in and out of existence as &#039;&#039;SessionsAttended&#039;&#039; is answered&lt;br /&gt;
*[http://docs.limesurvey.org/tiki-index.php?page=Setting+conditions&amp;amp;structure;=English+Instructions+for+LimeSurvey Conditions] are used to ensure that &#039;&#039;RateSessionsAttended&#039;&#039; only appears if some sessions are selected and &#039;&#039;ReasonNotAttended&#039;&#039; only appears if no sessions are selected&lt;br /&gt;
&lt;br /&gt;
=Filter Ranking Question With Multiple-Options=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90, IE 7/8, FireFox 3/4, Safari 5.0, Chrome 10.0&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, most of this is easier to do using the the array_filter attribute, or relevance equations in general.  They all work on the same page, and fully support cascading relevance.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround applies a filter to a ranking question based on the checked boxes of a previous multiple-options question. There are two methods - one for filter and ranking questions being on the same page and a slightly different one for the filter question being on a page before the ranking question.&lt;br /&gt;
&lt;br /&gt;
There is a [http://www.partnersinc.biz/surveys//index.php?sid=96314&amp;amp;newtest;=Y&amp;amp;lang;=en demo of both methods here].&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FOR BOTH METHODS:&#039;&#039;&#039;&lt;br /&gt;
*[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_ Set up your survey to use JavaScript].&lt;br /&gt;
*Place the following script in your template.js file. This function will be accessed by either method.&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// A function to filter choices in a ranking question&lt;br /&gt;
&lt;br /&gt;
function rankFilter(q1ID, q2ID, prevPage) {&lt;br /&gt;
&lt;br /&gt;
   // If filter question is on a previous page, hide Q1 and check all &amp;quot;visible&amp;quot; boxes&lt;br /&gt;
&lt;br /&gt;
   if(prevPage == 1) {&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q1ID+&#039; li[id&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&amp;quot;javatbd&amp;quot;]:visible input.checkbox&#039;).attr(&#039;checked&#039;, true);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q1ID+&#039;&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   handleChecked(q1ID, q2ID);&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#question&#039;+q1ID+&#039; input.checkbox&#039;).click(function() {&lt;br /&gt;
&lt;br /&gt;
       handleChecked(q1ID, q2ID);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   function handleChecked(q1ID, q2ID) {&lt;br /&gt;
&lt;br /&gt;
       // Find the survey and group IDs&lt;br /&gt;
&lt;br /&gt;
       if($( &#039;input#fieldnames&#039; ).length != 0) {&lt;br /&gt;
&lt;br /&gt;
           var fieldNames = $( &#039;input#fieldnames&#039; ).attr(&#039;value&#039;);&lt;br /&gt;
&lt;br /&gt;
           var tmp = fieldNames.split(&#039;X&#039;);&lt;br /&gt;
&lt;br /&gt;
           var sID = tmp[0];&lt;br /&gt;
&lt;br /&gt;
           var gID = tmp[1];&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       // Loop through all Q1 options&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q1ID+&#039; input.checkbox&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
           // Find the answer code and value&lt;br /&gt;
&lt;br /&gt;
           var tmp2 = $(this).attr(&#039;id&#039;).split(&#039;X&#039;+gID+&#039;X&#039;+q1ID+&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
           var ansCode = tmp2[1];&lt;br /&gt;
&lt;br /&gt;
           var ansTxt = $(this).next(&#039;label&#039;).text();&lt;br /&gt;
&lt;br /&gt;
           // If option is checked and not in rank choices or output, add it to the rank choices&lt;br /&gt;
&lt;br /&gt;
           if($(this).attr(&#039;checked&#039;) == true&lt;br /&gt;
&lt;br /&gt;
                          &amp;amp;&amp;amp; $(&#039;#question&#039;+q2ID+&#039; select.select option[value=&amp;quot;&#039;+ansCode+&#039;&amp;quot;]&#039;).length == 0&lt;br /&gt;
&lt;br /&gt;
                          &amp;amp;&amp;amp; $(&#039;#question&#039;+q2ID+&#039; .output input[id&amp;lt;/div&amp;gt;=&amp;quot;fvalue_&amp;quot;][value=&amp;quot;&#039;+ansCode+&#039;&amp;quot;]&#039;).length == 0) {&lt;br /&gt;
&lt;br /&gt;
               $(&#039;&amp;lt;option value=&amp;quot;&#039;+ansCode+&#039;&amp;quot;&amp;gt;&#039;+ansTxt+&#039;&amp;lt;/option&amp;gt;&#039;).appendTo(&#039;#question&#039;+q2ID+&#039; select.select&#039;);&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
           // If option is unchecked...&lt;br /&gt;
&lt;br /&gt;
           else if($(this).attr(&#039;checked&#039;) == false) {&lt;br /&gt;
&lt;br /&gt;
               // Remove it from the rank choices&lt;br /&gt;
&lt;br /&gt;
               $(&#039;#question&#039;+q2ID+&#039; select.select option[value=&amp;quot;&#039;+ansCode+&#039;&amp;quot;]&#039;).remove();&lt;br /&gt;
&lt;br /&gt;
               // Remove it from the rank output and reset hidden values&lt;br /&gt;
&lt;br /&gt;
$(&#039;#question&#039;+q2ID+&#039; .output input[id&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&amp;quot;fvalue_&amp;quot;][value=&amp;quot;&#039;+ansCode+&#039;&amp;quot;]&#039;).attr(&#039;value&#039;, &#039;&#039;).siblings(&#039;input.text&#039;).val(&#039;&#039;).siblings(&#039;img&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // Clean up empty inputs in the rank output table&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q2ID+&#039; .output table tr&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
           var nextRow = $(this).next(&#039;tr&#039;);&lt;br /&gt;
&lt;br /&gt;
           if($(&#039;input.text&#039;, this).val() == &#039;&#039; &amp;amp;&amp;amp; $(&#039;input.text&#039;, nextRow).val() != &#039;&#039;) {&lt;br /&gt;
&lt;br /&gt;
               $(&#039;input.text&#039;, this).val($(&#039;input.text&#039;, nextRow).val());&lt;br /&gt;
&lt;br /&gt;
               $(&#039;input.text&#039;, nextRow).val(&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
               $(&#039;input[id&amp;lt;/div&amp;gt;=&amp;quot;fvalue_&amp;quot;]&#039;, this).attr(&#039;value&#039;, $(&#039;input[id&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&amp;quot;fvalue_&amp;quot;]&#039;, nextRow).attr(&#039;value&#039;));&lt;br /&gt;
&lt;br /&gt;
               $(&#039;input[id&amp;lt;/div&amp;gt;=&amp;quot;fvalue_&amp;quot;]&#039;, nextRow).attr(&#039;value&#039;, &#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // Show the scissors for the last populated rank output row&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q2ID+&#039; .output table img[id&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&amp;quot;cut_&amp;quot;]&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q2ID+&#039; .output table input.text[value!=&amp;quot;&amp;quot;]:last&#039;).siblings(&#039;img[id&amp;lt;/div&amp;gt;=&amp;quot;cut_&amp;quot;]&#039;).show();&lt;br /&gt;
&lt;br /&gt;
       // Hide extra rank output rows&lt;br /&gt;
&lt;br /&gt;
       var optNum = $(&#039;#question&#039;+q1ID+&#039; input.checkbox:checked&#039;).length;&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q2ID+&#039; .output table tr&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q2ID+&#039; .output table tr:lt(&#039;+(optNum+1)+&#039;)&#039;).show();&lt;br /&gt;
&lt;br /&gt;
       // Hide and clear the ranking question if there are less than 2 checked options in Q1&lt;br /&gt;
&lt;br /&gt;
       if(optNum &amp;lt; 2) {&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+q2ID+&#039;&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+q2ID+&#039; input.text&#039;).val(&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+q2ID+&#039; input[id&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&amp;quot;fvalue_&amp;quot;]&#039;).attr(&#039;value&#039;, &#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       else {&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+q2ID+&#039;&#039;).show();&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       // A work around for the built in max-answers function&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q2ID+&#039; select.select&#039;).attr(&#039;disabled&#039;, true);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q2ID+&#039; td.output tr:visible&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
           if($(&#039;input.text&#039;, this).val() == &#039;&#039;) {&lt;br /&gt;
&lt;br /&gt;
               $(&#039;#question&#039;+q2ID+&#039; select.select&#039;).attr(&#039;disabled&#039;, false);&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   // A listener to work around the built in max-answers function&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#question&#039;+q2ID+&#039; td.rank&#039;).click(function (event) {&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q2ID+&#039; select.select&#039;).attr(&#039;disabled&#039;, true);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q2ID+&#039; td.item input.text&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
           if ($(this).val() == &#039;&#039;) {&lt;br /&gt;
&lt;br /&gt;
               $(&#039;#question&#039;+q2ID+&#039; select.select&#039;).attr(&#039;disabled&#039;, false);&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FOR BOTH FILTER AND RANKING QUESTIONS ON SAME PAGE:&#039;&#039;&#039;&lt;br /&gt;
*Create a multiple options question and a ranking question on the same page (in the same group).&lt;br /&gt;
*Both questions &#039;&#039;&#039;MUST&#039;&#039;&#039; have identical sub-questions and sub-question codes.&lt;br /&gt;
*Place the following script in the source of one of the questions.&lt;br /&gt;
*Replace &amp;quot;MM&amp;quot; with the ID of the multiple options question and &amp;quot;RR&amp;quot; with the ID of the ranking question.&lt;br /&gt;
*The function will hide the ranking question unless at least two options are selected in the multiple options question, in which case, it will only show the options selected.&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       rankFilter(MM, RR);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FOR FILTER AND RANKING QUESTIONS ON SEPARATE PAGES:&#039;&#039;&#039;&lt;br /&gt;
*Create a multiple options question on page 1.&lt;br /&gt;
*Create a multiple options question and a ranking question on page 2.&lt;br /&gt;
*All three questions &#039;&#039;&#039;MUST&#039;&#039;&#039; have identical sub-questions and sub-question codes.&lt;br /&gt;
*Set the multiple options on page 2 to be filtered by the multiple options on page 1.&lt;br /&gt;
*Place the following script in the source of one of the questions on page 2.&lt;br /&gt;
*Replace &amp;quot;MM&amp;quot; with the ID of the multiple options question and &amp;quot;RR&amp;quot; with the ID of the ranking question. Do not modify the &amp;quot;1&amp;quot;.&lt;br /&gt;
*The function will hide the multiple options question. If at least 2 options were selected in the multiple options on page 1, the corresponding options will be checked in the hidden multiple options question which will then be used to control the display of the ranking question.&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       rankFilter(MM, RR, 1);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Filter &amp;quot;Array by Column&amp;quot; Question With &amp;quot;Multiple-Options&amp;quot;=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.91, IE 7/8, FireFox 3/4, Safari 5.0, Chrome 10.0&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround applies a filter to an &amp;quot;Array by Column&amp;quot; question based on the checked boxes of a previous multiple-options question. There are two methods - one for filter and array questions being on the same page and a slightly different one for the filter question being on a page before the array question.&lt;br /&gt;
&lt;br /&gt;
There is a [http://www.partnersinc.biz/surveys//index.php?sid=74213&amp;amp;newtest;=Y&amp;amp;lang;=en demo of both methods here].&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FOR BOTH METHODS:&#039;&#039;&#039;&lt;br /&gt;
*[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_ Set up your survey to use JavaScript].&lt;br /&gt;
*Place the following scripts in your template.js file. These functions will be accessed by either method.&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
   function filterArrByCol(qMultiOpt, qArray, prevPage) {&lt;br /&gt;
&lt;br /&gt;
       // If filter question is on a previous page, hide Q1 and check all &amp;quot;visible&amp;quot; boxes&lt;br /&gt;
&lt;br /&gt;
       if(prevPage == 1) {&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qMultiOpt+&#039; li[id&amp;lt;/div&amp;gt;=&amp;quot;javatbd&amp;quot;]:visible input.checkbox&#039;).attr(&#039;checked&#039;, true);&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qMultiOpt+&#039;&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       // Assign classes to the answer cells&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+qArray+&#039; table.question tbody td&#039;).each(function(i){&lt;br /&gt;
&lt;br /&gt;
           var classArr = $(this).attr(&#039;class&#039;).split(&#039;answer_cell_00&#039;);&lt;br /&gt;
&lt;br /&gt;
           var ansCode = classArr[1];&lt;br /&gt;
&lt;br /&gt;
           $(this).addClass(&#039;ans-&#039;+ansCode+&#039; filtered&#039;);&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // Assign classes to the answer label cells&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+qArray+&#039; table.question tbody tr:eq(0) td&#039;).each(function(i){&lt;br /&gt;
&lt;br /&gt;
           var classArr2 = $(this).attr(&#039;class&#039;).split(&#039; ans-&#039;);&lt;br /&gt;
&lt;br /&gt;
           var ansCode2 = classArr2[1];&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qArray+&#039; table.question thead tr:eq(0) th:eq(&#039;+i+&#039;)&#039;).addClass(&#039;ans-&#039;+ansCode2+&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // Fire the filter function on page load&lt;br /&gt;
&lt;br /&gt;
       filterArr(qMultiOpt, qArray);&lt;br /&gt;
&lt;br /&gt;
       // Listener on multi-opt checkboxes to fire the filter function&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+qMultiOpt+&#039; input.checkbox&#039;).click(function(){&lt;br /&gt;
&lt;br /&gt;
           filterArr(qMultiOpt, qArray);&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // On submit, clear all hidden radios of array&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#movenextbtn, #movesubmitbtn&#039;).click(function(){&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qArray+&#039; td.filtered:hidden&#039;).each(function(i){&lt;br /&gt;
&lt;br /&gt;
               $(&#039;input.radio&#039;, this).attr(&#039;checked&#039;, false);&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           return true;&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   function filterArr(qMultiOpt, qArray) {&lt;br /&gt;
&lt;br /&gt;
       if($(&#039;#question&#039;+qMultiOpt+&#039; input.checkbox:checked&#039;).length &amp;lt; 1) {&lt;br /&gt;
&lt;br /&gt;
           // Hide the array if no multi-opt options are checked&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qArray+&#039;&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       else {&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qArray+&#039;&#039;).show();&lt;br /&gt;
&lt;br /&gt;
           // Hide all columns of array&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qArray+&#039; table.question tbody td, #question&#039;+qArray+&#039; table.question thead th&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
           // Loop through multi-opt checkboxes and, if checked, show corresponding column of array&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qMultiOpt+&#039; input.checkbox&#039;).each(function(i){&lt;br /&gt;
&lt;br /&gt;
               if($(this).attr(&#039;checked&#039;) == true) {&lt;br /&gt;
&lt;br /&gt;
                   var classArr3 = $(this).attr(&#039;id&#039;).split(&#039;X&#039;+qMultiOpt);&lt;br /&gt;
&lt;br /&gt;
                   var ansCode3 = classArr3[1];&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;#question&#039;+qArray+&#039; .ans-&#039;+ansCode3+&#039;&#039;).show();&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FOR BOTH FILTER AND ARRAY QUESTIONS ON SAME PAGE:&#039;&#039;&#039;&lt;br /&gt;
*Create a multiple options question and an array-by-column question on the same page (in the same group).&lt;br /&gt;
*Both questions &#039;&#039;&#039;MUST&#039;&#039;&#039; have identical sub-questions and sub-question codes.&lt;br /&gt;
*Place the following script in the source of one of the questions.&lt;br /&gt;
*Replace &amp;quot;MM&amp;quot; with the ID of the multiple options question and &amp;quot;AA&amp;quot; with the ID of the ranking question.&lt;br /&gt;
*The function will hide the array question unless at least one option is selected in the multiple-options question, in which case, it will only show the corresponding array column(s).&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       filterArrByCol(MM, AA);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FOR FILTER AND ARRAY QUESTIONS ON SEPARATE PAGES:&#039;&#039;&#039;&lt;br /&gt;
*Create a multiple options question on page 1.&lt;br /&gt;
*Create a multiple options question and an array-by-column question on page 2.&lt;br /&gt;
*All three questions &#039;&#039;&#039;MUST&#039;&#039;&#039; have identical sub-questions and sub-question codes.&lt;br /&gt;
*Set the multiple options on page 2 to be filtered by the multiple options on page 1.&lt;br /&gt;
*Place the following script in the source of one of the questions on page 2.&lt;br /&gt;
*Replace &amp;quot;MM&amp;quot; with the ID of the multiple options question and &amp;quot;AA&amp;quot; with the ID of the array question. Do not modify the &amp;quot;1&amp;quot;.&lt;br /&gt;
*The function will hide the multiple options question. If options were selected in the multiple options on page 1, the corresponding options will be checked in the hidden multiple options question which will then be used to control the display of the array columns.&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       filterArrByCol(MM, AA, 1);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Auto-tabbing between text input fields=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 6/7, FireFox 3.0, Safari 3.2, Chrome 2.0&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This is a workaround to facilitate auto-tabbing between text input questions in a single group using a [http://plugins.jquery.com/project/autotab jQuery plugin by Mathachew] and the Maximum characters attribute of questions.&lt;br /&gt;
&lt;br /&gt;
The behaviour will be: When the maximum number of characters has been entered into an input field, the focus (cursor) will be automatically moved to the next input field. When the backspace key is used to remove all characters from a field, the focus will be moved to the previous field. It&#039;s very useful in surveys having many text input questions to avoid having to manually tab or click between fields.&lt;br /&gt;
&lt;br /&gt;
You can view a small demo survey [http://www.partnersinc.biz/surveys//index.php?sid=11327&amp;amp;newtest;=Y&amp;amp;lang;=en here].&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#Visit [http://plugins.jquery.com/node/4046 http://plugins.jquery.com/node/4046], download the plugin script and save it as &#039;&#039;jquery.autotab-1.1b.js&#039;&#039; in the template folder.&lt;br /&gt;
#Link to the script by placing &#039;&#039;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;{TEMPLATEURL}jquery.autotab-1.1b.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&#039;&#039; within the &#039;&#039;&amp;lt;head&amp;gt;&#039;&#039; tag of startpage.pstpl.&lt;br /&gt;
#[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_ Set up your survey to use JavaScript].&lt;br /&gt;
#Create the text based questions that auto-tabbing is to be applied to. (All must be in the same group if you&#039;re using group by group presentation)&lt;br /&gt;
#Define a Maximum characters attribute for all questions that the autotab is applied to. (See [http://docs.limesurvey.org/tiki-index.php?page=Question+attributes&amp;amp;structure;=English+Instructions+for+LimeSurvey#maximum_chars documentation here])&lt;br /&gt;
#In the source of the first question of the group that contains the auto-tabbed questions, add the following code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#answerSSSSSXGGXAA&#039;).focus(); //initially focus on the first input&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#answerSSSSSXGGXAA&#039;).autotab({ target: &#039;answerSSSSSXGGXBB&#039; });&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#answerSSSSSXGGXBB&#039;).autotab({ previous: &#039;answerSSSSSXGGXAA&#039;, target: &#039;answerSSSSSXGGXCC&#039; });&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#answerSSSSSXGGXCC&#039;).autotab({ previous: &#039;answerSSSSSXGGXBB&#039;, target: &#039;answerSSSSSXGGXDD&#039; });&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#answerSSSSSXGGXDD&#039;).autotab({ previous: &#039;answerSSSSSXGGXCC&#039; });&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example has 4 fields to be auto-tabbed between - all instances of the following must be replaced to be compatible with your survey (See image below):&lt;br /&gt;
*SSSSS -&amp;gt; Survey ID&lt;br /&gt;
*GG -&amp;gt; Group ID&lt;br /&gt;
*AA -&amp;gt; First question&lt;br /&gt;
*BB -&amp;gt; Second question&lt;br /&gt;
*CC -&amp;gt; Third question&lt;br /&gt;
*DD -&amp;gt; Last question&lt;br /&gt;
&lt;br /&gt;
[[File:ids_343x252.gif]]&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;target&#039;&#039; parameter defines where the next input is and the &#039;&#039;previous&#039;&#039; parameter defines (you guessed it) the previous input.&lt;br /&gt;
&lt;br /&gt;
This plugin also has limited capability of formatting the input text - see comments in the plugin script.&lt;br /&gt;
&lt;br /&gt;
=Custom response listeners=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.85+ (7253), IE 6/7, FireFox 3.0, Safari 3.2, Chrome 2.0&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Listeners can be used to perform functions when a change in an input is detected. There are many uses such as the [http://docs.limesurvey.org/tiki-index.php?page=Workarounds#Reverse_array_filter Reverse array_filter] but a simple one would be to warn a respondent if they enter a value that may be too high.&lt;br /&gt;
&lt;br /&gt;
We can use the [http://docs.jquery.com/Events/change jQuery change( ) event] to fire a function whenever there is a change to the input. The function will look for an input value higher than 10 and, if found, will warn the respondent.&lt;br /&gt;
#[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_ Set up your survey to use JavaScript].&lt;br /&gt;
#Place the script below in the source of one of the questions on the page where:&lt;br /&gt;
**11111 is the survey ID&lt;br /&gt;
**22 is the group ID&lt;br /&gt;
**33 is the question ID&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#answer11111X22X33&#039;).change(function() {&lt;br /&gt;
&lt;br /&gt;
           if ( $(&#039;#answer11111X22X33&#039;).val() &amp;gt; 10 ) {&lt;br /&gt;
&lt;br /&gt;
               alert (&amp;quot;That&#039;s an awful lot. Are you sure?&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Text input masks=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 7, FireFox 3.0, Safari 3.2, Chrome 2.0&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;We&#039;re considering adding this as a built-in feature for version 1.92 (e.g. an advanced question attribute).&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There may be instances where you would like to place a mask on a text input - for example only allowing respondents to enter the correct characters for a North American phone number [[Expression Manager|Expression Manager]] rand() function.  This can be part of a relevance equation to randomly control which questions are shown; or you can create an Equation question type to store the random value, and let that question be part of downstream relevance equations.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround allows you to generate a random number and then populate a hidden question with that number. You can then use this question to control the display of subsequent questions with [http://docs.limesurvey.org/tiki-index.php?page=Setting+conditions&amp;amp;structure;=English+Instructions+for+LimeSurvey Conditions]. It&#039;s useful if you have several sets of questions that you would like to randomly present to participants - see this  [http://www.limesurvey.org/en/support/forums/5-can-i-do-this-with-limesurvey/29579-experiment-with-random-questions.html forum post].&lt;br /&gt;
&lt;br /&gt;
There is a small demo [http://www.partnersinc.biz/surveys//index.php?sid=12659&amp;amp;newtest;=Y&amp;amp;lang;=en here].&lt;br /&gt;
&lt;br /&gt;
In the demo, in the first group, we generate a random number between 1 and 4 and populate a hidden question with it. Then in the second group we have 4 questions, each showing conditional on the answer of the first question.&lt;br /&gt;
&lt;br /&gt;
Implementation for this demo is as follows:&lt;br /&gt;
#Turn off &#039;&#039;$filterxsshtml&#039;&#039; to allow insertion of JavaScript in the questions. (See [http://docs.limesurvey.org/tiki-index.php?page=Optional+settings&amp;amp;structure;=English+Instructions+for+LimeSurvey#Filtering_dangerous_HTML_tags_in_survey_objects documentation here])&lt;br /&gt;
#Set up the template to use custom onload functions. (See the [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#Custom_onload_function workaround here])&lt;br /&gt;
#In the first group add a &amp;quot;Short free text&amp;quot; question (We&#039;re going to hide this with JavaScript)&lt;br /&gt;
#In the source of that question add the following onload function. (See [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._ How to use script here])&lt;br /&gt;
#In the following groups add the questions that are conditional on the answer of the first question.&lt;br /&gt;
&lt;br /&gt;
Onload code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
function Custom_On_Load(){&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Find a random number between 1 and 4&lt;br /&gt;
&lt;br /&gt;
       var randNumber = Math.floor(Math.random()*4 + 1);&lt;br /&gt;
&lt;br /&gt;
       // Populate and hide the hidden question&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input#answerSSSSSXGGXQQ&#039;).val(randNumber);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#questionQQ&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
       /***********************************************************/&lt;br /&gt;
&lt;br /&gt;
       // This just tells the user which number has been selected&lt;br /&gt;
&lt;br /&gt;
       // You can remove this from your onload function&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input#setNumber&#039;).val(randNumber);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input#setNumber&#039;).css({&lt;br /&gt;
&lt;br /&gt;
           &#039;margin-left&#039;:&#039;0.5em&#039;,&lt;br /&gt;
&lt;br /&gt;
           &#039;width&#039;:&#039;1.5em&#039;,&lt;br /&gt;
&lt;br /&gt;
           &#039;text-align&#039;:&#039;center&#039;,&lt;br /&gt;
&lt;br /&gt;
           &#039;font-weight&#039;:&#039;bold&#039;&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input#setNumber&#039;).attr(&#039;disabled&#039;, true);&lt;br /&gt;
&lt;br /&gt;
       /***********************************************************/&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &#039;&#039;&#039;SSSSS&#039;&#039;&#039; is the survey ID, &#039;&#039;&#039;GG&#039;&#039;&#039; is the group ID and &#039;&#039;&#039;QQ&#039;&#039;&#039; is the hidden question ID.&lt;br /&gt;
&lt;br /&gt;
Increase or decrease the maximum value of the random number by modifying the first section. For example to get a number between 1 and 10 you would use this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
var randNumber = Math.floor(Math.random()*10 + 1);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The third section of code just populates a placeholder element that I use to tell the participant what&#039;s going on. You can remove it from your code.&lt;br /&gt;
&lt;br /&gt;
=Minimum number of required answers in an array=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 6/7, FireFox 3.0, Safari 3.2,&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92 all array style questions have the min_answers and max_answers options, so this script is obsolete.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround allows you to specify a &#039;&#039;&#039;minimum number&#039;&#039;&#039; of answers required in an array question. It is an alternative to the &amp;quot;Mandatory&amp;quot; parameter which specifies that &#039;&#039;&#039;all&#039;&#039;&#039; answers are required. It could also be easily modified to specify a maximum number of answers.&lt;br /&gt;
&lt;br /&gt;
We accomplish this by placing an onload function in the source of the array question. This function hides the Next/Submit button and displays a warning element until it detects a minimum number of responses. It then hides the warning and shows the Next/Submit button.&lt;br /&gt;
&lt;br /&gt;
There is a demo [http://www.partnersinc.biz/surveys//index.php?sid=97166&amp;amp;newtest;=Y&amp;amp;lang;=en here].&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#Turn off &#039;&#039;$filterxsshtml&#039;&#039; to allow insertion of JavaScript in the questions. (See [http://docs.limesurvey.org/tiki-index.php?page=Optional+settings&amp;amp;structure;=English+Instructions+for+LimeSurvey#Filtering_dangerous_HTML_tags_in_survey_objects documentation here])&lt;br /&gt;
#Set up the template to use custom onload functions. (See the [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#Custom_onload_function workaround here])&lt;br /&gt;
#In the source of the array question add the following onload function. (See [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._ How to use script here])&lt;br /&gt;
#Modify the &#039;&#039;SETTINGS&#039;&#039; section of the code as required.&lt;br /&gt;
&lt;br /&gt;
Onload code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Wait until the document is fully loaded&lt;br /&gt;
&lt;br /&gt;
$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
   /********************** SETTINGS **********************/&lt;br /&gt;
&lt;br /&gt;
   // The text to appear in the warning element&lt;br /&gt;
&lt;br /&gt;
   var warningText = &#039;Please answer at least 4 to continue&#039;;&lt;br /&gt;
&lt;br /&gt;
   // The question ID&lt;br /&gt;
&lt;br /&gt;
   var questionId = 137;&lt;br /&gt;
&lt;br /&gt;
   // The minimum number of answers required&lt;br /&gt;
&lt;br /&gt;
   var minNumber = 4;&lt;br /&gt;
&lt;br /&gt;
   /******************************************************/&lt;br /&gt;
&lt;br /&gt;
   // Create the warning element and place it after the submit button&lt;br /&gt;
&lt;br /&gt;
   var el = document.createElement(&#039;div&#039;);&lt;br /&gt;
&lt;br /&gt;
   el.setAttribute(&#039;id&#039;,&#039;warning&#039;);&lt;br /&gt;
&lt;br /&gt;
   document.body.appendChild(el);&lt;br /&gt;
&lt;br /&gt;
   $( &#039;#warning&#039; ).css({&lt;br /&gt;
&lt;br /&gt;
       &#039;border&#039;:&#039;1px solid #333333&#039;,&lt;br /&gt;
&lt;br /&gt;
       &#039;width&#039;:&#039;200px&#039;,&lt;br /&gt;
&lt;br /&gt;
       &#039;padding&#039;:&#039;3px&#039;,&lt;br /&gt;
&lt;br /&gt;
       &#039;color&#039;:&#039;red&#039;&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#warning&#039;).html(warningText);&lt;br /&gt;
&lt;br /&gt;
   $(&#039;input[type=&amp;quot;submit&amp;quot;]&#039;).after($(&#039;#warning&#039;));&lt;br /&gt;
&lt;br /&gt;
   // Detect the initial number of checked answers &amp;amp; display Next/Submit button accordingly&lt;br /&gt;
&lt;br /&gt;
   var inputInitCount = 0;&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#question&#039; + questionId + &#039; input&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
       if ($( this ).attr(&#039;checked&#039;) == true ) {&lt;br /&gt;
&lt;br /&gt;
           inputInitCount++;&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   if (inputInitCount &amp;gt; (minNumber - 1)) {&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input[type=&amp;quot;submit&amp;quot;]&#039;).show();&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#warning&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   else {&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#warning&#039;).show();&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input[type=&amp;quot;submit&amp;quot;]&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   // Listener to detect number of checked answers &amp;amp; display Next/Submit button accordingly&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#question&#039; + questionId + &#039; input.radio, #question&#039;+questionId+&#039; tbody[id&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&amp;quot;javatbd&amp;quot;] td&#039;).click(function() {&lt;br /&gt;
&lt;br /&gt;
       var inputCount = 0;&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039; + questionId + &#039; input.radio&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
           if ($( this ).attr(&#039;checked&#039;) == true ) {&lt;br /&gt;
&lt;br /&gt;
               inputCount++;&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       if (inputCount &amp;gt; (minNumber - 1)) {&lt;br /&gt;
&lt;br /&gt;
           $(&#039;input[type=&amp;quot;submit&amp;quot;]&#039;).show();&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#warning&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       else {&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#warning&#039;).show();&lt;br /&gt;
&lt;br /&gt;
           $(&#039;input[type=&amp;quot;submit&amp;quot;]&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       // The original functions of the click event&lt;br /&gt;
&lt;br /&gt;
       checkconditions(this.value, this.name, this.type);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Minimum elapsed time before moving forward in survey=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.91, IE 7/8, Firefox 7.0, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround interrupts the Next/Submit function and checks the amount of time elapsed since the page loaded. If the time is less than the minimum dictated, the respondent is alerted and not allowed to proceed. It is useful if you want to enforce a minimum amount of time spent viewing a page.&lt;br /&gt;
#[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_ Set up your survey to use JavaScript].&lt;br /&gt;
#Place the script below in the source of one of the questions on the page, replacing &amp;quot;TT&amp;quot; with the minimum number of seconds required before advancing is allowed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       minTime(TT);&lt;br /&gt;
&lt;br /&gt;
       function minTime(minTime) {&lt;br /&gt;
&lt;br /&gt;
           var startTime = new Date();&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#movenextbtn, #movesubmitbtn&#039;).click(function(){&lt;br /&gt;
&lt;br /&gt;
               var endTime = new Date();&lt;br /&gt;
&lt;br /&gt;
               if[[endTime - startTime)/1000 &amp;lt;= minTime) {&lt;br /&gt;
&lt;br /&gt;
                    alert (&#039;You must spend at least &#039;+minTime+&#039; seconds on the question.&#039;);&lt;br /&gt;
&lt;br /&gt;
                    return false;&lt;br /&gt;
&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
                else {&lt;br /&gt;
&lt;br /&gt;
                    return true;&lt;br /&gt;
&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
            });&lt;br /&gt;
&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 =Minimum number of characters in Long free text or Huge free text questions=&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with: 1.91, IE 7/8, Firefox 7.0, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/div&amp;gt;As of version 1.91, you can use regular expression masks (validation) to specify the minimum number of required characters.  However, even if the question is mandatory, it can still be blank.&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/div&amp;gt;As of version  1.92, if you make the question mandatory and use a validation mask to specify the minimum number of characters, then the user will be forced to answer the question.  Note that unlike 1.91, they can submit their current answers, even if partially invalid (so they are stored in the database), but they will not ber able to proceed to the next page until they have passed all mandatory and validity checks.&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 This workaround interrupts the Next/Submit function and checks the number of characters entered in a Long free text or Huge free text question. If the number is less than the minimum dictated, the respondent is alerted and not allowed to proceed.&lt;br /&gt;
&lt;br /&gt;
 #[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_|Set up your survey to use JavaScript].&lt;br /&gt;
&lt;br /&gt;
 #Place the script below in the source of one of the questions on the page, replace &amp;quot;QQ&amp;quot; with the question ID and &amp;quot;CC&amp;quot; with the minimum number of characters required before advancing is allowed.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
        minChar(QQ, CC);&lt;br /&gt;
&lt;br /&gt;
        function minChar(qID, minChars) {&lt;br /&gt;
&lt;br /&gt;
            $(&#039;#movenextbtn, #movesubmitbtn&#039;).click(function(){&lt;br /&gt;
&lt;br /&gt;
                if($(&#039;#question&#039;+qID+&#039; textarea&#039;).val().replace(/ /g,&#039;&#039;).length &amp;lt; minChars) {&lt;br /&gt;
&lt;br /&gt;
                    alert (&#039;You must enter at least &#039;+minChars+&#039; characters.&#039;);&lt;br /&gt;
&lt;br /&gt;
                    return false;&lt;br /&gt;
&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
                else {&lt;br /&gt;
&lt;br /&gt;
                    return true;&lt;br /&gt;
&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
            });&lt;br /&gt;
&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 =Variable Length Array (Multi Flexible Text) question=&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with: 1.90+, IE 6/7/8, FireFox 3.0, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 This workaround allows a respondent to add or remove rows of an Array (Multi Flexible Text) question. It&#039;s useful to avoid the page being cluttered with unnecessary array rows.&lt;br /&gt;
&lt;br /&gt;
 A function is placed in the template.js file of your template (use template editor). This function hides all of the array rows except the first and inserts two elements that when clicked show or hide rows accordingly.&lt;br /&gt;
&lt;br /&gt;
 There is a demo [http://www.partnersinc.biz/surveys//index.php?sid=53132&amp;amp;newtest;=Y&amp;amp;lang;=en|here].&lt;br /&gt;
&lt;br /&gt;
 It must be noted that you can not make this question Mandatory as the respondent will have no way to complete hidden fields. If you want the displayed fields to be mandatory you will need to validate them in another function or modify this function to only allow the addition of rows if all fields in the last row are completed and then disable those fields - that, however, is a little over the top for this example.&lt;br /&gt;
&lt;br /&gt;
 Implementation is as follows:&lt;br /&gt;
&lt;br /&gt;
 #Set up your survey to use JavaScript (See instructions [http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_|here])&lt;br /&gt;
&lt;br /&gt;
 #Add the following script to your &#039;&#039;template.js&#039;&#039; file.&lt;br /&gt;
&lt;br /&gt;
 #Replace &amp;quot;QQ&amp;quot; in the function call at the end with the question ID.&lt;br /&gt;
&lt;br /&gt;
 #Create one or more Array (Multi Flexible Text) questions&lt;br /&gt;
&lt;br /&gt;
 #If you want to apply it to more arrays on the same page simply add more calls with the appropriate question IDs. (eg. varLengthArray(1); varLengthArray(2);...)&lt;br /&gt;
&lt;br /&gt;
 Onload code:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
        // A function to add or remove rows of an Array (Multi Flexible)(Text) question&lt;br /&gt;
&lt;br /&gt;
        function varLengthArray(qID) {&lt;br /&gt;
&lt;br /&gt;
            if ($(&#039;#question&#039;+qID+&#039;&#039;).length &amp;gt; 0) {&lt;br /&gt;
&lt;br /&gt;
                // The HTML content of the Add/Remove elements - modify as you wish&lt;br /&gt;
&lt;br /&gt;
                var addContent = &#039;[+]&#039;;&lt;br /&gt;
&lt;br /&gt;
                var removeContent = &#039;[-]&#039;;&lt;br /&gt;
&lt;br /&gt;
                // Create the Add and Remove elements &amp;amp; insert them&lt;br /&gt;
&lt;br /&gt;
                var el1 = document.createElement(&#039;div&#039;);&lt;br /&gt;
&lt;br /&gt;
                el1.setAttribute(&#039;id&#039;,&#039;addButton&#039;+qID);&lt;br /&gt;
&lt;br /&gt;
                document.body.appendChild(el1);&lt;br /&gt;
&lt;br /&gt;
                var el2 = document.createElement(&#039;div&#039;);&lt;br /&gt;
&lt;br /&gt;
                el2.setAttribute(&#039;id&#039;,&#039;removeButton&#039;+qID);&lt;br /&gt;
&lt;br /&gt;
                document.body.appendChild(el2);&lt;br /&gt;
&lt;br /&gt;
                // Move them to after the array&lt;br /&gt;
&lt;br /&gt;
                $( &#039;div#addButton&#039;+qID ).appendTo($( &#039;#question&#039; + qID + &#039; table.question&#039; ).parent(]];&lt;br /&gt;
&lt;br /&gt;
               $( &#039;div#removeButton&#039;+qID ).appendTo($( &#039;#question&#039; + qID + &#039; table.question&#039; ).parent());&lt;br /&gt;
&lt;br /&gt;
               // Insert their HTML&lt;br /&gt;
&lt;br /&gt;
               $( &#039;div#addButton&#039;+qID ).html( addContent );&lt;br /&gt;
&lt;br /&gt;
               $( &#039;div#removeButton&#039;+qID ).html( removeContent );&lt;br /&gt;
&lt;br /&gt;
               // Style the elements - you can modify here if you wish&lt;br /&gt;
&lt;br /&gt;
               $( &#039;div#addButton&#039;+qID ).css({&lt;br /&gt;
&lt;br /&gt;
                   &#039;margin&#039;:&#039;10px 0 0 10px&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;padding&#039;:&#039;1px&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;text-align&#039;:&#039;center&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;font-weight&#039;:&#039;bold&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;width&#039;:&#039;auto&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;cursor&#039;:&#039;pointer&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;float&#039;:&#039;left&#039;&lt;br /&gt;
&lt;br /&gt;
               });&lt;br /&gt;
&lt;br /&gt;
               $( &#039;div#removeButton&#039;+qID ).css({&lt;br /&gt;
&lt;br /&gt;
                   &#039;margin&#039;:&#039;10px 0 0 10px&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;padding&#039;:&#039;1px&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;text-align&#039;:&#039;center&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;font-weight&#039;:&#039;bold&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;width&#039;:&#039;auto&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;cursor&#039;:&#039;pointer&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;float&#039;:&#039;left&#039;&lt;br /&gt;
&lt;br /&gt;
               });&lt;br /&gt;
&lt;br /&gt;
               // Initially hide the Remove element&lt;br /&gt;
&lt;br /&gt;
               $( &#039;div#removeButton&#039;+qID ).hide();&lt;br /&gt;
&lt;br /&gt;
               // Call the functions below when clicked&lt;br /&gt;
&lt;br /&gt;
               $( &#039;div#addButton&#039;+qID ).click(function (event) {&lt;br /&gt;
&lt;br /&gt;
                   addRow(qID);&lt;br /&gt;
&lt;br /&gt;
               });&lt;br /&gt;
&lt;br /&gt;
               $( &#039;div#removeButton&#039;+qID ).click(function (event) {&lt;br /&gt;
&lt;br /&gt;
                   removeRow(qID);&lt;br /&gt;
&lt;br /&gt;
               });&lt;br /&gt;
&lt;br /&gt;
               // Function to add a row, also shows the Remove element and hides the&lt;br /&gt;
&lt;br /&gt;
               //Add element if all rows are shown&lt;br /&gt;
&lt;br /&gt;
               function addRow(qID) {&lt;br /&gt;
&lt;br /&gt;
                   var arrayRow = &#039;#question&#039; + qID + &#039; table.question tbody&#039;;&lt;br /&gt;
&lt;br /&gt;
                   var rowCount = $( arrayRow ).size() - 1;&lt;br /&gt;
&lt;br /&gt;
                   $( arrayRow + &#039;[name=&amp;quot;hidden&amp;quot;]:first&#039; ).attr(&#039;name&#039;, &#039;visible&#039;).show();&lt;br /&gt;
&lt;br /&gt;
                   $( &#039;div#removeButton&#039;+qID ).show();&lt;br /&gt;
&lt;br /&gt;
                   if ( $( arrayRow + &#039;:eq(&#039; + rowCount + &#039;)&#039; ).attr(&#039;name&#039;) == &#039;visible&#039; )  {&lt;br /&gt;
&lt;br /&gt;
                       $( &#039;div#addButton&#039;+qID ).hide();&lt;br /&gt;
&lt;br /&gt;
                   }&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               // Function to remove a row, also clears the contents of the removed row,&lt;br /&gt;
&lt;br /&gt;
               // shows the Add element if the last row is hidden and hides the Remove&lt;br /&gt;
&lt;br /&gt;
               // element if only the first row is shown&lt;br /&gt;
&lt;br /&gt;
               function removeRow(qID) {&lt;br /&gt;
&lt;br /&gt;
                   var arrayRow = &#039;#question&#039; + qID + &#039; table.question tbody&#039;;&lt;br /&gt;
&lt;br /&gt;
                   var rowCount = $( arrayRow ).size() - 1;&lt;br /&gt;
&lt;br /&gt;
                   $( arrayRow + &#039;[name=&amp;quot;visible&amp;quot;]:last input[type=&amp;quot;text&amp;quot;]&#039; ).val(&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
                   $( arrayRow + &#039;[name=&amp;quot;visible&amp;quot;]:last&#039; ).attr(&#039;name&#039;, &#039;hidden&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
                   $( &#039;div#addButton&#039;+qID ).show();&lt;br /&gt;
&lt;br /&gt;
                   if ( $( arrayRow + &#039;:eq(1)&#039; ).attr(&#039;name&#039;) == &#039;hidden&#039; )  {&lt;br /&gt;
&lt;br /&gt;
                       $( &#039;div#removeButton&#039;+qID ).hide();&lt;br /&gt;
&lt;br /&gt;
                   }&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               // Just some initialization stuff&lt;br /&gt;
&lt;br /&gt;
               var arrayRow = &#039;#question&#039; + qID + &#039; table.question tbody&#039;;&lt;br /&gt;
&lt;br /&gt;
               var rowCount = &#039;&#039;;&lt;br /&gt;
&lt;br /&gt;
               // Initially hide all except first row or any rows with populated inputs&lt;br /&gt;
&lt;br /&gt;
               $( arrayRow ).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
                   if ( i &amp;gt; 0 ) {&lt;br /&gt;
&lt;br /&gt;
                       // We also need to give the hidden rows a name cause IE doesn&#039;t&lt;br /&gt;
&lt;br /&gt;
                       // recognize jQuery :visible selector consistently&lt;br /&gt;
&lt;br /&gt;
                       $( this ).attr(&#039;name&#039;, &#039;hidden&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
                       $(&#039;input[type=text]&#039;, this).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
                           if ($(this).attr(&#039;value&#039;) != &#039;&#039;) {&lt;br /&gt;
&lt;br /&gt;
                               $(this).parents(&#039;tbody:eq(0)&#039;).attr(&#039;name&#039;, &#039;visible&#039;).show();&lt;br /&gt;
&lt;br /&gt;
                               $( &#039;div#removeButton&#039;+qID ).show();&lt;br /&gt;
&lt;br /&gt;
                           }&lt;br /&gt;
&lt;br /&gt;
                       });&lt;br /&gt;
&lt;br /&gt;
                       rowCount = i;&lt;br /&gt;
&lt;br /&gt;
                   }&lt;br /&gt;
&lt;br /&gt;
               });&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       // Call the function with a question ID&lt;br /&gt;
&lt;br /&gt;
       varLengthArray(QQ);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Expandable Array=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 6/7, FireFox 3.5, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround allows you to present an array question incrementally. That is to say that initially only the first option (row) in the array is shown. When that option is answered the next is shown and so-on.&lt;br /&gt;
&lt;br /&gt;
A JavaScript function is placed in the source of the array question. This function hides all of the array rows except the first and then displays them as options are answered.&lt;br /&gt;
&lt;br /&gt;
There is a demo [http://www.partnersinc.biz/surveys//index.php?sid=94958&amp;amp;newtest;=Y&amp;amp;lang;=en here].&lt;br /&gt;
&lt;br /&gt;
The workaround supports following question types:&lt;br /&gt;
*Array (flexible labels)&lt;br /&gt;
*Array (flexible labels) by column&lt;br /&gt;
*Array (Yes/No/Uncertain)&lt;br /&gt;
*Array (Increase, Same, Decrease)&lt;br /&gt;
*Array (Flexible Labels) dual scale&lt;br /&gt;
*Array (10 point choice)&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#Set up your survey to use JavaScript. (See [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._ documentation here])&lt;br /&gt;
#Create one or more Array questions&lt;br /&gt;
#In the source of the first array question add the following script.&lt;br /&gt;
#Replace &amp;quot;QQ&amp;quot; in the function call at the end of the script with the question ID of the array you would like to manipulate.&lt;br /&gt;
#If you want to apply it to more arrays on the same page, simply add more calls with the appropriate question IDs. (eg. expandingArray(1); expandingArray(2);...)&lt;br /&gt;
&lt;br /&gt;
Onload code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // A function to show subsequent rows of an array as options are checked&lt;br /&gt;
&lt;br /&gt;
       function expandingArray(qID) {&lt;br /&gt;
&lt;br /&gt;
           // Build an array of the question rows&lt;br /&gt;
&lt;br /&gt;
           var arrayRow = &#039;#question&#039; + qID + &#039; table.question tbody tr&#039;;&lt;br /&gt;
&lt;br /&gt;
           // Initially hide all rows unless an input was previously checked&lt;br /&gt;
&lt;br /&gt;
           $( arrayRow ).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
               if ( $( arrayRow  + &#039;:eq(&#039; + i + &#039;) input.radio:checked&#039; ).length != 0 ) {&lt;br /&gt;
&lt;br /&gt;
                   $( this ).attr(&#039;name&#039;, &#039;clickedRow&#039;);&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               else {&lt;br /&gt;
&lt;br /&gt;
                   $( this ).attr(&#039;name&#039;, &#039;hidden&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Now show the first hidden row&lt;br /&gt;
&lt;br /&gt;
           addRow();&lt;br /&gt;
&lt;br /&gt;
           // Add another row when an option is checked for the first time&lt;br /&gt;
&lt;br /&gt;
           $( &#039;#question&#039; + qID + &#039; td.answer input.radio&#039; ).click(function (event) {&lt;br /&gt;
&lt;br /&gt;
               if ($( this ).parents(&#039;tr:eq(0)&#039;).attr(&#039;name&#039;) != &#039;clickedRow&#039;) {&lt;br /&gt;
&lt;br /&gt;
                   addRow();&lt;br /&gt;
&lt;br /&gt;
                   $( this ).parents(&#039;tr:eq(0)&#039;).attr(&#039;name&#039;, &#039;clickedRow&#039;);&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               // The original function of the click event&lt;br /&gt;
&lt;br /&gt;
               checkconditions(this.value, this.name, this.type);&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Add another row when an table cell is clicked for the first time&lt;br /&gt;
&lt;br /&gt;
           $( &#039;#question&#039; + qID + &#039; table.question tbody td&#039; ).click(function (event) {&lt;br /&gt;
&lt;br /&gt;
               if ($( this ).parents(&#039;tr:eq(0)&#039;).attr(&#039;name&#039;) != &#039;clickedRow&#039;) {&lt;br /&gt;
&lt;br /&gt;
                   addRow();&lt;br /&gt;
&lt;br /&gt;
                   $( this ).parents(&#039;tr:eq(0)&#039;).attr(&#039;name&#039;, &#039;clickedRow&#039;);&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Function to add a row&lt;br /&gt;
&lt;br /&gt;
           function addRow() {&lt;br /&gt;
&lt;br /&gt;
               $( arrayRow + &#039;[name=&amp;quot;hidden&amp;quot;]:first&#039; ).attr(&#039;name&#039;, &#039;visible&#039;).show();&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       // Call the function with a question ID&lt;br /&gt;
&lt;br /&gt;
       expandingArray(QQ);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Partially Randomized Answers - Multiple Options &amp;amp; List (radio) questions=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 6/7, FireFox 3.0, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround allows the answers of Multiple Options &amp;amp; List (radio) questions to be randomized while always keeping one answer at the end of the list. It&#039;s useful if you want to randomize, say, the first 4 of your answers but always have the fifth displayed last as in the image below:&lt;br /&gt;
&lt;br /&gt;
[[File:random_336x179gif.gif]]&lt;br /&gt;
&lt;br /&gt;
An onload function is placed in the source of a question. After the randomizing has occurred this function moves the answer with the highest answer code to the end of the list.&lt;br /&gt;
&lt;br /&gt;
There is a demo [http://www.partnersinc.biz/surveys//index.php?sid=89344&amp;amp;newtest;=Y&amp;amp;lang;=en here].&lt;br /&gt;
&lt;br /&gt;
Some conditions on the use of this are:&lt;br /&gt;
*For Select/radio type questions it will only work if the [http://docs.limesurvey.org/tiki-index.php?page=Optional+settings&amp;amp;structure;=English+Instructions+for+LimeSurvey#Survey_Behavior $shownoanswer option] is set to 0 in config.php. (&amp;quot;No answer&amp;quot; is removed from the end of questions)&lt;br /&gt;
*You must use sequential numbers, starting at 1 as response codes. (See image below)&lt;br /&gt;
&lt;br /&gt;
[[File:random_700x154.png]]&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#Turn off &#039;&#039;$filterxsshtml&#039;&#039; to allow insertion of JavaScript in the questions. (See [http://docs.limesurvey.org/tiki-index.php?page=Optional+settings&amp;amp;structure;=English+Instructions+for+LimeSurvey#Filtering_dangerous_HTML_tags_in_survey_objects documentation here])&lt;br /&gt;
#Create one or more Multiple Options or List (radio) questions with sequential response codes. Set the [http://docs.limesurvey.org/tiki-index.php?page=Question+attributes&amp;amp;structure;=English+Instructions+for+LimeSurvey#random_order random_order question attribute] to 1.&lt;br /&gt;
#In the source of the first question add the following onload function. (See [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._ How to use script here])&lt;br /&gt;
#Replace &amp;quot;SSSSS&amp;quot;, &amp;quot;GG&amp;quot;, &amp;quot;QQ&amp;quot; in the function call at the end with the survey ID, group ID and question ID respectively.&lt;br /&gt;
#If you want to apply it to more questions on the same page simply add more calls with the appropriate IDs. (eg. partRand(11111, 22, 1); partRand(11111, 22, 2); ...)&lt;br /&gt;
&lt;br /&gt;
Onload code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Function to allow randomization of all answers except the last one in Multiple options and List/radio questions&lt;br /&gt;
&lt;br /&gt;
       function partRand(sID, gID, qID) {&lt;br /&gt;
&lt;br /&gt;
           // Find the number of answers&lt;br /&gt;
&lt;br /&gt;
           var ansCount = &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
           $( &#039;div#question&#039; + qID + &#039; td.answer li&#039; ).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
               ansCount = (i + 1);&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Place the last answer created at the end of the list&lt;br /&gt;
&lt;br /&gt;
           $( &#039;input#answer&#039; + sID + &#039;X&#039; + gID + &#039;X&#039; + qID + ansCount + &#039;&#039; ).parent().appendTo($( &#039;#question&#039; + qID + &#039; td.answer ul&#039; ));&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       // Call the function with the SID, GID and QID&lt;br /&gt;
&lt;br /&gt;
       partRand(SSSSS, GG, QQ);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Partially Randomized Answers - List (dropdown) questions=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 6/7, FireFox 3.0, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround, similar to the one above, allows the answers of List (dropdown) questions to be randomized while always keeping one answer at the end of the list. It&#039;s useful if you want to randomize, say, the first 4 of your answers but always have the fifth displayed last.&lt;br /&gt;
&lt;br /&gt;
An onload function is placed in the source of a question. After the randomizing has occurred this function moves the answer with the highest answer code to the end of the list.&lt;br /&gt;
&lt;br /&gt;
There is a demo [http://www.partnersinc.biz/surveys//index.php?sid=89344&amp;amp;newtest;=Y&amp;amp;lang;=en here].&lt;br /&gt;
&lt;br /&gt;
A condition is that you must use sequential numbers, starting at 1 as response codes. (See image below)&lt;br /&gt;
&lt;br /&gt;
[[File:random_700x154.png]]&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#Turn off &#039;&#039;$filterxsshtml&#039;&#039; to allow insertion of JavaScript in the questions. (See [http://docs.limesurvey.org/tiki-index.php?page=Optional+settings&amp;amp;structure;=English+Instructions+for+LimeSurvey#Filtering_dangerous_HTML_tags_in_survey_objects documentation here])&lt;br /&gt;
#Create one or more List (dropdown) questions with sequential response codes. Set the [http://docs.limesurvey.org/tiki-index.php?page=Question+attributes&amp;amp;structure;=English+Instructions+for+LimeSurvey#random_order random_order question attribute] to 1.&lt;br /&gt;
#In the source of the first question add the following onload function. (See [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._ How to use script here])&lt;br /&gt;
#Replace &amp;quot;SSSSS&amp;quot;, &amp;quot;GG&amp;quot;, &amp;quot;QQ&amp;quot; in the function call at the end with the survey ID, group ID and question ID respectively.&lt;br /&gt;
#If you want to apply it to more questions on the same page simply add more calls with the appropriate IDs. (eg. partRandDD(11111, 22, 1); partRandDD(11111, 22, 2); ...)&lt;br /&gt;
&lt;br /&gt;
Onload code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
   // Function to allow randomization of all answers&lt;br /&gt;
&lt;br /&gt;
   //except the last one in List/dropdown questions&lt;br /&gt;
&lt;br /&gt;
   function partRandDD(sID, gID, qID) {&lt;br /&gt;
&lt;br /&gt;
       // Find the number of answers&lt;br /&gt;
&lt;br /&gt;
       var ansCount = &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
       $( &#039;div#question&#039; + qID + &#039; select option&#039; ).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
           ansCount = i;&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // Place the last answer created at the end of the list&lt;br /&gt;
&lt;br /&gt;
$( &#039;option[value=&amp;quot;&#039; + ansCount + &#039;&amp;quot;]&#039; ).appendTo($( &#039;div#question&#039; + qID + &#039; select&#039; ));&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   // Call the function with the SID, GID and QID&lt;br /&gt;
&lt;br /&gt;
   partRandDD(89344, 72, 244);&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Partially Randomized Answers - Multiple numerical input=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, Safari 5.1&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround, similar to the ones above, allows the answers of Multiple numerical input questions to be randomized while always keeping one answer at the end of the list. It&#039;s useful if you want to randomize, say, the first 4 of your answers but always have the fifth displayed last.&lt;br /&gt;
&lt;br /&gt;
An onload function is placed in the source of a question. After the randomizing has occurred this function moves the answer with the highest answer code to the end of the list.&lt;br /&gt;
&lt;br /&gt;
A condition is that you must use sequential numbers, starting at 1 as response codes. (See image below)&lt;br /&gt;
&lt;br /&gt;
[[File:random_700x154.png]]&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#Turn off &#039;&#039;$filterxsshtml&#039;&#039; to allow insertion of JavaScript in the questions. (See [http://docs.limesurvey.org/tiki-index.php?page=Optional+settings&amp;amp;structure;=English+Instructions+for+LimeSurvey#Filtering_dangerous_HTML_tags_in_survey_objects documentation here])&lt;br /&gt;
#Create one or more Multiple numerical input question with sequential response codes. Set the [http://docs.limesurvey.org/tiki-index.php?page=Question+attributes&amp;amp;structure;=English+Instructions+for+LimeSurvey#random_order random_order question attribute] to 1.&lt;br /&gt;
#In the source of the first question add the following onload function. (See [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._ How to use script here])&lt;br /&gt;
#Replace &amp;quot;SSSSS&amp;quot;, &amp;quot;GG&amp;quot;, &amp;quot;QQ&amp;quot; in the function call at the end with the survey ID, group ID and question ID respectively.&lt;br /&gt;
#If you want to apply it to more questions on the same page simply add more calls with the appropriate IDs. (eg. partRandDD(11111, 22, 1); partRandDD(11111, 22, 2); ...)&lt;br /&gt;
&lt;br /&gt;
Onload code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Function to allow randomization of all answers except the last one in multiple numeric input questions&lt;br /&gt;
&lt;br /&gt;
       function partRand(sID, gID, qID) {&lt;br /&gt;
&lt;br /&gt;
           // Find the number of answers&lt;br /&gt;
&lt;br /&gt;
           var ansCount = &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
           $( &#039;div#question&#039; + qID + &#039; div.answers li&#039; ).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
               ansCount = (i - 1);&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Place the last answer created at the end of the list - but before the first helping sum&lt;br /&gt;
&lt;br /&gt;
           $( &#039;li#javatbd&#039; + sID + &#039;X&#039; + gID + &#039;X&#039; + qID + ansCount + &#039;&#039; ).insertBefore($( &#039;div#question&#039; + qID + &#039; div.answers li.multiplenumerichelp&#039; ).first());&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       // Call the function with the SID, GID and QID&lt;br /&gt;
&lt;br /&gt;
       partRand(SID, GID, QID);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using this solution for Multiple numerical input questions might be a bit more complicated than for other question types. All answers are organized in an unordered list (&amp;lt;ul&amp;gt;) structure. However, if advanced question settings like &#039;&#039;Equals sum value&#039;&#039; are used, LimeSurvey adds helping information (e.g. sum of all entries and remainder) to the same unordered list using the class &#039;&#039;multiplenumerichelp&#039;&#039; for these additional list items. The above example  assumes that at least one of these list items is present and moves the last answer to the position right above the first helper item. Without such advanced settings, the code will most certainly need adaptation.&lt;br /&gt;
&lt;br /&gt;
=Making one (or more) rows of an array mandatory=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 6/7, Firefox 3.0, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround allows you to define one or more rows of an array question as mandatory (instead of all of them which the &amp;quot;Mandatory&amp;quot; question setting does). It is [http://www.partnersinc.biz/surveys//index.php?sid=26842&amp;amp;newtest;=Y&amp;amp;lang;=en demonstrated here].&lt;br /&gt;
&lt;br /&gt;
A JavaScript function interrupts the submit function and checks if the inputs in the mandatory row(s) are populated. If not, an alert is popped up, the offending inputs are turned pink and the submit is aborted. Otherwise the submit goes ahead.&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#Turn off &#039;&#039;$filterxsshtml&#039;&#039; to allow insertion of JavaScript in the questions (see [http://docs.limesurvey.org/tiki-index.php?page=Optional+settings&amp;amp;structure;=English+Instructions+for+LimeSurvey#Filtering_dangerous_HTML_tags_in_survey_objects documentation here]).&lt;br /&gt;
#Create the array question.&lt;br /&gt;
#In the source of the array question add the following script (see [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._ How to use script here]).&lt;br /&gt;
#Modify the warningText (line10)as required.&lt;br /&gt;
#Replace &amp;quot;QQ&amp;quot; (lines 13 and 14)  with the question ID and add calls as necessary for more rows - the example code renders rows 1 and 3 mandatory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$(document).ready(function () {&lt;br /&gt;
&lt;br /&gt;
 // Interrupt the submit function&lt;br /&gt;
&lt;br /&gt;
 $(&#039;form#limesurvey&#039;).submit(function () {&lt;br /&gt;
&lt;br /&gt;
   // Override the built-in &amp;quot;disable navigation buttons&amp;quot; feature&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#moveprevbtn, #movenextbtn, #movesubmitbtn&#039;).attr(&#039;disabled&#039;, &#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
   var empty = 0;&lt;br /&gt;
&lt;br /&gt;
   var warningText = &#039;Please complete the highlighted inputs.&#039;;&lt;br /&gt;
&lt;br /&gt;
   // Call the mandatory row function with question IDs and row numbers&lt;br /&gt;
&lt;br /&gt;
   mandatoryRow(QQ, 1);&lt;br /&gt;
&lt;br /&gt;
   mandatoryRow(QQ, 3);&lt;br /&gt;
&lt;br /&gt;
   // A function to render rows of an array mandatory&lt;br /&gt;
&lt;br /&gt;
   function mandatoryRow(qID, rowNum) {&lt;br /&gt;
&lt;br /&gt;
     $(&#039;div#question&#039; + qID + &#039; table.question tbody[id&amp;lt;/div&amp;gt;=&amp;quot;javatbd&amp;quot;]:eq(&#039; + Number(rowNum - 1) + &#039;) input[type=&amp;quot;text&amp;quot;]&#039;).each(function (i) {&lt;br /&gt;
&lt;br /&gt;
       if ($(this).val() == &#039;&#039;) {&lt;br /&gt;
&lt;br /&gt;
         $(this).css(&#039;background-color&#039;, &#039;pink&#039;);&lt;br /&gt;
&lt;br /&gt;
         empty = 1;&lt;br /&gt;
&lt;br /&gt;
       } else {&lt;br /&gt;
&lt;br /&gt;
         $(this).css(&#039;background-color&#039;, &#039;#FFFFFF&#039;);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
     });&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   if (empty == 1) {&lt;br /&gt;
&lt;br /&gt;
     alert(warningText);&lt;br /&gt;
&lt;br /&gt;
     return false;&lt;br /&gt;
&lt;br /&gt;
   } else {&lt;br /&gt;
&lt;br /&gt;
     return true;&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Randomly displaying one of a few YouTube videos, and recording which was displayed=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested in 1.85+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Jason Cleeland has created and documented a method to randomly display one of a number of youtube videos in a single question, and save which one was displayed.&lt;br /&gt;
&lt;br /&gt;
http://www.aptigence.com.au/home/archives/23-Random-display-of-videos-in-a-question-2-YouTube.html&lt;br /&gt;
&lt;br /&gt;
=Randomly displaying one of a few pictures, and recording which was displayed=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested in 1.91+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The following steps allow you to randomly display one of a few pictures and record in the dataset which picture was displayed. We use four pictures in this example, but you can easily adapt these scripts according to your needs.&lt;br /&gt;
&lt;br /&gt;
1. Create a new sub-directory &#039;&#039;&#039;pic&#039;&#039;&#039; in your LimeSurvey folder.&lt;br /&gt;
&lt;br /&gt;
2. Copy four pictures (named &#039;&#039;1.jpg&#039;&#039;, &#039;&#039;2.jpg&#039;&#039;, &#039;&#039;3.jpg&#039;&#039;, and &#039;&#039;4.jpg&#039;&#039;) in this pic sub-directory.&lt;br /&gt;
&lt;br /&gt;
3. Deactivate the &#039;&#039;Filter HTML for XSS&#039;&#039; function in LimeSurvey&#039;s &#039;&#039;Global Settings&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
4. Create a &#039;&#039;&#039;Short free text&#039;&#039;&#039; question where you want these pictures to be displayed.&lt;br /&gt;
&lt;br /&gt;
5. Figure out the [http://docs.limesurvey.org/SGQA+identifier SGQA Identifier] of this question (e.g., 12345X67X89).&lt;br /&gt;
&lt;br /&gt;
6. Paste the following code as question text after activating the editor&#039;s &#039;&#039;Source&#039;&#039; view and replace both SSSSSXGGXQQ strings with your SGQA identifier:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please have a look at this picture:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$(document).ready(&lt;br /&gt;
&lt;br /&gt;
function(){&lt;br /&gt;
&lt;br /&gt;
// Find a random number (here between 1 and 4)&lt;br /&gt;
&lt;br /&gt;
var randNumber = Math.floor(Math.random()*4 + 1);&lt;br /&gt;
&lt;br /&gt;
// Save the number as answer of this question&lt;br /&gt;
&lt;br /&gt;
$(&#039;input#answerSSSSSXGGXQQ&#039;).val(randNumber);&lt;br /&gt;
&lt;br /&gt;
// Hide this answer field&lt;br /&gt;
&lt;br /&gt;
document.getElementById(&amp;quot;answerSSSSSXGGXQQ&amp;quot;).style.display=&#039;none&#039;;&lt;br /&gt;
&lt;br /&gt;
// Show the picture&lt;br /&gt;
&lt;br /&gt;
picString = &#039;&amp;lt;img src=&amp;quot;pic/&#039; + String(randNumber) + &#039;.jpg&amp;quot;&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
document.getElementById(&#039;pic&#039;).innerHTML = picString;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;pic&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to display the number of this picture in a later question, use the following code as question text (don&#039;t forget to replace the SSSSSXGGXQQ string acordingly):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You saw picture number {INSERTANS:SSSSSXGGXQQ}.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Perhaps you want to display the same picture again in a later question, but a little bit smaller (100px width, 100px height)? Just paste the following code as question text after activating the editor&#039;s &#039;&#039;Source&#039;&#039; view, and replace the SSSSSXGGXQQ string acordingly:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here you see the picture again: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$(document).ready(&lt;br /&gt;
&lt;br /&gt;
function(){&lt;br /&gt;
&lt;br /&gt;
// Get the picture number from previous question&lt;br /&gt;
&lt;br /&gt;
var randNumber = &amp;quot;{INSERTANS:SSSSSXGGXQQ}&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
// Show picture&lt;br /&gt;
&lt;br /&gt;
picString = &#039;&amp;lt;img width=&amp;quot;100&amp;quot; height=&amp;quot;100&amp;quot; src=&amp;quot;pic/&#039; + String(randNumber) + &#039;.jpg&amp;quot;&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
document.getElementById(&#039;pic&#039;).innerHTML = picString;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;pic&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Multiple numerical input with max_num_value defined in token (personalized limit)=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested in 1.85+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, max_num_value can be an experession, so you can simply enter the {TOKEN} or other variable in that question attribute.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To make personalized survey with multiple numerical input when max_num_value (Maximum sum value) is different for each user and is loaded from the token use following tricks:&lt;br /&gt;
*Create 1st group with numerical input field (1000X10X11). &amp;quot;Limit&amp;quot;&lt;br /&gt;
*Add java script into this question:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
function Custom_On_Load(){&lt;br /&gt;
&lt;br /&gt;
  document.getElementById(&#039;answer1000X10X11&#039;).value=&#039;{TOKEN:ATTRIBUTE_1}&#039;;&lt;br /&gt;
&lt;br /&gt;
  document.getElementById(&#039;answer1000X10X11&#039;).readOnly=1;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where:&lt;br /&gt;
&lt;br /&gt;
TOKEN:ATTRIBUTE_1 is individual limit defined in token.&lt;br /&gt;
&lt;br /&gt;
readOnly=1 // user shouldn&#039;t change it.&lt;br /&gt;
*Create 2nd group with multiple numerical input and add &amp;quot;Max value from SGQA&amp;quot; with 1000X10X11 as argument.&lt;br /&gt;
&lt;br /&gt;
Note: If you don&#039;t want to show first field with numerical input (and show definied limit in different way) you can add 2 lines to above script to hide whole question:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
document.getElementById(&#039;question85&#039;).style.display=&#039;none&#039;;&lt;br /&gt;
&lt;br /&gt;
document.getElementById(&#039;display85&#039;).value=&#039;&#039;;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where:&lt;br /&gt;
&lt;br /&gt;
question85 and display85 are field names.&lt;br /&gt;
&lt;br /&gt;
Note: It&#039;s no possible to create it into one group, because all SGQA references can only refer to data on a previous page because when clicking next the answer is stored at the DB and the SGQA is replaced by querying the database.&lt;br /&gt;
&lt;br /&gt;
=Default values in array questions=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.87+ (7557), IE 6/7, Firefox 3.5, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of Version 1.92, many more question types support default values.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround uses JavaScript to allow you to pre-check default answers in all sub-questions of an array type question. You can select a column of the array to be checked as the page loads. The script first checks to see if a sub-question has already been answered and, if not, checks the default answer.&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#[http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._ Set up your survey to use JavaScript].&lt;br /&gt;
#Create the array question.&lt;br /&gt;
#In the source of the array question add the following script.&lt;br /&gt;
#Replace&amp;quot;QQ&amp;quot; with the question ID and &amp;quot;CC&amp;quot; with the column number to be checked.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // A function to pre-check a column of an array&lt;br /&gt;
&lt;br /&gt;
       function checkedDefault(qID, column) {&lt;br /&gt;
&lt;br /&gt;
           var checkedCol = column - 1;&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039; + qID + &#039; table.question tbody tr&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
               if ($(&#039;input.radio[checked=true]&#039;, this).length == 0) {&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;input.radio:eq(&#039; + checkedCol + &#039;)&#039;, this).attr(&#039;checked&#039;, true);&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       // Call the function with a question ID and column number&lt;br /&gt;
&lt;br /&gt;
       checkedDefault(QQ, CC);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Record group view time=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.87+ (8518), IE 6/7, Firefox 3.5, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, group view time is accurately recorded in the timings table if you choose the Record Timings survey option.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround uses JavaScript to populate a hidden question with the total time that a respondent views a group. If used in a group with only one question, it could be used to track the amount of time required to answer the question.&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#[http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._ Set up your survey to use JavaScript].&lt;br /&gt;
#In the group, create a short-text question. We will hide this later with JavaScript and populate it with the elapsed time.&lt;br /&gt;
#Place the following script in the source of the short-text question.&lt;br /&gt;
#Replace &amp;quot;QQ&amp;quot; in line 6 with the ID of the short-text question.&lt;br /&gt;
&lt;br /&gt;
The script populates the hidden question with the elapsed time since the group was opened. If a respondent leaves the group and then returns, the timer continues up from the elapsed time of the last visit.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function(){&lt;br /&gt;
&lt;br /&gt;
       // call the functions with the hidden timer question ID&lt;br /&gt;
&lt;br /&gt;
       runTimer(QQ);&lt;br /&gt;
&lt;br /&gt;
       function runTimer(timeQID) {&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+timeQID).hide();&lt;br /&gt;
&lt;br /&gt;
           var initSec = &#039;0&#039;;&lt;br /&gt;
&lt;br /&gt;
           // Check for elapsed time from previous visits&lt;br /&gt;
&lt;br /&gt;
           if ($(&#039;#question&#039;+timeQID+&#039; input.text&#039;).val()) {&lt;br /&gt;
&lt;br /&gt;
               var initTime = $(&#039;#question&#039;+timeQID+&#039; input.text&#039;).val();&lt;br /&gt;
&lt;br /&gt;
               initTimeArr = initTime.split(&#039;:&#039;);&lt;br /&gt;
&lt;br /&gt;
               initSec = Number[[initTimeArr[0]*3600]]+Number[[initTimeArr[1]*60]]+Number(initTimeArr[2]);&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
           // Run the timer update function&lt;br /&gt;
&lt;br /&gt;
           recordTime(initSec, timeQID);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   // Timer update function&lt;br /&gt;
&lt;br /&gt;
   function recordTime(elapsedSec, timeQID){&lt;br /&gt;
&lt;br /&gt;
       elapsedSec++;&lt;br /&gt;
&lt;br /&gt;
       var h = Math.floor(elapsedSec / 3600);&lt;br /&gt;
&lt;br /&gt;
       var m = Math.floor(elapsedSec % 3600 / 60);&lt;br /&gt;
&lt;br /&gt;
       var s = Math.floor(elapsedSec % 3600 % 60);&lt;br /&gt;
&lt;br /&gt;
       var elapsedTime = [[h &amp;gt; 0 ? h + &amp;quot;:&amp;quot; : &amp;quot;00:&amp;quot;) + (m &amp;gt; 0 ? (m &amp;lt; 10 ? &amp;quot;0&amp;quot; : &amp;quot;&amp;quot;) + m + &amp;quot;:&amp;quot; : &amp;quot;00:&amp;quot;) + (s &amp;lt; 10 ? &amp;quot;0&amp;quot; : &amp;quot;&amp;quot;) + s);&lt;br /&gt;
&lt;br /&gt;
        $(&#039;#question&#039;+timeQID+&#039; input.text&#039;).val(elapsedTime);&lt;br /&gt;
&lt;br /&gt;
        // Run the timer update function every second&lt;br /&gt;
&lt;br /&gt;
        setTimeout(&#039;recordTime(&#039;+elapsedSec+&#039;, &#039;+timeQID+&#039;)&#039;,1000);&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 =Toggle visibility of groups=&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with: 1.90+, IE 6/7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;Version 1.92 supports group-level relevance, making this workaround obsolete.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 This workaround uses JavaScript to toggle the visibility of groups in an &amp;quot;all in one&amp;quot; survey. Initially the groups are hidden and there are links inserted to display the groups. It&#039;s useful to avoid the page being cluttered with many groups and lets the respondent focus on one at a time.&lt;br /&gt;
&lt;br /&gt;
 It&#039;s [http://www.partnersinc.biz/surveys//index.php?sid=33613&amp;amp;newtest;=Y&amp;amp;lang;=en|demonstrated here].&lt;br /&gt;
&lt;br /&gt;
 Implementation is as follows:&lt;br /&gt;
&lt;br /&gt;
 #[http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._|Set up your survey to use JavaScript].&lt;br /&gt;
&lt;br /&gt;
 #Set the survey to run in &amp;quot;all in one&amp;quot; mode.&lt;br /&gt;
&lt;br /&gt;
 #Add your groups and questions.&lt;br /&gt;
&lt;br /&gt;
 #Place the following script in the source of one of the questions in the first group.&lt;br /&gt;
&lt;br /&gt;
 The comments in the script are pretty self-explanatory but it does the following:&lt;br /&gt;
&lt;br /&gt;
 #initially hides all of the groups&lt;br /&gt;
&lt;br /&gt;
 #inserts a link above each one to toggle its display&lt;br /&gt;
&lt;br /&gt;
 #some styles are added to the clickable links but these could be done in template.css instead&lt;br /&gt;
&lt;br /&gt;
 #shows any groups that have an unanswered mandatory after a submit attempt&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    $(document).ready(function(){&lt;br /&gt;
&lt;br /&gt;
       // Insert show/hide elements before all group wrapper divs&lt;br /&gt;
&lt;br /&gt;
        $(&#039;&amp;lt;div class=&amp;quot;groupToggler&amp;quot;&amp;gt;&amp;lt;span&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;/div&amp;gt;&#039;).insertBefore(&#039;div[id&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&amp;quot;group-&amp;quot;]&#039;);&lt;br /&gt;
&lt;br /&gt;
        // Add some text to the show/hide elements&lt;br /&gt;
&lt;br /&gt;
        $(&#039;.groupToggler span&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
            ($( this ).text(&#039;Show/Hide Group &#039;+(i+1)+&#039;&#039;]];&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // Add some styles to the show/hide elements&lt;br /&gt;
&lt;br /&gt;
       $(&#039;.groupToggler&#039;).css({&lt;br /&gt;
&lt;br /&gt;
           &#039;padding&#039;:&#039;5px 0 10px 0&#039;,&lt;br /&gt;
&lt;br /&gt;
           &#039;text-align&#039;:&#039;center&#039;&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       $(&#039;.groupToggler span&#039;).css({&lt;br /&gt;
&lt;br /&gt;
           &#039;text-decoration&#039;:&#039;underline&#039;,&lt;br /&gt;
&lt;br /&gt;
           &#039;cursor&#039;:&#039;pointer&#039;&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // Add some hover effects to the show/hide elements&lt;br /&gt;
&lt;br /&gt;
       $(&amp;quot;.groupToggler span&amp;quot;).hover(&lt;br /&gt;
&lt;br /&gt;
           function () {&lt;br /&gt;
&lt;br /&gt;
               $(this).css({&lt;br /&gt;
&lt;br /&gt;
                   &#039;text-decoration&#039;:&#039;none&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;font-weight&#039;:&#039;bold&#039;&lt;br /&gt;
&lt;br /&gt;
               });&lt;br /&gt;
&lt;br /&gt;
           },&lt;br /&gt;
&lt;br /&gt;
           function () {&lt;br /&gt;
&lt;br /&gt;
               $(this).css({&lt;br /&gt;
&lt;br /&gt;
                   &#039;text-decoration&#039;:&#039;underline&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;font-weight&#039;:&#039;normal&#039;&lt;br /&gt;
&lt;br /&gt;
               });&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       );&lt;br /&gt;
&lt;br /&gt;
       // Initially hide all of the groups&lt;br /&gt;
&lt;br /&gt;
       // Toggle their visibility when the show/hide element is clicked&lt;br /&gt;
&lt;br /&gt;
       $(&#039;.groupToggler span&#039;).click(function() {&lt;br /&gt;
&lt;br /&gt;
           $(this).parent().next().toggle();&lt;br /&gt;
&lt;br /&gt;
           return false;&lt;br /&gt;
&lt;br /&gt;
       }).parent().next().hide();&lt;br /&gt;
&lt;br /&gt;
       // Display any groups that have unanswered mandatories&lt;br /&gt;
&lt;br /&gt;
       $(&#039;.errormandatory&#039;).parents(&#039;div[id&amp;lt;/div&amp;gt;=&amp;quot;group-&amp;quot;]&#039;).show();&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Use jQuery Autocomplete plugin to suggest answers for text inputs=&lt;br /&gt;
&lt;br /&gt;
== 1.90 and previous versions==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 6/7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround uses the [http://docs.jquery.com/Plugins/Autocomplete jQuery Autocomplete] plugin to provide a respondent a list of suggested answers that the they can select from as they type in a text input.&lt;br /&gt;
&lt;br /&gt;
Although the plugin allows for much more complex applications, the two that I use most frequently are outlined below. The first method uses a relatively small list of suggestions that is stored in an array locally. The second is a little more complex - it uses a remote CSV file of suggestions that is accessed through AJAX an PHP.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve put together a small demonstration [http://www.partnersinc.biz/surveys//index.php?sid=78611&amp;amp;newtest;=Y&amp;amp;lang;=en here] and implementation is as follows.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Both methods:&#039;&#039;&#039;&lt;br /&gt;
*[http://docs.jquery.com/Plugins/Autocomplete Download the plugin]&lt;br /&gt;
*Place the files &#039;&#039;jquery.autocomplete.css&#039;&#039; and &#039;&#039;jquery.autocomplete.js&#039;&#039; in your template directory&lt;br /&gt;
*Add the following code inside the &amp;lt;head&amp;gt; element of startpage.pstpl&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;{TEMPLATEURL}jquery.autocomplete.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;link rel=&amp;quot;stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot; href=&amp;quot;{TEMPLATEURL}jquery.autocomplete.css&amp;quot; /&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Method 1 (&amp;quot;States&amp;quot; question in the demo):&#039;&#039;&#039;&lt;br /&gt;
*Create a text input question&lt;br /&gt;
*Add the following script to the source of the text question&lt;br /&gt;
*Replace &amp;quot;QQ&amp;quot; with the ID of the text input question&lt;br /&gt;
*Replace the states with your list of suggestions (comma separated)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       var q1ID = QQ;&lt;br /&gt;
&lt;br /&gt;
       var states = &amp;quot;Alabama,Alaska,Arizona,Arkansas,California,Colorado,Connecticut,Delaware,&lt;br /&gt;
&lt;br /&gt;
       District of Columbia,Florida,Georgia,Hawaii,Idaho,Illinois,Indiana,Iowa,Kansas,Kentucky,&lt;br /&gt;
&lt;br /&gt;
       Louisiana,Maine,Montana,Nebraska,Nevada,New Hampshire,New Jersey,New Mexico,New York,&lt;br /&gt;
&lt;br /&gt;
       North Carolina,North Dakota,Ohio,Oklahoma,Oregon,Maryland,Massachusetts,Michigan,&lt;br /&gt;
&lt;br /&gt;
       Minnesota,Mississippi,Missouri,Pennsylvania,Rhode Island,South Carolina,South Dakota,&lt;br /&gt;
&lt;br /&gt;
       Tennessee,Texas,Utah,Vermont,Virginia,Washington,West Virginia,Wisconsin,Wyoming&amp;quot;.split(&#039;,&#039;);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q1ID+&#039; input.text&#039;).autocomplete(states, {&lt;br /&gt;
&lt;br /&gt;
           matchContains: true,&lt;br /&gt;
&lt;br /&gt;
           minChars: 0&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Method 2 (&amp;quot;Countries&amp;quot; question in the demo):&#039;&#039;&#039;&lt;br /&gt;
*Place the CSV file of suggestions in your template directory (you can download my demo CSV [http://www.partnersinc.biz/surveys/templates/default_autocompleting_input/countries2.csv here])&lt;br /&gt;
*Place a PHP file containing the code below in your template directory&lt;br /&gt;
*Replace &amp;quot;countries2.csv&amp;quot; with your CSV filename (you could make this more universal by passing the filename in the URL)&lt;br /&gt;
*This file will grab the contents of the CSV and encode them in JSON format that the JavaScript can use&lt;br /&gt;
*Place the JavaScript code below in ths source of the text question&lt;br /&gt;
*Replace &amp;quot;QQ&amp;quot; with the ID of the text input question&lt;br /&gt;
*Replace &amp;quot;templates/yourTemplate/countries.php&amp;quot; with the path to the PHP file (from LimeSurvey root)&lt;br /&gt;
*This script will grab the jsonized data from the PHP file and load it into an array that the plugin can use&lt;br /&gt;
&lt;br /&gt;
PHP code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
   $countriesArr = array();&lt;br /&gt;
&lt;br /&gt;
   $file_handle = fopen(&amp;quot;countries2.csv&amp;quot;, &amp;quot;r&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
   while (!feof($file_handle) ) {&lt;br /&gt;
&lt;br /&gt;
       $line_of_text = fgetcsv($file_handle);&lt;br /&gt;
&lt;br /&gt;
       array_push($countriesArr, $line_of_text[0]);&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   fclose($file_handle);&lt;br /&gt;
&lt;br /&gt;
   echo json_encode($countriesArr);&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
JavaScript code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       var qID = QQ;&lt;br /&gt;
&lt;br /&gt;
       var url = &amp;quot;templates/yourTemplate/countries.php&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
       var countriesArr = new Array();&lt;br /&gt;
&lt;br /&gt;
       $.getJSON(url,function(data){&lt;br /&gt;
&lt;br /&gt;
           $(data).each(function(i, item){&lt;br /&gt;
&lt;br /&gt;
               countriesArr.push(item);&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qID+&#039; input.text&#039;).autocomplete(countriesArr, {&lt;br /&gt;
&lt;br /&gt;
               matchContains: true,&lt;br /&gt;
&lt;br /&gt;
               minChars: 0&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 1.91 and later versions==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.91+, IE 6/7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround uses the [http://jqueryui.com/demos/autocomplete/ Autocomplete widget] included with jQuery UI to provide a respondent a list of suggested answers that the they can select from as they type in a text input.&lt;br /&gt;
&lt;br /&gt;
Although the plugin allows for much more complex applications, the two that I use most frequently are outlined below. The first method uses a relatively small list of suggestions that is stored in an array locally. The second is a little more complex - it uses a remote CSV file of suggestions that is accessed through AJAX an PHP.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Both methods:&#039;&#039;&#039;&lt;br /&gt;
*Add the following styles to the end of your &#039;template.css&#039; file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;/* Autocomplete styles */&lt;br /&gt;
&lt;br /&gt;
ul.ui-autocomplete {&lt;br /&gt;
&lt;br /&gt;
   width: 250px !important;&lt;br /&gt;
&lt;br /&gt;
   padding: 5px 10px;&lt;br /&gt;
&lt;br /&gt;
   list-style: none;&lt;br /&gt;
&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Method 1 (use local JavaScript array for data):&#039;&#039;&#039;&lt;br /&gt;
*Create a text input question&lt;br /&gt;
*Add the following script to the source of the text question&lt;br /&gt;
*Replace &amp;quot;QQ&amp;quot; with the ID of the text input question&lt;br /&gt;
*Replace the states with your list of suggestions (comma separated)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       var q1ID = QQ;&lt;br /&gt;
&lt;br /&gt;
       var states = &amp;quot;Alabama,Alaska,Arizona,Arkansas,California,Colorado,Connecticut,Delaware,&lt;br /&gt;
&lt;br /&gt;
       District of Columbia,Florida,Georgia,Hawaii,Idaho,Illinois,Indiana,Iowa,Kansas,Kentucky,&lt;br /&gt;
&lt;br /&gt;
       Louisiana,Maine,Montana,Nebraska,Nevada,New Hampshire,New Jersey,New Mexico,New York,&lt;br /&gt;
&lt;br /&gt;
       North Carolina,North Dakota,Ohio,Oklahoma,Oregon,Maryland,Massachusetts,Michigan,&lt;br /&gt;
&lt;br /&gt;
       Minnesota,Mississippi,Missouri,Pennsylvania,Rhode Island,South Carolina,South Dakota,&lt;br /&gt;
&lt;br /&gt;
       Tennessee,Texas,Utah,Vermont,Virginia,Washington,West Virginia,Wisconsin,Wyoming&amp;quot;.split(&#039;,&#039;);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q1ID+&#039; input.text&#039;).autocomplete({&lt;br /&gt;
&lt;br /&gt;
           source: states&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Method 2 (use remote CSV file for data):&#039;&#039;&#039;&lt;br /&gt;
*Place the CSV file of suggestions in your template directory (you can download my demo CSV [http://www.partnersinc.biz/surveys/templates/default_autocompleting_input/countries2.csv here])&lt;br /&gt;
*Place a PHP file containing the code below in your template directory&lt;br /&gt;
*Replace &amp;quot;countries2.csv&amp;quot; with your CSV filename (you could make this more universal by passing the filename in the URL)&lt;br /&gt;
*This file will grab the contents of the CSV and encode them in JSON format that the JavaScript can use&lt;br /&gt;
*Place the JavaScript code below in ths source of the text question&lt;br /&gt;
*Replace &amp;quot;QQ&amp;quot; with the ID of the text input question&lt;br /&gt;
*Replace &amp;quot;templates/yourTemplate/countries.php&amp;quot; with the path to the PHP file (from LimeSurvey root)&lt;br /&gt;
*This script will grab the jsonized data from the PHP file and load it into an array that the plugin can use&lt;br /&gt;
&lt;br /&gt;
PHP code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
   $countriesArr = array();&lt;br /&gt;
&lt;br /&gt;
   $file_handle = fopen(&amp;quot;countries2.csv&amp;quot;, &amp;quot;r&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
   while (!feof($file_handle) ) {&lt;br /&gt;
&lt;br /&gt;
       $line_of_text = fgetcsv($file_handle);&lt;br /&gt;
&lt;br /&gt;
       array_push($countriesArr, $line_of_text[0]);&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   fclose($file_handle);&lt;br /&gt;
&lt;br /&gt;
   echo json_encode($countriesArr);&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
JavaScript code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
       $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       var qID = QQ;&lt;br /&gt;
&lt;br /&gt;
       var url = &amp;quot;templates/yourTemplate/countries.php&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
       var dataArr = [];&lt;br /&gt;
&lt;br /&gt;
       $.getJSON(url,function(data){&lt;br /&gt;
&lt;br /&gt;
           $.each(data,function(i, item){&lt;br /&gt;
&lt;br /&gt;
               dataArr.push(item);&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
          $(&#039;#question&#039;+qID+&#039; input.text&#039;).autocomplete({&lt;br /&gt;
&lt;br /&gt;
               source: dataArr&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Use autocomplete to populate several fields==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.91+, IE 7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround uses the [http://jqueryui.com/demos/autocomplete/ Autocomplete widget] included with jQuery UI and the [http://plugins.jquery.com/project/csv jquery.csv.js] plugin to provide a respondent with a list of suggested answers as they type in a text input and then to automatically populate other fields depending on the selection.&lt;br /&gt;
&lt;br /&gt;
For example, if you have 3 questions - &amp;quot;Name&amp;quot;, &amp;quot;ID&amp;quot; and &amp;quot;Email&amp;quot; - you can use this workaround to autocomplete the &amp;quot;Name&amp;quot; question and then the &amp;quot;ID&amp;quot; and &amp;quot;Email&amp;quot; questions can be automatically populated with values associated with the selected name.&lt;br /&gt;
*Download the [http://plugins.jquery.com/project/csv jquery.csv.js] plugin and place it in your template folder&lt;br /&gt;
*Add the following line to your startpage.pstpl BEFORE the tag for template.js&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;{TEMPLATEURL}jquery.csv.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
*Create your CSV file with 3 columns (name, ID, email) as in this example and place it in your template folder&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;Bob,    Bob&#039;s ID,    Bob&#039;s email&lt;br /&gt;
&lt;br /&gt;
Andy,    Andy&#039;s ID,    Andy&#039;s email&lt;br /&gt;
&lt;br /&gt;
Sam,    Sam&#039;s ID,    Sam&#039;s email&lt;br /&gt;
&lt;br /&gt;
Tony,    Tony&#039;s ID,    Tony&#039;s email&lt;br /&gt;
&lt;br /&gt;
Fred,    Fred&#039;s ID,    Fred&#039;s email&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
*Create your 3 questions - &amp;quot;Name&amp;quot;, &amp;quot;ID&amp;quot; and &amp;quot;Email&amp;quot;. They must be in the same group/page.&lt;br /&gt;
*Add the following styles to the end of your &#039;template.css&#039; file&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;/* Autocomplete styles */&lt;br /&gt;
&lt;br /&gt;
ul.ui-autocomplete {&lt;br /&gt;
&lt;br /&gt;
   width: 250px !important;&lt;br /&gt;
&lt;br /&gt;
   padding: 5px 10px;&lt;br /&gt;
&lt;br /&gt;
   list-style: none;&lt;br /&gt;
&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
*Add the following script to the source of one of the questions&lt;br /&gt;
*Replace:&lt;br /&gt;
**&amp;quot;NN&amp;quot; with the &amp;quot;Name&amp;quot; question ID&lt;br /&gt;
**&amp;quot;II&amp;quot; with the &amp;quot;ID&amp;quot; question ID&lt;br /&gt;
**&amp;quot;EE&amp;quot; with the &amp;quot;Email&amp;quot; question ID&lt;br /&gt;
*Modify the path to your CSV file&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       var qNameID = NN;&lt;br /&gt;
&lt;br /&gt;
       var qIDID = II;&lt;br /&gt;
&lt;br /&gt;
       var qEmailID = EE;&lt;br /&gt;
&lt;br /&gt;
       var url = &amp;quot;upload/templates/yourTemplate/yourCsvFile.csv&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
       // Create an array to hold the names&lt;br /&gt;
&lt;br /&gt;
       var namesArr = new Array();&lt;br /&gt;
&lt;br /&gt;
       // Grab the CSV contents&lt;br /&gt;
&lt;br /&gt;
       $.get(url,function(data){&lt;br /&gt;
&lt;br /&gt;
           // Convert CSV contents to an array of arrays&lt;br /&gt;
&lt;br /&gt;
           fullArray = jQuery.csv()(data);&lt;br /&gt;
&lt;br /&gt;
           // Load the names array&lt;br /&gt;
&lt;br /&gt;
           $(fullArray).each(function(i, item){&lt;br /&gt;
&lt;br /&gt;
               namesArr.push(item[0]);&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Initialise the autocomplete plugin&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qNameID+&#039; input.text&#039;).autocomplete({&lt;br /&gt;
&lt;br /&gt;
               source: namesArr,&lt;br /&gt;
&lt;br /&gt;
               // Event fired when a selection is made (ui.item.value refers to the selected item)&lt;br /&gt;
&lt;br /&gt;
               select: function(event, ui) {&lt;br /&gt;
&lt;br /&gt;
                   // Find the &amp;quot;ID&amp;quot; and &amp;quot;Email&amp;quot; values associated with the selected name value and load those questions&lt;br /&gt;
&lt;br /&gt;
                   $(fullArray).each(function(i, item){&lt;br /&gt;
&lt;br /&gt;
                       if(item[0] == ui.item.value) {&lt;br /&gt;
&lt;br /&gt;
                           // The value from column 2 of the CSV&lt;br /&gt;
&lt;br /&gt;
                           $(&#039;#question&#039;+qIDID+&#039; input.text&#039;).val(item[1]);&lt;br /&gt;
&lt;br /&gt;
                           // The value from column 3 of the CSV&lt;br /&gt;
&lt;br /&gt;
                           $(&#039;#question&#039;+qEmailID+&#039; input.text&#039;).val(item[2]);&lt;br /&gt;
&lt;br /&gt;
                       }&lt;br /&gt;
&lt;br /&gt;
                   });&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Drag and Drop Rankings=&lt;br /&gt;
&lt;br /&gt;
==Drag and Drop Ranking - Version 1.90 and newer==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+ &amp;amp; 1.91RC4, IE 6/7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround is a modification of the workaround below and also uses [http://jqueryui.com/demos/sortable/#connect-lists JQuery connected sortables]. Thanks to the author of that workaround.&lt;br /&gt;
&lt;br /&gt;
[[File:Untitled-12.png]]&lt;br /&gt;
&lt;br /&gt;
Modifications include:&lt;br /&gt;
*Allow for multiple drag-n-drop ranking questions on a page&lt;br /&gt;
*Handle minimum and maximum answers settings&lt;br /&gt;
*Allow double clicking of items to add or remove them from the ranking list&lt;br /&gt;
*Work with the new shipped jQuery UI&lt;br /&gt;
&lt;br /&gt;
There is a &#039;&#039;&#039;[http://www.partnersinc.biz/surveys//index.php?sid=36981&amp;amp;newtest;=Y&amp;amp;lang;=en demonstrated here]&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_ Set up your survey to use JavaScript].&lt;br /&gt;
#Place the large script below in your template.js file.&lt;br /&gt;
#Place the small script below in the source a ranking question, (this applies the &amp;quot;dragDropRank&amp;quot; function to the question). Replace &amp;quot;QQ&amp;quot; with the ranking [http://docs.limesurvey.org/SGQA+identifier&amp;amp;structure;=English+Instructions+for+LimeSurvey#General_Description question ID].&lt;br /&gt;
**Note: the LimeSurvey translations will be automatically used for the &amp;quot;Choices&amp;quot; and &amp;quot;Rankings&amp;quot; header labels but can be overridden with custom labels - see the example calls below.&lt;br /&gt;
#Insert the CSS below at the end of template.css (these styles are for the default template).&lt;br /&gt;
&lt;br /&gt;
NOTE: I have not tested this workaround with conditions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Code for template.js:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
function dragDropRank(qID, choiceText, rankText) {&lt;br /&gt;
&lt;br /&gt;
   if(!choiceText) {&lt;br /&gt;
&lt;br /&gt;
       choiceText = $(&#039;#question&#039;+qID+&#039; td.label label&#039;).text();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   if(!rankText) {&lt;br /&gt;
&lt;br /&gt;
       rankText = $(&#039;#question&#039;+qID+&#039; td.output tr:first td:eq(1)&#039;).text();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   //Add a class to the question&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#question&#039;+qID+&#039;&#039;).addClass(&#039;dragDropRanking&#039;);&lt;br /&gt;
&lt;br /&gt;
   // Hide the original question in LimeSurvey (so that we can replace with drag and drop)&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#question&#039;+qID+&#039; .rank, #question&#039;+qID+&#039; .questionhelp&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
   // Turn off display of question (to override error checking built into LimeSurvey ranking question)&lt;br /&gt;
&lt;br /&gt;
   //$(&#039;#display&#039;+qID).val(&#039;off&#039;);&lt;br /&gt;
&lt;br /&gt;
   // Add connected sortables elements to the question&lt;br /&gt;
&lt;br /&gt;
   var htmlCode = &#039;&amp;lt;table class=&amp;quot;dragDropTable&amp;quot;&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
       &amp;lt;tbody&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
           &amp;lt;tr&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
               &amp;lt;td&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                   &amp;lt;span class=&amp;quot;dragDropHeader choicesLabel&amp;quot;&amp;gt;&#039;+choiceText+&#039;&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                   &amp;lt;div class=&amp;quot;ui-state-highlight dragDropChoices&amp;quot;&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                       &amp;lt;ul id=&amp;quot;sortable1&#039;+qID+&#039;&amp;quot; class=&amp;quot;connectedSortable&#039;+qID+&#039; dragDropChoiceList&amp;quot;&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                           &amp;lt;li&amp;gt;Choices&amp;lt;/li&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                       &amp;lt;/ul&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                   &amp;lt;/div&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
               &amp;lt;/td&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
               &amp;lt;td&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                   &amp;lt;span class=&amp;quot;dragDropHeader rankingLabel&amp;quot;&amp;gt;&#039;+rankText+&#039;&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                   &amp;lt;div class=&amp;quot;ui-state-highlight dragDropRanks&amp;quot;&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                       &amp;lt;ol id=&amp;quot;sortable2&#039;+qID+&#039;&amp;quot; class=&amp;quot;connectedSortable&#039;+qID+&#039; dragDropRankList&amp;quot;&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                           &amp;lt;li&amp;gt;Ranks&amp;lt;/li&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                       &amp;lt;/ol&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                   &amp;lt;/div&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
               &amp;lt;/td&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
           &amp;lt;/tr&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
       &amp;lt;/tbody&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                   &amp;lt;/table&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
   $(htmlCode).insertAfter(&#039;#question&#039;+qID+&#039; table.rank&#039;);&lt;br /&gt;
&lt;br /&gt;
   // Remove placeholder list items (have to have one item so that LimeSurvey doesn&amp;quot;t remove the &amp;lt;ul&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#sortable1&#039;+qID+&#039; li, #sortable2&#039;+qID+&#039; li&#039;).remove();&lt;br /&gt;
&lt;br /&gt;
   // Load any previously-set values&lt;br /&gt;
&lt;br /&gt;
   loadDragDropRank(qID);&lt;br /&gt;
&lt;br /&gt;
   // Find the number of LimeSurvey ranking inputs (&amp;quot;Maximum answers&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
   var maxAnswer = $(&#039;#question&#039;+qID+&#039; td.output input.text&#039;).length;&lt;br /&gt;
&lt;br /&gt;
   // Set up the connected sortable&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#sortable1&#039;+qID+&#039;, #sortable2&#039;+qID+&#039;&#039;).sortable({&lt;br /&gt;
&lt;br /&gt;
       connectWith: &#039;.connectedSortable&#039;+qID+&#039;&#039;,&lt;br /&gt;
&lt;br /&gt;
       placeholder: &#039;ui-sortable-placeholder&#039;,&lt;br /&gt;
&lt;br /&gt;
       helper: &#039;clone&#039;,&lt;br /&gt;
&lt;br /&gt;
       revert: 50,&lt;br /&gt;
&lt;br /&gt;
       receive: function(event, ui) {&lt;br /&gt;
&lt;br /&gt;
           if($(&#039;#sortable2&#039;+qID+&#039; li&#039;).length &amp;gt; maxAnswer) {&lt;br /&gt;
&lt;br /&gt;
               alert (&#039;You can only rank a maximum of &#039;+maxAnswer+&#039; choices.&#039;);&lt;br /&gt;
&lt;br /&gt;
               $(ui.sender).sortable(&#039;cancel&#039;);&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       },&lt;br /&gt;
&lt;br /&gt;
       stop: function(event, ui) {&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#sortable1&#039;+qID+&#039;&#039;).sortable(&#039;refresh&#039;);&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#sortable2&#039;+qID+&#039;&#039;).sortable(&#039;refresh&#039;);&lt;br /&gt;
&lt;br /&gt;
           updateDragDropRank(qID);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   }).disableSelection();&lt;br /&gt;
&lt;br /&gt;
   // Get the list of choices from the LimeSurvey question and copy them as items into the sortable choices list&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#CHOICES_&#039; + qID).children().each(function(index, Element) {&lt;br /&gt;
&lt;br /&gt;
       var liCode = &#039;&amp;lt;li class=&amp;quot;ui-state-default&amp;quot; id=&amp;quot;choice_&#039; + $(this).attr(&amp;quot;value&amp;quot;) + &#039;&amp;quot;&amp;gt;&#039; + this.text + &#039;&amp;lt;/li&amp;gt;&#039;&lt;br /&gt;
&lt;br /&gt;
       $(liCode).appendTo(&#039;#sortable1&#039;+qID+&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   // Allow users to double click to move to selections from list to list&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#sortable1&#039;+qID+&#039; li&#039;).live(&#039;dblclick&#039;, function() {&lt;br /&gt;
&lt;br /&gt;
       if($(&#039;#sortable2&#039;+qID+&#039; li&#039;).length == maxAnswer) {&lt;br /&gt;
&lt;br /&gt;
           alert (&#039;You can only rank a maximum of &#039;+maxAnswer+&#039; choices.&#039;);&lt;br /&gt;
&lt;br /&gt;
           return false;&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       else {&lt;br /&gt;
&lt;br /&gt;
           $(this).appendTo(&#039;#sortable2&#039;+qID+&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#sortable1&#039;+qID+&#039;&#039;).sortable(&#039;refresh&#039;);&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#sortable2&#039;+qID+&#039;&#039;).sortable(&#039;refresh&#039;);&lt;br /&gt;
&lt;br /&gt;
           updateDragDropRank(qID);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#sortable2&#039;+qID+&#039; li&#039;).live(&#039;dblclick&#039;, function() {&lt;br /&gt;
&lt;br /&gt;
       $(this).appendTo(&#039;#sortable1&#039;+qID+&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#sortable2&#039;+qID+&#039;&#039;).sortable(&#039;refresh&#039;);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#sortable1&#039;+qID+&#039;&#039;).sortable(&#039;refresh&#039;);&lt;br /&gt;
&lt;br /&gt;
       updateDragDropRank(qID);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// This function copies the drag and drop sortable data into the LimeSurvey ranking list.&lt;br /&gt;
&lt;br /&gt;
function updateDragDropRank(qID)&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   // Reload the LimeSurvey choices select element&lt;br /&gt;
&lt;br /&gt;
   var rankees = [];&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#sortable2&#039;+qID+&#039; li&#039;).each(function(index) {&lt;br /&gt;
&lt;br /&gt;
       $(this).attr(&#039;value&#039;, index+1);&lt;br /&gt;
&lt;br /&gt;
       // Get value of ranked item&lt;br /&gt;
&lt;br /&gt;
       var liID = $(this).attr(&amp;quot;id&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
       liIDArray = liID.split(&#039;_&#039;);&lt;br /&gt;
&lt;br /&gt;
       // Save to an array&lt;br /&gt;
&lt;br /&gt;
       rankees[rankees.length] = { &amp;quot;r_name&amp;quot;:$(this).text(),&amp;quot;r_value&amp;quot;:liIDArray[1] };&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#question&#039;+qID+&#039; input[name&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&amp;quot;RANK_&amp;quot;]&#039;).each(function(index) {&lt;br /&gt;
&lt;br /&gt;
       if (rankees.length &amp;gt; index) {&lt;br /&gt;
&lt;br /&gt;
           $(this).val(rankees[index].r_name);&lt;br /&gt;
&lt;br /&gt;
           //alert (rankees[index].r_value);&lt;br /&gt;
&lt;br /&gt;
           $(this).next(&#039;input&#039;).attr(&#039;value&#039;, rankees[index].r_value);&lt;br /&gt;
&lt;br /&gt;
       } else {&lt;br /&gt;
&lt;br /&gt;
           $(this).val(&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
           $(this).next().val(&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
     });&lt;br /&gt;
&lt;br /&gt;
   // Reload the LimeSurvey choices select element (we need this for &amp;quot;Minimum answers&amp;quot; code)&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#question&#039;+qID+&#039; td.label select option&#039;).remove();&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#sortable1&#039;+qID+&#039; li&#039;).each(function(index) {&lt;br /&gt;
&lt;br /&gt;
       var liText = $(this).text();&lt;br /&gt;
&lt;br /&gt;
       var liID = $(this).attr(&#039;id&#039;);&lt;br /&gt;
&lt;br /&gt;
       liIDArray = liID.split(&#039;_&#039;);&lt;br /&gt;
&lt;br /&gt;
       var optionCode = &#039;&amp;lt;option value=&amp;quot;&#039;+liIDArray[1]+&#039;&amp;quot;&amp;gt;&#039;+liText+&#039;&amp;lt;/option&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
       $(optionCode).appendTo(&#039;#question&#039;+qID+&#039; td.label select&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   // Hack for IE6&lt;br /&gt;
&lt;br /&gt;
   if ($.browser.msie &amp;amp;&amp;amp; $.browser.version.substr(0,1)&amp;lt;7) {&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+qID+&#039; select&#039;).show();&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+qID+&#039; select&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// This function is called on page load to see if there are any items already ranked (from a previous visit&lt;br /&gt;
&lt;br /&gt;
// or cached due to a page change.  If so, the already-ranked items are loaded into the sortable list&lt;br /&gt;
&lt;br /&gt;
function loadDragDropRank(qID)&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   var rankees = [];&lt;br /&gt;
&lt;br /&gt;
   // Loop through each item in the built-in LimeSurvey ranking list looking for non-empty values&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#question&#039;+qID+&#039; input[name&amp;lt;/div&amp;gt;=&amp;quot;RANK_&amp;quot;]&#039;).each(function(index) {&lt;br /&gt;
&lt;br /&gt;
       // Check to see if the current item has a value&lt;br /&gt;
&lt;br /&gt;
       if ($(this).val()) {&lt;br /&gt;
&lt;br /&gt;
           // Item has a value - save to the array&lt;br /&gt;
&lt;br /&gt;
           // Use this element to contain the name and the next for the value (numeric)&lt;br /&gt;
&lt;br /&gt;
           rankees[rankees.length] = { &amp;quot;r_name&amp;quot;:$(this).val(),&amp;quot;r_value&amp;quot;:$(this).next().val() };&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   // Now that we have a list of all the pre-ranked items, populate the sortable list&lt;br /&gt;
&lt;br /&gt;
   // Note that the items *won&amp;quot;t* appear in the main list because LimeSurvey has removed them.&lt;br /&gt;
&lt;br /&gt;
   $.each(rankees, function(index, value) {&lt;br /&gt;
&lt;br /&gt;
       // Create the items in the sortable&lt;br /&gt;
&lt;br /&gt;
       var liCode = &#039;&amp;lt;li class=&amp;quot;ui-state-default&amp;quot; id=&amp;quot;choice_&#039; + value.r_value + &#039;&amp;quot;&amp;gt;&#039; + value.r_name + &#039;&amp;lt;/li&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
       $(liCode).appendTo(&#039;#sortable2&#039;+qID+&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Code in the source of the question(s) using the LimeSurvey translations for the &amp;quot;Choices&amp;quot; and &amp;quot;Rankings&amp;quot; element header labels&#039;&#039;&#039; (replace &amp;quot;QQ&amp;quot; with the ranking [http://docs.limesurvey.org/SGQA+identifier&amp;amp;structure;=English+Instructions+for+LimeSurvey#General_Description question ID]):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       dragDropRank(QQ);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Code in the source of the question(s) using custom text for the &amp;quot;Choices&amp;quot; and &amp;quot;Rankings&amp;quot; element header labels&#039;&#039;&#039; (replace &amp;quot;QQ&amp;quot; with the ranking [http://docs.limesurvey.org/SGQA+identifier&amp;amp;structure;=English+Instructions+for+LimeSurvey#General_Description question ID]):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       dragDropRank(QQ, &#039;Custom Choices Label&#039;, &#039;Custom Rankings Label&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Styles for template.css:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* Drag-n-drop ranking styles */&lt;br /&gt;
&lt;br /&gt;
.dragDropTable {&lt;br /&gt;
&lt;br /&gt;
   border: 0 none;&lt;br /&gt;
&lt;br /&gt;
   border-collapse: collapse;&lt;br /&gt;
&lt;br /&gt;
   width: 100%;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.dragDropTable td {&lt;br /&gt;
&lt;br /&gt;
   vertical-align: top;&lt;br /&gt;
&lt;br /&gt;
   width: 50%;&lt;br /&gt;
&lt;br /&gt;
   padding-right: 20px;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.dragDropTable .dragDropHeader {&lt;br /&gt;
&lt;br /&gt;
   font-weight: bold;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.dragDropTable .dragDropChoices,&lt;br /&gt;
&lt;br /&gt;
.dragDropTable .dragDropRanks {&lt;br /&gt;
&lt;br /&gt;
   margin: 5px 0 0 0;&lt;br /&gt;
&lt;br /&gt;
   background: transparent none;&lt;br /&gt;
&lt;br /&gt;
   border: 0 none;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.dragDropTable .dragDropChoiceList,&lt;br /&gt;
&lt;br /&gt;
.dragDropTable .dragDropRankList {&lt;br /&gt;
&lt;br /&gt;
   float: left;&lt;br /&gt;
&lt;br /&gt;
   width: 100%;&lt;br /&gt;
&lt;br /&gt;
   min-height: 2.4em;&lt;br /&gt;
&lt;br /&gt;
   _height: 2.4em; /* IE6 and below hack */&lt;br /&gt;
&lt;br /&gt;
   margin: 0;&lt;br /&gt;
&lt;br /&gt;
   padding: 0;&lt;br /&gt;
&lt;br /&gt;
   list-style-type: none;&lt;br /&gt;
&lt;br /&gt;
   background: #FBFBFB none;&lt;br /&gt;
&lt;br /&gt;
   border: 1px solid #CCCCCC;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.dragDropTable .dragDropChoiceList li,&lt;br /&gt;
&lt;br /&gt;
.dragDropTable .dragDropRankList li {&lt;br /&gt;
&lt;br /&gt;
   margin: 3px;&lt;br /&gt;
&lt;br /&gt;
   *margin-left: -13px; /* IE7 and below */&lt;br /&gt;
&lt;br /&gt;
   padding: 3px;&lt;br /&gt;
&lt;br /&gt;
   min-height: 1.3em;&lt;br /&gt;
&lt;br /&gt;
   _height: 1.3em; /* IE6 and below hack */&lt;br /&gt;
&lt;br /&gt;
   font-weight: normal;&lt;br /&gt;
&lt;br /&gt;
   cursor: move;&lt;br /&gt;
&lt;br /&gt;
   display: block; /* Force the li to full width */&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Drag and Drop Ranking using Images - Version 1.90 and newer==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+ &amp;amp; 1.91RC4, IE 6/7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround works in conjunction with the above workaround to allow ranking of images.&lt;br /&gt;
&lt;br /&gt;
[[File:Untitled-11.png]]&lt;br /&gt;
&lt;br /&gt;
There is a &#039;&#039;&#039;[http://www.partnersinc.biz/surveys//index.php?sid=36981&amp;amp;newtest;=Y&amp;amp;lang;=en demonstrated here]&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
&lt;br /&gt;
1) Follow the above workaround to get basic drag-n-drop functionality in your ranking question.&lt;br /&gt;
&lt;br /&gt;
2) Insert your images in the ranking question text or help section after any text that you wish to have there (we&#039;ll move them later with JavaScript).&lt;br /&gt;
&lt;br /&gt;
3) Give the images &#039;&#039;&#039;EXACTLY&#039;&#039;&#039; the same IDs as the answer code you would like them to be associated with:[[File:Untitled-8.png]]&lt;br /&gt;
&lt;br /&gt;
4) Place the first script below in your template.js file.&lt;br /&gt;
&lt;br /&gt;
5) Place the second script below in the source the ranking question &#039;&#039;&#039;AFTER&#039;&#039;&#039; the initial call for the dragDropRank function from the workaround above. Replace &amp;quot;QQ&amp;quot; with the ID of the ranking question (this applies the &amp;quot;dragDropRankImages&amp;quot; function to the question).&lt;br /&gt;
&lt;br /&gt;
6) Insert the CSS below at the end of template.css. Replace &amp;quot;11&amp;quot; with your question ID. These styles are for the default template using 50x50px images (as in the demo) and may need to be modified for other templates or image sizes.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Code for template.js:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
function dragDropRankImages(qID) {&lt;br /&gt;
&lt;br /&gt;
   $(&#039;.connectedSortable&#039;+qID+&#039; li&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
       // Remove any text in the sortable choice or rank items&lt;br /&gt;
&lt;br /&gt;
       $(this).text(&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
       // Move the images into the appropriate sortable list item&lt;br /&gt;
&lt;br /&gt;
       var liID = $(this).attr(&#039;id&#039;);&lt;br /&gt;
&lt;br /&gt;
       liIDArray = liID.split(&#039;_&#039;);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+qID+&#039; img#&#039;+liIDArray[1]+&#039;&#039;).appendTo(this);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Code in the source of the question(s):&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       dragDropRankImages(QQ);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Styles for template.css:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* Drag-n-drop for ranking images */&lt;br /&gt;
#question11 .dragDropTable {&lt;br /&gt;
&lt;br /&gt;
   width: auto;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
#question11 .dragDropTable .dragDropChoiceList,&lt;br /&gt;
#question11 .dragDropTable .dragDropRankList {&lt;br /&gt;
&lt;br /&gt;
   min-height: 60px;&lt;br /&gt;
&lt;br /&gt;
   _height: 60px; /* IE6 and below hack */&lt;br /&gt;
&lt;br /&gt;
   width: auto;&lt;br /&gt;
&lt;br /&gt;
   min-width: 60px;&lt;br /&gt;
&lt;br /&gt;
   _width: 60px; /* IE6 and below hack */&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
#question11 .dragDropTable li {&lt;br /&gt;
&lt;br /&gt;
   background: 0 none;&lt;br /&gt;
&lt;br /&gt;
   border: 0 none;&lt;br /&gt;
&lt;br /&gt;
   height: 50px;&lt;br /&gt;
&lt;br /&gt;
   width: 50px;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
#question11 .dragDropTable li img {&lt;br /&gt;
&lt;br /&gt;
   margin: 0;&lt;br /&gt;
&lt;br /&gt;
   padding: 0;&lt;br /&gt;
&lt;br /&gt;
   border: 0 none;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Drag and Drop Ranking for iPad - Version 1.91 and newer==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: LimeSurvey 1.91, iPad 2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround extends the above workarounds to work with the touch interface on iPads.&lt;br /&gt;
&lt;br /&gt;
1) Follow the &amp;quot;[http://docs.limesurvey.org/Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#Drag_and_Drop_Ranking_-_Version_1.90_and_newer Drag and Drop Ranking - Version 1.90 and newer]&amp;quot; workaround above to get basic drag-n-drop functionality in your ranking question.&lt;br /&gt;
&lt;br /&gt;
2) Download the [https://github.com/furf/jquery-ui-touch-punch jQuery.ui.touch-punch.js plugin] and save it in your template directory.&lt;br /&gt;
&lt;br /&gt;
3) Replace this line in your startpage.pstpl:&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;{TEMPLATEURL}template.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;With this:&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;{TEMPLATEURL}jquery.ui.touch-punch.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;{TEMPLATEURL}template.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Drag and Drop Ranking - Version 1.86==&lt;br /&gt;
&lt;br /&gt;
Tested with 1.86 on IE 7,8, FireFox 3, Chrome, and Safari 4&lt;br /&gt;
&lt;br /&gt;
This workaround uses [http://jqueryui.com/demos/sortable/#connect-lists JQuery connected sortables] to modify a ranking question and allow the survey taker to drag and drop choices instead of clicking.  The nice thing is that the choices can be easily re-arranged or removed from the ranking, all by drag and drop.&lt;br /&gt;
&lt;br /&gt;
I used it for a voting application and some of the element names reflect that use.&lt;br /&gt;
&lt;br /&gt;
It looks best when some CSS is added to control the appearance of the boxers around each choice.&lt;br /&gt;
&lt;br /&gt;
[[File:drag-n-drop.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   // Question ID global variable&lt;br /&gt;
&lt;br /&gt;
    var questionID;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Grab the question ID[[File:drag-n-drop.png]]&lt;br /&gt;
&lt;br /&gt;
       // This is something with a class of &amp;quot;ranking&amp;quot; and an ID that starts with &amp;quot;questionXXXXX&amp;quot;.  The X&#039;s represent the question ID&lt;br /&gt;
&lt;br /&gt;
       var entire_questionID = $(&amp;quot;.ranking[id&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&#039;question&#039;]&amp;quot;).attr(&#039;id&#039;);&lt;br /&gt;
&lt;br /&gt;
       // Get just the question number (ID)&lt;br /&gt;
&lt;br /&gt;
       var patt=/\d+$/;&lt;br /&gt;
&lt;br /&gt;
       questionID=patt.exec(entire_questionID);&lt;br /&gt;
&lt;br /&gt;
       // Hide the original quetion in LimeSurvey (so that we can replace with drag and drop)&lt;br /&gt;
&lt;br /&gt;
       $(&amp;quot;.rank, .questionhelp&amp;quot;).hide();&lt;br /&gt;
&lt;br /&gt;
       // Turn off display of question (to override error checking built into LimeSurvey ranking question)&lt;br /&gt;
&lt;br /&gt;
       $(&amp;quot;#display&amp;quot;+questionID).val(&amp;quot;off&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
       // Add connected sortables to the question&lt;br /&gt;
&lt;br /&gt;
       var html_code = &amp;quot;&amp;lt;table style=&#039;border: medium none ; width: 770px; margin-left: auto; \&lt;br /&gt;
&lt;br /&gt;
                                margin-right: auto;&#039;&amp;gt;&amp;lt;tbody&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td style=&#039;width: 590px; vertical-align: top;&#039;&amp;gt;&amp;lt;h3&amp;gt;List of Candidates:&amp;lt;/h3&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
               &amp;lt;div class=&#039;ui-state-highlight&#039; style=&#039;margin: 5px; float: left;&#039; id=&#039;ballot_list&#039;&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                               &amp;lt;ul id=&#039;sortable1&#039; class=&#039;connectedSortable&#039;&amp;gt;&amp;lt;li&amp;gt;Candidates&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/td&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
               &amp;lt;td style=&#039;vertical-align: top;&#039;&amp;gt;&amp;lt;h3&amp;gt;Your selections:&amp;lt;/h3&amp;gt;&amp;lt;div class=&#039;ui-state-highlight&#039; \&lt;br /&gt;
&lt;br /&gt;
                               style=&#039;margin: 5px; float: left;&#039; id=&#039;voting_selections&#039;&amp;gt;&amp;lt;ol id=&#039;sortable2&#039; class=&#039;connectedSortable&#039;&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
               &amp;lt;li&amp;gt;Voting Area&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/tbody&amp;gt;&amp;lt;/table&amp;gt;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
       $(html_code).appendTo(&amp;quot;#question&amp;quot; + questionID);&lt;br /&gt;
&lt;br /&gt;
       // Remove list items (have to have one item so that LimeSurvey doesn&#039;t remove the &amp;lt;ul&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
       $(&amp;quot;#sortable1 li, #sortable2 li&amp;quot;).remove();&lt;br /&gt;
&lt;br /&gt;
       // Load any previously-set values&lt;br /&gt;
&lt;br /&gt;
       loadRanking();&lt;br /&gt;
&lt;br /&gt;
       // Load jQuery UI&lt;br /&gt;
&lt;br /&gt;
       $.getScript(&amp;quot;/scripts/jquery/jquery-ui.js&amp;quot;, function() {&lt;br /&gt;
&lt;br /&gt;
           // After JQuery UI finishes loading, set up the connected sortable.&lt;br /&gt;
&lt;br /&gt;
           $(&amp;quot;#sortable1, #sortable2&amp;quot;).sortable({&lt;br /&gt;
&lt;br /&gt;
               connectWith: &#039;.connectedSortable&#039;,&lt;br /&gt;
&lt;br /&gt;
               placeholder: &#039;ui-sortable-placeholder&#039;,&lt;br /&gt;
&lt;br /&gt;
               stop: function(event, ui) {&lt;br /&gt;
&lt;br /&gt;
                   $(&amp;quot;#sortable1&amp;quot;).sortable(&amp;quot;refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                   $(&amp;quot;#sortable2&amp;quot;).sortable(&amp;quot;refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                   updateRanking();&lt;br /&gt;
&lt;br /&gt;
                   }&lt;br /&gt;
&lt;br /&gt;
           }).disableSelection();&lt;br /&gt;
&lt;br /&gt;
           // Get the list of candidates from the built-in LimeSurvey question and copy them as items in sortable1&lt;br /&gt;
&lt;br /&gt;
           $(&amp;quot;#CHOICES_&amp;quot; + questionID).children().each(function(index, Element) {&lt;br /&gt;
&lt;br /&gt;
               li_tag = &amp;quot;&amp;lt;li class=&#039;ui-state-default&#039; id=&#039;choice_&amp;quot; + $(this).attr(&#039;value&#039;) + &amp;quot;&#039;&amp;gt;&amp;quot; + this.text + &amp;quot;&amp;lt;/li&amp;gt;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
               $(li_tag).appendTo(&amp;quot;#sortable1&amp;quot;); }    );&lt;br /&gt;
&lt;br /&gt;
           // Make sure the submit button is showing&lt;br /&gt;
&lt;br /&gt;
           $(&amp;quot;:submit[value|=&#039; Submit&#039;]&amp;quot;).show();&lt;br /&gt;
&lt;br /&gt;
           // Show a confirmation alert upon submit&lt;br /&gt;
&lt;br /&gt;
           $(&amp;quot;form&amp;quot;).submit(function() {&lt;br /&gt;
&lt;br /&gt;
               // Override the built-in &amp;quot;disable navigation buttons&amp;quot; feature&lt;br /&gt;
&lt;br /&gt;
               $(&#039;#moveprevbtn, #movenextbtn, #movesubmitbtn&#039;).attr(&#039;disabled&#039;, &#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
               var validated = confirm(&amp;quot;Cast your ballot now?&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
               if (validated) { return true; } else { return false; }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Allow users to double click to move to selection list&lt;br /&gt;
&lt;br /&gt;
           $(&amp;quot;#sortable1 li&amp;quot;).assignDblClick();&lt;br /&gt;
&lt;br /&gt;
       });  // End of JQuery UI loading&lt;br /&gt;
&lt;br /&gt;
   }); // End of JQuery ready function&lt;br /&gt;
&lt;br /&gt;
// Define the actions when an item is double clicked&lt;br /&gt;
&lt;br /&gt;
$.fn.assignDblClick = function()&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   $(this).dblclick(function(){&lt;br /&gt;
&lt;br /&gt;
       $(this).appendTo(&#039;#sortable2&#039;);&lt;br /&gt;
&lt;br /&gt;
       $(&amp;quot;#sortable1&amp;quot;).sortable(&amp;quot;refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
       $(&amp;quot;#sortable2&amp;quot;).sortable(&amp;quot;refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
       updateRanking();&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// This function copies the drag and drop sortable data into the standard LimeSurvey ranking structure.&lt;br /&gt;
&lt;br /&gt;
function updateRanking()&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   var rankees = [];&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#sortable2 li&#039;).each(function(index) {&lt;br /&gt;
&lt;br /&gt;
   $(this).attr(&amp;quot;value&amp;quot;, index+1);&lt;br /&gt;
&lt;br /&gt;
       // Get value of person&lt;br /&gt;
&lt;br /&gt;
       li_tag = $(this).attr(&#039;id&#039;);&lt;br /&gt;
&lt;br /&gt;
       li_tag_array = li_tag.split(&amp;quot;_&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
       // Save to an array&lt;br /&gt;
&lt;br /&gt;
       rankees[rankees.length] = { &#039;r_name&#039;:$(this).text(),&#039;r_value&#039;:li_tag_array[1] };&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   $(&amp;quot;input[name&amp;lt;/div&amp;gt;=&#039;RANK_&#039;]&amp;quot;).each(function(index) {&lt;br /&gt;
&lt;br /&gt;
       if (rankees.length &amp;gt; index) {&lt;br /&gt;
&lt;br /&gt;
           $(this).val(rankees[index].r_name);&lt;br /&gt;
&lt;br /&gt;
           $(this).next().val(rankees[index].r_value);&lt;br /&gt;
&lt;br /&gt;
       } else {&lt;br /&gt;
&lt;br /&gt;
           $(this).val(&amp;quot;&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
           $(this).next().val(&amp;quot;&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
     });&lt;br /&gt;
&lt;br /&gt;
   // Re-assign double click action to first list items and remove&lt;br /&gt;
&lt;br /&gt;
   // double click action from section list items&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#sortable1 li&#039;).unbind(&#039;dblclick&#039;).assignDblClick();&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#sortable2 li&#039;).unbind(&#039;dblclick&#039;);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// This function is called on page load to see if there are any items already ranked (from a previous visit&lt;br /&gt;
&lt;br /&gt;
// or cached due to a page change.  If so, the already-ranked items are loaded into the sortable list&lt;br /&gt;
&lt;br /&gt;
function loadRanking()&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   var rankees = [];&lt;br /&gt;
&lt;br /&gt;
   // Loop through each item in the built-in LimeSurvey ranking list looking for non-empty values&lt;br /&gt;
&lt;br /&gt;
   $(&amp;quot;input[name&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&#039;RANK_&#039;]&amp;quot;).each(function(index) {&lt;br /&gt;
&lt;br /&gt;
       // Check to see if the current item has a value&lt;br /&gt;
&lt;br /&gt;
       if ($(this).val()) {&lt;br /&gt;
&lt;br /&gt;
           // Item has a value - save to the array&lt;br /&gt;
&lt;br /&gt;
           // Use this element to contain the name and the next for the value (numeric)&lt;br /&gt;
&lt;br /&gt;
           rankees[rankees.length] = { &#039;r_name&#039;:$(this).val(),&#039;r_value&#039;:$(this).next().val() };&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   // Now that we have a list of all the pre-ranked items, populate the sortable list&lt;br /&gt;
&lt;br /&gt;
   // Note that the items *won&#039;t* appear in the main list because LimeSurvey has removed them.&lt;br /&gt;
&lt;br /&gt;
   $.each(rankees, function(index, value) {&lt;br /&gt;
&lt;br /&gt;
       // Create the items in the sortable&lt;br /&gt;
&lt;br /&gt;
       li_tag = &amp;quot;&amp;lt;li class=&#039;ui-state-default&#039; id=&#039;choice_&amp;quot; + value.r_value + &amp;quot;&#039;&amp;gt;&amp;quot; + value.r_name + &amp;quot;&amp;lt;/li&amp;gt;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
       $(li_tag).appendTo(&amp;quot;#sortable2&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Create MaxDiff question type=&lt;br /&gt;
&lt;br /&gt;
See the &amp;quot;[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Question+design%2C+layout+and+templating&amp;amp;structure;=English+Instructions+for+LimeSurvey Question design, layout and templating]&amp;quot; section for a workaround that uses JavaScript to convert an &#039;&#039;&#039;&#039;&#039;Array (flexible labels) by column&#039;&#039;&#039;&#039;&#039; question into a [http://en.wikipedia.org/wiki/MaxDiff MaxDiff] question type.&lt;br /&gt;
&lt;br /&gt;
[[File:max_diff_596x253.gif]]&lt;br /&gt;
&lt;br /&gt;
=In a checkbox matrix, have the &#039;none&#039; option in a row disable all other columns in that row=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: Limesurvey 1.90+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The questionId parameter is the base ID of the question matrix (multiflexible).&lt;br /&gt;
&lt;br /&gt;
numColumns and numRows speak for themselves&lt;br /&gt;
&lt;br /&gt;
specialColumns is an array of the columns that have the special ability that when one of them&lt;br /&gt;
&lt;br /&gt;
is checked, none of the others can be checked. E.g., a &#039;none of these&#039; and/or a &#039;do now know&#039; option.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
numColumns=13;&lt;br /&gt;
&lt;br /&gt;
numRows=18;&lt;br /&gt;
&lt;br /&gt;
questionId=&#039;28417X2X24&#039;;&lt;br /&gt;
&lt;br /&gt;
specialColumns=[1,12,13];&lt;br /&gt;
&lt;br /&gt;
function action(obj){&lt;br /&gt;
&lt;br /&gt;
   locator=obj.id.replace(&#039;cbox_&#039;+questionId, &#039;&#039;).split(&#039;_&#039;);&lt;br /&gt;
&lt;br /&gt;
   row=locator[0];&lt;br /&gt;
&lt;br /&gt;
   column=locator[1];&lt;br /&gt;
&lt;br /&gt;
   //alert(&#039;Action for row,column=&#039;+row+&#039;,&#039;+column);&lt;br /&gt;
&lt;br /&gt;
   my_id=&#039;#cbox_&#039;+questionId+row+&#039;_&#039;+column+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
   if($(my_id).attr(&#039;checked&#039;) == false) {&lt;br /&gt;
&lt;br /&gt;
       for( var i=1; i&amp;lt;=numColumns; i++ ) {&lt;br /&gt;
&lt;br /&gt;
           if(i==column) continue;&lt;br /&gt;
&lt;br /&gt;
           id=&#039;#cbox_&#039;+questionId+row+&#039;_&#039;+i&lt;br /&gt;
&lt;br /&gt;
           $(id).attr(&#039;disabled&#039;,false);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   } else {&lt;br /&gt;
&lt;br /&gt;
       for( var i=1; i&amp;lt;=numColumns; i++ ) {&lt;br /&gt;
&lt;br /&gt;
           if(i==column) continue;&lt;br /&gt;
&lt;br /&gt;
           id=&#039;#cbox_&#039;+questionId+row+&#039;_&#039;+i&lt;br /&gt;
&lt;br /&gt;
           aid=&#039;#answer&#039;+questionId+row+&#039;_&#039;+i&lt;br /&gt;
&lt;br /&gt;
           $(aid).val(0);&lt;br /&gt;
&lt;br /&gt;
           $(id).attr(&#039;checked&#039;,false);&lt;br /&gt;
&lt;br /&gt;
           $(id).attr(&#039;disabled&#039;,true);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function customOnLoad(){&lt;br /&gt;
&lt;br /&gt;
   for( var row=1; row&amp;lt;=numRows; row++ ) {&lt;br /&gt;
&lt;br /&gt;
       for( var k=0; k&amp;lt;specialColumns.length; k++ )&lt;br /&gt;
&lt;br /&gt;
       {&lt;br /&gt;
&lt;br /&gt;
           column=specialColumns[k];&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#cbox_&#039;+questionId+row+&#039;_&#039;+column).change(function() {&lt;br /&gt;
&lt;br /&gt;
               action(this);&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
jQuery(document).ready(&lt;br /&gt;
&lt;br /&gt;
   function(){&lt;br /&gt;
&lt;br /&gt;
   customOnLoad();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Last Option In Array (Numbers) (Checkboxes) Row Excludes All Others=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround uses JavaScript/jQuery to make the last option of each Array (Numbers) (Checkboxes) row exclude all other options in the same row.&lt;br /&gt;
&lt;br /&gt;
The script will uncheck all options in a row if the last option is checked and uncheck the last option in a row if any other options are checked.&lt;br /&gt;
&lt;br /&gt;
It&#039;s [http://www.partnersinc.biz/surveys//index.php?sid=22532&amp;amp;newtest;=Y&amp;amp;lang;=en demonstrated here].&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_ Set up your survey to use JavaScript].&lt;br /&gt;
#Place the following script in the source of the array question or the group description.&lt;br /&gt;
#Call the script by replacing &amp;quot;QQ&amp;quot; in line 6 with your array question ID (you can call the script for more array questions by copying this line with new IDs).&lt;br /&gt;
&lt;br /&gt;
NOTE: Care should be taken when using this script and conditional questions on the same page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Call the exclude function using question ID(s)&lt;br /&gt;
&lt;br /&gt;
       excludeOpt (QQ);&lt;br /&gt;
&lt;br /&gt;
       // A function to make the last option in each array row exclusive&lt;br /&gt;
&lt;br /&gt;
       function excludeOpt (qID) {&lt;br /&gt;
&lt;br /&gt;
           // Add some classes to the checkboxes so we can manipulate them&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qID+&#039; table.question tbody td&#039;).addClass(&#039;normalOpt&#039;);&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qID+&#039; table.question tbody&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
               $(&#039;td:last&#039;, this).removeClass(&#039;normalOpt&#039;).addClass(&#039;exlusiveOpt&#039;)&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // A listener on the checkbox cells&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qID+&#039; table.question tbody td&#039;).click(function (event) {&lt;br /&gt;
&lt;br /&gt;
               // Set some vars&lt;br /&gt;
&lt;br /&gt;
               var el = $(this).parent();&lt;br /&gt;
&lt;br /&gt;
               var optLength = $(&#039;td&#039;, el).length&lt;br /&gt;
&lt;br /&gt;
               // Uncheck the appropriate boxes in a row&lt;br /&gt;
&lt;br /&gt;
               if ($(this).hasClass(&#039;normalOpt&#039;)) {&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;td:last input[type=checkbox]&#039;, el).attr(&#039;checked&#039;, false);&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               else {&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;td&#039;, el).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
                       if (i &amp;lt; (optLength - 1)) {&lt;br /&gt;
&lt;br /&gt;
                           $(&#039;input[type=checkbox]&#039;, this).attr(&#039;checked&#039;, false);&lt;br /&gt;
&lt;br /&gt;
                       }&lt;br /&gt;
&lt;br /&gt;
                   });&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // A listener on the checkboxes&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qID+&#039; table.question tbody td input[type=checkbox]&#039;).click(function (event) {&lt;br /&gt;
&lt;br /&gt;
               // Set some vars&lt;br /&gt;
&lt;br /&gt;
               var el2 = $(this).parent().parent();&lt;br /&gt;
&lt;br /&gt;
               var optLength = $(&#039;td&#039;, el2).length&lt;br /&gt;
&lt;br /&gt;
               // Uncheck the appropriate boxes in a row&lt;br /&gt;
&lt;br /&gt;
               if ($(this).parent().hasClass(&#039;normalOpt&#039;)) {&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;td:last input[type=checkbox]&#039;, el2).attr(&#039;checked&#039;, false);&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               else {&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;td&#039;, el2).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
                       if (i &amp;lt; (optLength - 1)) {&lt;br /&gt;
&lt;br /&gt;
                           $(&#039;input[type=checkbox]&#039;, this).attr(&#039;checked&#039;, false);&lt;br /&gt;
&lt;br /&gt;
                       }&lt;br /&gt;
&lt;br /&gt;
                   });&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Load SVG Code From Drawing Tool=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround uses JavaScript/jQuery to load a drawing tool and store the results in a huge-text question.&lt;br /&gt;
&lt;br /&gt;
The drawing tool is supplied by [http://www.mainada.net/inputdraw/ mainada.net].&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#Go to [www.mainada.net/inputdraw/downloads|www.mainada.net/inputdraw/downloads], download the latest package and install all files in the root of your LS installation (you only really need &#039;&#039;&#039;inputdraw.js&#039;&#039;&#039;, &#039;&#039;&#039;inputdraw.non-commercial.v1.5.swf&#039;&#039;&#039; and &#039;&#039;&#039;swfobject.js&#039;&#039;&#039; but the others are cool to play with).&lt;br /&gt;
#Add the following to the &amp;lt;head&amp;gt; element of your template startpage.pstpl file to pull in the scripts:&lt;br /&gt;
&lt;br /&gt;
+~hs&amp;lt;span style=&amp;quot;color:hs&amp;lt;/span&amp;gt;hs&amp;lt;span style=&amp;quot;color:hs~&amp;lt;script src=&amp;quot;swfobject.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
+~hs&amp;lt;/span&amp;gt;hs&amp;lt;span style=&amp;quot;color:hs&amp;lt;/span&amp;gt;hs~&amp;lt;script src=&amp;quot;inputdraw.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
#Create a huge-text question and add the following script to the source of that question.&lt;br /&gt;
&lt;br /&gt;
The script will&amp;quot;&amp;gt;&lt;br /&gt;
*Automatically find the ID of the first huge-text question on the page&lt;br /&gt;
*Insert the drawing element into the huge-text question&lt;br /&gt;
*Hide the textarea of that question&lt;br /&gt;
*Populate it with the SVG code generated by the drawing element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Find the survey, group and question IDs&lt;br /&gt;
&lt;br /&gt;
       if($( &#039;input#fieldnames&#039; ).length != 0) {&lt;br /&gt;
&lt;br /&gt;
           var fieldNames = $(&#039;input#fieldnames&#039;).attr(&#039;value&#039;);&lt;br /&gt;
&lt;br /&gt;
           var tmp = fieldNames.split(&#039;X&#039;);&lt;br /&gt;
&lt;br /&gt;
           var sID = tmp[0];&lt;br /&gt;
&lt;br /&gt;
           var gID = tmp[1];&lt;br /&gt;
&lt;br /&gt;
           var qIDStr = $(&#039;div.text-huge:eq(0)&#039;).attr(&#039;id&#039;);&lt;br /&gt;
&lt;br /&gt;
           var tmp2 = qIDStr.split(&#039;question&#039;);&lt;br /&gt;
&lt;br /&gt;
           var qID = tmp2[1];&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       var textAreaID = &#039;answer&#039;+sID+&#039;X&#039;+gID+&#039;X&#039;+qID;&lt;br /&gt;
&lt;br /&gt;
       // Hide the textarea&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#&#039;+textAreaID+&#039;&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
       // Insert an element for the drawing tool&lt;br /&gt;
&lt;br /&gt;
   $(&#039;&amp;lt;div id=&amp;quot;place&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&#039;).insertBefore($(&#039;#&#039;+textAreaID+&#039;&#039;));&lt;br /&gt;
&lt;br /&gt;
       // Load the drawing tool&lt;br /&gt;
&lt;br /&gt;
   var draw = new InputDraw(&#039;inputdraw.non-commercial.v1.5.swf&#039;, &#039;place&#039;, {&lt;br /&gt;
&lt;br /&gt;
           id:textAreaID,&lt;br /&gt;
&lt;br /&gt;
           width:&#039;350&#039;,&lt;br /&gt;
&lt;br /&gt;
           height:&#039;100&#039;,&lt;br /&gt;
&lt;br /&gt;
           stroke_style:&#039;2 1 rgb(255,0,0)&#039;,&lt;br /&gt;
&lt;br /&gt;
           animation:60,&lt;br /&gt;
&lt;br /&gt;
           color:&#039;#CCCCCC&#039; ,&lt;br /&gt;
&lt;br /&gt;
           tools_color:&#039;0xd6c004&#039;,&lt;br /&gt;
&lt;br /&gt;
           clean:&#039;clear.png&#039;,&lt;br /&gt;
&lt;br /&gt;
           undo:&#039;undo.png&#039;,&lt;br /&gt;
&lt;br /&gt;
           disable:&#039;size opacity color&#039; // Get rid of most of the tools&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Add Navigation Buttons (Next and Previous) To Top Of Page=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Add the following to the end of template.js. It will insert a new div after the progress bar and then insert clones of the nav buttons in the new div.&lt;br /&gt;
&lt;br /&gt;
This example is for the default template in 1.90 or 1.91. The placement of the new div may need to be modified for other templates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Insert a new div after the progress bar&lt;br /&gt;
&lt;br /&gt;
       $(&#039;&amp;lt;div id=&amp;quot;navigator2&amp;quot; /&amp;gt;&#039;).insertAfter(&#039;#progress-wrapper&#039;);&lt;br /&gt;
&lt;br /&gt;
       // Style the new div&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#navigator2&#039;).css({&lt;br /&gt;
&lt;br /&gt;
           &#039;text-align&#039;:&#039;center&#039;&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // Insert clones of the nav buttons in the new div&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input.submit:eq(0)&#039;).clone().appendTo(&#039;#navigator2&#039;);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input.submit:eq(2)&#039;).clone().appendTo(&#039;#navigator2&#039;);&lt;br /&gt;
&lt;br /&gt;
       // Give the new buttons some new IDs&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#navigator2 input.submit&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
           var oldID = $(this).attr(&#039;id&#039;);&lt;br /&gt;
&lt;br /&gt;
           var newID = oldID + &#039;2&#039;;&lt;br /&gt;
&lt;br /&gt;
           $(this).attr(&#039;id&#039;, newID)&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:extra_buttons.png]]&lt;br /&gt;
&lt;br /&gt;
=How to &#039;&#039;add&#039;&#039; an opt out link to your survey using javascript.=&lt;br /&gt;
&lt;br /&gt;
Tested with: 1.91+, Firefox 5.0&lt;br /&gt;
&lt;br /&gt;
This javascript inserts a link to opt out of the survey above the progress bar.&lt;br /&gt;
&lt;br /&gt;
First see the section above entitled: &amp;quot;How to use Script (eg. JavaScript etc.) in LimeSurvey?&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Then insert the following code into to the source of a group description or a question. I used the group description.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt; &amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Find the survey ID&lt;br /&gt;
&lt;br /&gt;
       if($(&#039;input#fieldnames&#039;).length != 0) {&lt;br /&gt;
&lt;br /&gt;
           var fieldNames = $(&#039;input#fieldnames&#039;).attr(&#039;value&#039;);&lt;br /&gt;
&lt;br /&gt;
           var tmp = fieldNames.split(&#039;X&#039;);&lt;br /&gt;
&lt;br /&gt;
           var sID = tmp[0];&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       // Insert a new div after the progress bar&lt;br /&gt;
&lt;br /&gt;
       $(&#039;&amp;lt;div id=&amp;quot;optOutLink&amp;quot; /&amp;gt;&#039;).insertBefore(&#039;#progress-wrapper&#039;);&lt;br /&gt;
&lt;br /&gt;
       // Style the new div&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#optOutLink&#039;).css({&lt;br /&gt;
&lt;br /&gt;
           &#039;text-align&#039;:&#039;center&#039;&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // Insert opt out url in the new div&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#optOutLink&#039;).html(&#039;&amp;lt;P&amp;gt;&amp;lt;a href=&amp;quot;optout.php?lang=en&amp;amp;sid;=&#039;+sID+&#039;&amp;amp;token;={TOKEN}&amp;quot;&amp;gt; /&lt;br /&gt;
&lt;br /&gt;
               Click here to opt out of this survey.&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;&amp;lt;br&amp;gt;&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Anonymously track respondents answers across multiple surveys=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.91+ and 1.92+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround uses JavaScript/jQuery to enable tracking of respondents across multiple surveys ensuring anonymity (it does not use tokens).&lt;br /&gt;
&lt;br /&gt;
To do this you have to use this question in all the surveys you want to link respondents answers.&lt;br /&gt;
&lt;br /&gt;
This workaround create an ID by asking some partial personal information (like initials, birth month ...). The ID will be encrypted using a one-way function (in this case SHA-1) and stored in a brief text answer.&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_ Set up your survey to use JavaScript].&lt;br /&gt;
#Place the following code in the source of a brief text question.&lt;br /&gt;
#Optional: you can also add other select field to avoid collisions (e.g. for large population sample)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;This answers are used to generate your ID. These information will be encrypted, it will not be possible in any case to identify you neither from your answers nor from your ID.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;Initial of your name&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;select id=&amp;quot;field1&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;&amp;quot;&amp;gt;&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;A&amp;quot;&amp;gt;A&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;B&amp;quot;&amp;gt;B&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;C&amp;quot;&amp;gt;C&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;D&amp;quot;&amp;gt;D&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;E&amp;quot;&amp;gt;E&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;F&amp;quot;&amp;gt;F&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;G&amp;quot;&amp;gt;G&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;H&amp;quot;&amp;gt;H&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;I&amp;quot;&amp;gt;I&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;J&amp;quot;&amp;gt;J&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;K&amp;quot;&amp;gt;K&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;L&amp;quot;&amp;gt;L&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;M&amp;quot;&amp;gt;M&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;N&amp;quot;&amp;gt;N&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;O&amp;quot;&amp;gt;O&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;P&amp;quot;&amp;gt;P&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;Q&amp;quot;&amp;gt;Q&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;R&amp;quot;&amp;gt;R&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;S&amp;quot;&amp;gt;S&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;T&amp;quot;&amp;gt;T&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;U&amp;quot;&amp;gt;U&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;V&amp;quot;&amp;gt;V&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;W&amp;quot;&amp;gt;W&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;X&amp;quot;&amp;gt;X&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;Y&amp;quot;&amp;gt;Y&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;Z&amp;quot;&amp;gt;Z&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/select&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;Your birth month&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;select id=&amp;quot;field2&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;&amp;quot;&amp;gt;&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;01&amp;quot;&amp;gt;January&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;02&amp;quot;&amp;gt;February&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;03&amp;quot;&amp;gt;March&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;04&amp;quot;&amp;gt;April&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;05&amp;quot;&amp;gt;May&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;06&amp;quot;&amp;gt;June&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;07&amp;quot;&amp;gt;July&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;08&amp;quot;&amp;gt;August&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;09&amp;quot;&amp;gt;September&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;10&amp;quot;&amp;gt;October&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;11&amp;quot;&amp;gt;November&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;12&amp;quot;&amp;gt;December&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/select&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;http://crypto-js.googlecode.com/svn/tags/3.0.2/build/rollups/sha1.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
   $(&amp;quot;#answer{SGQ}&amp;quot;).attr(&#039;readonly&#039;, &#039;readonly&#039;);&lt;br /&gt;
&lt;br /&gt;
   //$(&amp;quot;#answer{SGQ}&amp;quot;).css(&#039;display&#039;, &#039;none&#039;); //uncomment this line for not displaying the code&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
$(&#039;#field1, #field2&#039;).bind(&#039;change keyup&#039;, function() {&lt;br /&gt;
&lt;br /&gt;
   if ($(&amp;quot;#field1&amp;quot;).val()==&#039;&#039; || $(&amp;quot;#field2&amp;quot;).val()==&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
       $(&amp;quot;#answer{SGQ}&amp;quot;).val(&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
   else {&lt;br /&gt;
&lt;br /&gt;
       var sha1 = CryptoJS.algo.SHA1.create();&lt;br /&gt;
&lt;br /&gt;
       sha1.update($(&amp;quot;#field1&amp;quot;).val());&lt;br /&gt;
&lt;br /&gt;
       sha1.update($(&amp;quot;#field2&amp;quot;).val());&lt;br /&gt;
&lt;br /&gt;
       // sha1.update($(&amp;quot;#otherfield&amp;quot;).val());&lt;br /&gt;
&lt;br /&gt;
       var hash = sha1.finalize();&lt;br /&gt;
&lt;br /&gt;
       $(&amp;quot;#answer{SGQ}&amp;quot;).val(hash);&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Check validity of international phone number in subquestion=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.91+, Firefox 8, Chrome 15&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;As of version 1.92, you can use the core Validation querstion option to validate multiple short text and array text questions. Any question that fails that validation check will have its background color changed to red.&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;Note, the below workaround will fail in version 1.92 because it contains a regular expression with curly braces.  However, as described above, support for this feature is now built-in to version 1.92&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround uses javascript to check the validity of an international phone number in a subquestion of multiple short text.&lt;br /&gt;
&lt;br /&gt;
Add the following code to the source of your question.&lt;br /&gt;
&lt;br /&gt;
Replace &amp;quot;QQ&amp;quot; with the question ID and &amp;quot;NN&amp;quot; with the row number that you want to validate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Call the phone function with the question ID and the row number&lt;br /&gt;
&lt;br /&gt;
       phoneTest(QQ, NN);&lt;br /&gt;
&lt;br /&gt;
       function phoneTest(qID, inputNum) {&lt;br /&gt;
&lt;br /&gt;
           // Interrupt next/submit function&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#movenextbtn, #movesubmitbtn&#039;).click(function(){&lt;br /&gt;
&lt;br /&gt;
               // Some vars - modify as required&lt;br /&gt;
&lt;br /&gt;
               var phoneMatch = /^[0-9,+,(), ,]{1,}(,[0-9]+){0,}$/;&lt;br /&gt;
&lt;br /&gt;
               var msg1 = &#039;Please enter a valid phone number.&#039;;&lt;br /&gt;
&lt;br /&gt;
               // Test the input&lt;br /&gt;
&lt;br /&gt;
               var phoneInput = $(&#039;#question&#039;+qID+&#039; li:eq(&#039;+(inputNum-1)+&#039;) input.text&#039;).val();&lt;br /&gt;
&lt;br /&gt;
               if(phoneInput != &#039;&#039; &amp;amp;&amp;amp; !phoneMatch.test(phoneInput)) {&lt;br /&gt;
&lt;br /&gt;
                   alert(msg1);&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;#question&#039;+qID+&#039; li:eq(&#039;+(inputNum-1)+&#039;) input.text&#039;).css({ &#039;background&#039;:&#039;pink&#039; });&lt;br /&gt;
&lt;br /&gt;
                   return false;&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               else {&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;#question&#039;+qID+&#039; li:eq(&#039;+(inputNum-1)+&#039;) input.text&#039;).css({ &#039;background&#039;:&#039;&#039; });&lt;br /&gt;
&lt;br /&gt;
                   return true;&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The regex is from: [http://www.regexlib.com/REDetails.aspx?regexp_id=1136 regexlib.com blank]&lt;br /&gt;
&lt;br /&gt;
=Check validity of email address in subquestion=&lt;br /&gt;
&lt;br /&gt;
&#039;Tested with: 1.91+, Firefox 8, Chrome 15&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;As of version 1.92, you can use the core Validation querstion option to validate multiple short text and array text questions. Any question that fails that validation check will have its background color changed to red.&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;Note, the below workaround will fail in version 1.92 because it contains a regular expression with curly braces.  However, as described above, support for this feature is now built-in to version 1.92&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround uses javascript to check the validity of an email address in a subquestion of multiple short text.&lt;br /&gt;
&lt;br /&gt;
Add the following code to the source of your question.&lt;br /&gt;
&lt;br /&gt;
Replace &amp;quot;QQ&amp;quot; with the question ID and &amp;quot;NN&amp;quot; with the row number that you want to validate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Call the email function with the question ID and the row number&lt;br /&gt;
&lt;br /&gt;
       emailTest(QQ, NN);&lt;br /&gt;
&lt;br /&gt;
       function emailTest(qID, inputNum) {&lt;br /&gt;
&lt;br /&gt;
           // Interrupt next/submit function&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#movenextbtn, #movesubmitbtn&#039;).click(function(){&lt;br /&gt;
&lt;br /&gt;
               // Some vars - modify as required&lt;br /&gt;
&lt;br /&gt;
               var emailMatch = /^[a-zA-Z0-9\_\-]+[a-zA-Z0-9\.\_\-]*@([a-zA-Z0-9\_\-]+\.)+([a-zA-Z]{2,4}|travel|museum)$/;&lt;br /&gt;
&lt;br /&gt;
               var msg1 = &#039;Please enter a valid email address.&#039;;&lt;br /&gt;
&lt;br /&gt;
               // Test the input&lt;br /&gt;
&lt;br /&gt;
               var emailInput = $(&#039;#question&#039;+qID+&#039; li:eq(&#039;+(inputNum-1)+&#039;) input.text&#039;).val();&lt;br /&gt;
&lt;br /&gt;
               if(emailInput != &#039;&#039; &amp;amp;&amp;amp; !emailMatch.test(emailInput)) {&lt;br /&gt;
&lt;br /&gt;
                   alert(msg1);&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;#question&#039;+qID+&#039; li:eq(&#039;+(inputNum-1)+&#039;) input.text&#039;).css({ &#039;background&#039;:&#039;pink&#039; });&lt;br /&gt;
&lt;br /&gt;
                   return false;&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               else {&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;#question&#039;+qID+&#039; li:eq(&#039;+(inputNum-1)+&#039;) input.text&#039;).css({ &#039;background&#039;:&#039;&#039; });&lt;br /&gt;
&lt;br /&gt;
                   return true;&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The regex is from: [http://www.regexlib.com/REDetails.aspx?regexp_id=1653 regexlib.com blank]&lt;br /&gt;
&lt;br /&gt;
=Hiding the help-text when it&#039;s empty=&lt;br /&gt;
&lt;br /&gt;
Tested with: 1.91+&lt;br /&gt;
&lt;br /&gt;
I had made a style in my template putting a border around my help-text. To avoid empty help-text to show up (and have lines instead of just &#039;nothing&#039; when there was no help text, I used this piece of code in question.pstpl:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
                   var questionhelp=&amp;quot;{QUESTIONHELP}&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
                   if (questionhelp==&amp;quot;&amp;quot;) {&lt;br /&gt;
&lt;br /&gt;
                          document.write(&amp;quot;&amp;quot;);}&lt;br /&gt;
&lt;br /&gt;
                   else {&lt;br /&gt;
&lt;br /&gt;
                   document.write(&#039;&amp;lt;tr&amp;gt;&amp;lt;td class=&amp;quot;survey-question-help&amp;quot;&amp;gt;&#039;+ questionhelp +&#039;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&#039;);}&lt;br /&gt;
&lt;br /&gt;
               &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
it can probably be optimized but it worked for me&lt;br /&gt;
&lt;br /&gt;
=Disable or hide selected fields in a matrix question=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.92+, IE 7/8/9, FireFox 12/13&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
TASK&lt;br /&gt;
&lt;br /&gt;
Hide or disable selected fields in a Matrix, so that users cannot make any input.&lt;br /&gt;
&lt;br /&gt;
(See example, where users should not make input into red framed fields)&lt;br /&gt;
&lt;br /&gt;
[[File:snap035.gif]]&lt;br /&gt;
&lt;br /&gt;
Fig. 1: Prevent users from input into first two fields (as an example)&lt;br /&gt;
&lt;br /&gt;
SOLUTION&lt;br /&gt;
&lt;br /&gt;
First find the name of the fields you want to hide / disable. In my case I used Firebug with firefox to figure that out.&lt;br /&gt;
&lt;br /&gt;
[[File:snap037.gif]]&lt;br /&gt;
&lt;br /&gt;
Fig. 2: Figure out the name(s) of the field(s)&lt;br /&gt;
&lt;br /&gt;
Then put the following script-code into the HTML-source code as described above:&lt;br /&gt;
&lt;br /&gt;
Note: you have to change the code to match the names of your fields!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input[name=&amp;quot;69965X2X10SQ001_SQ001&amp;quot;]&#039;).attr(&#039;disabled&#039;, &#039;disabled&#039;);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input[name=&amp;quot;69965X2X10SQ001_SQ002&amp;quot;]&#039;).attr(&#039;hidden&#039;, &#039;hidden&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:snap039.gif]]&lt;br /&gt;
&lt;br /&gt;
Fig. 3: Result: first field is diabled (&amp;quot;greyed out&amp;quot;), second one is completely hidden&lt;br /&gt;
&lt;br /&gt;
I think this way one can apply many other attributes to a field like color etc. But did not try that myself.&lt;br /&gt;
&lt;br /&gt;
Thanks to roB2009 for the input in the forum!&lt;br /&gt;
&lt;br /&gt;
=Add prefix or suffix to question type &amp;quot;Array (Texts)&amp;quot;=&lt;br /&gt;
&lt;br /&gt;
TASK&lt;br /&gt;
&lt;br /&gt;
Add a prefix or suffix to the text fields in questions of the &amp;quot;Array (Texts)&amp;quot; type.&lt;br /&gt;
&lt;br /&gt;
[[File:suffix.png]]&lt;br /&gt;
&lt;br /&gt;
Fig. 1: Suffix&lt;br /&gt;
&lt;br /&gt;
[[File:prefix.png]]&lt;br /&gt;
&lt;br /&gt;
Fig. 1: Prefix&lt;br /&gt;
&lt;br /&gt;
SOLUTION&lt;br /&gt;
*Set up your survey to use JavaScript.&lt;br /&gt;
*Add the following script to the source of the array. Replace &amp;quot;12345&amp;quot; with the array question ID and modify the suffixes/prefixes as required.&lt;br /&gt;
*The function call must consist of a question ID followed by the suffixes for each column. Suffixes/Prefixes must be enclosed in quotes and comma separated.&lt;br /&gt;
*In this example question ID 12345 will get an &amp;quot;in &amp;amp;euro;&amp;quot; suffix in the first column and an &amp;quot;in %&amp;quot; in the next 3 columns.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Call the function with the question ID followed by a comma-separated list of suffixes&lt;br /&gt;
&lt;br /&gt;
       addSuffix(12345, &#039;in &amp;amp;euro;&#039;, &#039;in %&#039;, &#039;in %&#039;, &#039;in %&#039;);&lt;br /&gt;
&lt;br /&gt;
       function addSuffix() {&lt;br /&gt;
&lt;br /&gt;
           var qID = $(arguments)[0];&lt;br /&gt;
&lt;br /&gt;
           // Assign some column-specific classes&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qID+&#039; table.question tbody tr&#039;).each(function(i){&lt;br /&gt;
&lt;br /&gt;
               $(&#039;td&#039;, this).each(function(i){&lt;br /&gt;
&lt;br /&gt;
                   $(this).addClass(&#039;answerCol-&#039;+(i+1)+&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
               });&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Some styling&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qID+&#039; table.question tbody input[type=&amp;quot;text&amp;quot;]&#039;).css({&lt;br /&gt;
&lt;br /&gt;
               &#039;width&#039;: &#039;50%&#039;&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Insert the suffixes&lt;br /&gt;
&lt;br /&gt;
           $(arguments).each(function(i, val){&lt;br /&gt;
&lt;br /&gt;
               if(i &amp;gt; 0) {&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;#question&#039;+qID+&#039; td.answerCol-&#039;+i+&#039; label&#039;).append(val);&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For adding a prefix you need to substitute the following line in the code&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;$(&#039;#question&#039;+qID+&#039; td.answerCol-&#039;+i+&#039; label&#039;).append(val);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with this&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;$(&#039;#question&#039;+qID+&#039; td.answerCol-&#039;+i+&#039; label&#039;).prepend(val);&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Holch</name></author>
	</entry>
	<entry>
		<id>https://www.limesurvey.org/manual/index.php?title=Workarounds:_Manipulating_a_survey_at_runtime_using_Javascript&amp;diff=3790</id>
		<title>Workarounds: Manipulating a survey at runtime using Javascript</title>
		<link rel="alternate" type="text/html" href="https://www.limesurvey.org/manual/index.php?title=Workarounds:_Manipulating_a_survey_at_runtime_using_Javascript&amp;diff=3790"/>
		<updated>2012-07-06T22:49:35Z</updated>

		<summary type="html">&lt;p&gt;Holch: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
Often you want to manipulate certain elements of a survey at runtime. The only solution without touching the source code is to use Javascript or jQuery which is shipped with Limesurvey. Here are some examples to hide and style elements, validate user input or do calculations at runtime.&lt;br /&gt;
&lt;br /&gt;
Non Javascript workarounds can be found at&lt;br /&gt;
* [http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Survey+behaviour&amp;amp;structure;=English+Instructions+for+LimeSurvey Workarounds - Survey Behavior]&lt;br /&gt;
* [http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Question+design%2C+layout+and+templating Workarounds - Question design, layout and templating]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;&amp;lt;center&amp;gt;&#039;&#039;&#039;Please keep in mind that the workarounds published here are no official Limesurvey extensions but solutions that other users created for themselves.&amp;lt;br/&amp;gt;&amp;lt;span style=&#039;color:#EE0000,#FFFFFF&#039;&amp;gt;Therefore we can&#039;t give support for any solution on this page.&amp;lt;/span&amp;gt;&amp;lt;br/&amp;gt;Please contact the users that, thankfully, shared their solutions with the community if you have any questions.&#039;&#039;&#039;&amp;lt;/center&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;Note:  Version 1.92 implements many new features that make some existing workarounds obsolete.  You can continue to use existing workarounds, but may want to consider switching over to using the new features (since those new features are officially supported, and the workarounds are not).  Please review below for details of which are no longer needed.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;Also Note:  Version 1.92&#039;s Expression Manager (EM) may cause some of these work-arounds to fail.  Any custom javascript included as a .js file will be fine.  However, if you in-line your JavaScript code, you must make sure that you have a space after every opening (left) curly brace, and a space before every closing (right) curly brace.  Otherwise, EM will think that the content between the curly braces is something it should parse and understand.  I have fixed all of the work-arounds below that can be fixed (many did not follow those rules).  However, some will continue to break.  If a work-around contains a regular expression which contains curly braces (to indicate a range of repeats of a sub-expression), EM will try to process those curly braces, and thus break your regular expression.  Strategies to continue to support that work-around functionality are discussed below.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=How to &#039;&#039;add&#039;&#039; a javascript workaround solution to this Wiki page?=&lt;br /&gt;
&lt;br /&gt;
Well, this is pretty easy. Click the edit icon and create your own headline within the javascript section starting with &amp;quot;&#039;&#039;&#039;!&#039;&#039;&#039;&amp;quot;. Then add a short note about the version you have used when creating your workaround, you can copy/paste this code snippet &amp;lt;nowiki&amp;gt;&#039;&#039;Tested with: (enter Limesurvey version and maybe browser)&#039;&#039;&amp;lt;/nowiki&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Finally it&#039;s imported to mark all your code with code tags, other wise you might break this page.&lt;br /&gt;
*Start tag: &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
*End tag: &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=How to &#039;&#039;use&#039;&#039; Script (eg. JavaScript etc.) in LimeSurvey?=&lt;br /&gt;
&lt;br /&gt;
To use JavaScript within Limesurvey, the XSS filter must be turned off and the code inserted in the source of a question or a group description.&lt;br /&gt;
*Go to Global settings --&amp;gt; Security and set &amp;quot;Filter HTML for XSS&amp;quot; to &amp;quot;Off&amp;quot;.&lt;br /&gt;
* [http://docs.limesurvey.org/tiki-index.php?page=Adding+A+Question Add a new question]&lt;br /&gt;
* Edit the question and click the &amp;quot;Source&amp;quot; button in the editor toolbar:&lt;br /&gt;
&lt;br /&gt;
   [[File:editor_1.gif]]&lt;br /&gt;
* Enter your script after the question text:&lt;br /&gt;
&lt;br /&gt;
   [[File:editor_2.gif]]&lt;br /&gt;
* Save the question&lt;br /&gt;
&lt;br /&gt;
A simple test to see if JavaScript is enabled is to echo an alert. Use this code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   alert(&amp;quot;Test!&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is a good practice to use the jQuery $(document).ready function to prevent the code from executing until the page is fully loaded:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       alert(&amp;quot;Test!&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Sum up input values using Javascript=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, this is easier to do using the sum() function in [[Expression Manager|Expression Manager]].  See this [[Expression Manager HowTos|#Calculate assessment values at runtime and store the results in the survey data|HowTo example]].&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is from a survey that is a invitation to a longer party, when the user clicks to the next page, the calculated results will be shown.&lt;br /&gt;
&lt;br /&gt;
If you wonder what the {INSERTANS:1X6X12} stuff is, look at [http://docs.limesurvey.org/tiki-index.php?page=SGQA+Identifier SGQA identifier] and [http://docs.limesurvey.org/tiki-index.php?page=Adding+a+Question#Information_from_previous_answers Using information from previous answers].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;text-align: left&amp;quot;&amp;gt;These are your answers:&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;u&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;u&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;u&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;u&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;script LANGUAGE=&amp;quot;JavaScript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
partyprice = 3;&lt;br /&gt;
&lt;br /&gt;
beadclothprice = 3;&lt;br /&gt;
&lt;br /&gt;
breakfastprice = 7;&lt;br /&gt;
&lt;br /&gt;
lunchprice = 8;&lt;br /&gt;
&lt;br /&gt;
dinnerprice = 10;&lt;br /&gt;
&lt;br /&gt;
foodtotal = 0;&lt;br /&gt;
&lt;br /&gt;
var isreallytrue = &amp;quot;Yes&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
var noanswer = &amp;quot;No answer&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
document.write( &amp;quot;Can you come? = {INSERTANS:45251X1X1}&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
if (&amp;quot;{INSERTANS:45251X1X1}&amp;quot; == isreallytrue )&lt;br /&gt;
&lt;br /&gt;
  {&lt;br /&gt;
&lt;br /&gt;
   if (&amp;quot;{INSERTANS:45251X1X3}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
   else { answer = &amp;quot;{INSERTANS:45251X1X3}&amp;quot;; }&lt;br /&gt;
&lt;br /&gt;
   partypeople = parseInt(answer);&lt;br /&gt;
&lt;br /&gt;
   partytotal = partyprice * partypeople;&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;It&#039;s {INSERTANS:45251X1X3} persons who will come = &amp;quot; + partytotal + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   if (&amp;quot;{INSERTANS:45251X1X4}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
   else { answer = &amp;quot;{INSERTANS:45251X1X4}&amp;quot;;}&lt;br /&gt;
&lt;br /&gt;
   beadcloths = parseInt(answer);&lt;br /&gt;
&lt;br /&gt;
   beadclothtotal = beadclothprice * beadcloths;&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;You want to borrow {INSERTANS:45251X1X4} beadcloths = &amp;quot; + beadclothtotal + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;Will you be there thursday? = {INSERTANS:45251X1X5}&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;On friday you will have these meals: &amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   if (&amp;quot;{INSERTANS:45251X1X71}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
   else { answer = &amp;quot;{INSERTANS:45251X1X71}&amp;quot;;}&lt;br /&gt;
&lt;br /&gt;
   breakfastfriday = parseInt(answer) * breakfastprice;&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; breakfeasts = &amp;quot; + breakfastfriday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   if (&amp;quot;{INSERTANS:45251X1X72}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
   else { answer = &amp;quot;{INSERTANS:45251X1X72}&amp;quot;;}&lt;br /&gt;
&lt;br /&gt;
   lunchfriday = parseInt(answer) * lunchprice ;&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; lunches = &amp;quot; + lunchfriday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   if (&amp;quot;{INSERTANS:45251X1X73}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
   else { answer = &amp;quot;{INSERTANS:45251X1X73}&amp;quot;;}&lt;br /&gt;
&lt;br /&gt;
   dinnerfriday = parseInt(answer)* dinnerprice ;&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; dinners = &amp;quot; + dinnerfriday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   foodtotal = breakfastfriday + lunchfriday + dinnerfriday;&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;Will you be there saturday? = {INSERTANS:45251X1X8}&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   if (&amp;quot;{INSERTANS:45251X1X8}&amp;quot; == isreallytrue )&lt;br /&gt;
&lt;br /&gt;
      {&lt;br /&gt;
&lt;br /&gt;
       document.write( &amp;quot;On saturday you will have these meals: &amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
       if (&amp;quot;{INSERTANS:45251X1X91}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
       else { answer = &amp;quot;{INSERTANS:45251X1X91}&amp;quot;; }&lt;br /&gt;
&lt;br /&gt;
       breakfastsaturday = parseInt(answer) * breakfastprice ;&lt;br /&gt;
&lt;br /&gt;
       document.write(&amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; breakfeasts = &amp;quot; + breakfastsaturday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
       if (&amp;quot;{INSERTANS:45251X1X92}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
       else { answer = &amp;quot;{INSERTANS:45251X1X92}&amp;quot;; }&lt;br /&gt;
&lt;br /&gt;
       lunchsaturday = parseInt(answer) * lunchprice ;&lt;br /&gt;
&lt;br /&gt;
       document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; lunches = &amp;quot; + lunchsaturday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
       if (&amp;quot;{INSERTANS:45251X1X93}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
       else { answer = &amp;quot;{INSERTANS:45251X1X93}&amp;quot;; }&lt;br /&gt;
&lt;br /&gt;
       dinnersaturday = parseInt(answer) * dinnerprice ;&lt;br /&gt;
&lt;br /&gt;
       document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; dinners = &amp;quot; + dinnersaturday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
       foodtotal = foodtotal + breakfastsaturday + lunchsaturday + dinnersaturday;&lt;br /&gt;
&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;Will you be there sunday? = {INSERTANS:45251X1X10}&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   if (&amp;quot;{INSERTANS:45251X1X10}&amp;quot; == isreallytrue )&lt;br /&gt;
&lt;br /&gt;
      {&lt;br /&gt;
&lt;br /&gt;
       document.write( &amp;quot;On sunday you will have these meals: &amp;lt;br&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
       if (&amp;quot;{INSERTANS:45251X1X111}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
       else { answer = &amp;quot;{INSERTANS:45251X1X111}&amp;quot;; }&lt;br /&gt;
&lt;br /&gt;
       breakfastsunday = parseInt(answer) * breakfastprice ;&lt;br /&gt;
&lt;br /&gt;
       document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; breakfeasts = &amp;quot; + breakfastsunday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot;  );&lt;br /&gt;
&lt;br /&gt;
       if (&amp;quot;{INSERTANS:45251X1X112}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
       else { answer = &amp;quot;{INSERTANS:45251X1X112}&amp;quot;; }&lt;br /&gt;
&lt;br /&gt;
       lunchsunday = parseInt(answer) * lunchprice ;&lt;br /&gt;
&lt;br /&gt;
       document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; lunches = &amp;quot; + lunchsunday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
       if (&amp;quot;{INSERTANS:45251X1X113}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
       else { answer = &amp;quot;{INSERTANS:45251X1X113}&amp;quot;; }&lt;br /&gt;
&lt;br /&gt;
       dinnersunday = parseInt(answer) * dinnerprice ;&lt;br /&gt;
&lt;br /&gt;
       document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; dinners = &amp;quot; + dinnersunday + &amp;quot;&amp;amp;euro;&amp;lt;p&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
       foodtotal = foodtotal + breakfastsunday + lunchsunday + dinnersunday;&lt;br /&gt;
&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
   total = partytotal + beadclothtotal + foodtotal;&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;&amp;lt;h3&amp;gt;In total it will cost you &amp;quot; + total + &amp;quot;&amp;amp;euro;&amp;lt;/h3&amp;gt;&amp;lt;BR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   Put that sum in this bank account 1234 5678 9012&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/SCRIPT&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Multiple Question Validation=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, this is easier to do using the min/max/equals_num_value attributes (to validate sums), or the em_validation_q function, which lets you refer to other variables when you validate the current question [[Expression Manager|Expression Manager]].  Such validations also work on the current page, and properly handle array_filter and cascading relevance.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround is in case you need to do some validation involving more than one question, it implies a very little JavaScript programming and the use of SQGA Identifiers; this should work on almost any version of LimeSurvey.&lt;br /&gt;
&lt;br /&gt;
Is easy to explain with an example, we need to do a survey of the percentage of males and females and we want to be sure that the sum is 100, to do this follow this steps (the necessary data that is not indicated in these instructions are not important i.e. question codes, etc.):&lt;br /&gt;
#Create a new survey of type &amp;amp;ldquo;group by group&amp;amp;rdquo;, set the &amp;amp;ldquo;Show |&amp;lt;&amp;lt; Prev| button&amp;amp;rdquo; to yes and note the SID.&lt;br /&gt;
#Add a new group called &amp;amp;ldquo;Group 1&amp;amp;rdquo; and note the GID.&lt;br /&gt;
#Add a new question &amp;amp;ldquo;Percent of males&amp;amp;rdquo; of type &amp;amp;ldquo;numeric&amp;amp;rdquo;, make it mandatory and note the QID (we will refer to this as QID1).&lt;br /&gt;
#Add a new question &amp;amp;ldquo;Percent of females&amp;amp;rdquo; of type &amp;amp;ldquo;numeric&amp;amp;rdquo;, make it mandatory and note the QID (we will refer to this as QID2).&lt;br /&gt;
#Add a new group called &amp;amp;ldquo;Group 2&amp;amp;rdquo;&lt;br /&gt;
#Add a new non mandatory question, here is the trick the question text has to be (be sure to replace the SID, GID, QID1 and QID2&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
function validation()&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   if [[{INSERTANS:SIDXGIDXQID1}+{INSERTANS:SIDXGIDXQID2}) != 100)&lt;br /&gt;
&lt;br /&gt;
   {&lt;br /&gt;
&lt;br /&gt;
     alert(&amp;quot;Your responses don&#039;t sum 100! Check them&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
     document.limesurvey.move.value = &#039;moveprev&#039;;&lt;br /&gt;
&lt;br /&gt;
     document.limesurvey.submit();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   else&lt;br /&gt;
&lt;br /&gt;
   {&lt;br /&gt;
&lt;br /&gt;
     document.limesurvey.move.value = &#039;movelast&#039;;&lt;br /&gt;
&lt;br /&gt;
     document.limesurvey.submit();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 setTimeout(&amp;quot;validation()&amp;quot;,250);&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 But this will show shortly the question and will jump to the end page, a little weird for the survey taker but works.&lt;br /&gt;
&lt;br /&gt;
 This is a proof of concept, and may have some problems, please if you notice something or improve it send me an e-mail to leochaton-limesurvey at yahoo dot com.&lt;br /&gt;
&lt;br /&gt;
 This will work for 2 questions that you want to be the same.  Works well for email and confirm email questions&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  function validation() {&lt;br /&gt;
&lt;br /&gt;
  if (&amp;quot;{INSERTANS:SIDXGIDXQID}&amp;quot; != &amp;quot;{INSERTANS:SIDXGIDXQID}&amp;quot;) {&lt;br /&gt;
&lt;br /&gt;
     alert(&amp;quot;Your responses don&#039;t match Check them&amp;quot;); document.limesurvey.move.value = &#039;moveprev&#039;;&lt;br /&gt;
&lt;br /&gt;
     document.limesurvey.submit();&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  setTimeout(&amp;quot;validation()&amp;quot;,250);&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 =Alternate exit=&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with: &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 Using the same idea of the previous post, you can implement an alternate exit of your survey.&lt;br /&gt;
&lt;br /&gt;
 This script should be in the first question to be displayed in a next page after the question that should trigger the alternate exit. In this example the question that trigger the alternate exit is a Yes/No question, if the user chooses no, he is redirected to another page.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 if (&amp;quot;{INSERTANS:SIDXGIDXQID}&amp;quot; == &amp;quot;No&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
&lt;br /&gt;
   window.location=&amp;quot;http://www.limesurvey.org&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 =Custom onload function=&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with: &#039;All browsers&#039;, LimeSurvey 1.70 and up&lt;br /&gt;
&lt;br /&gt;
 ==General==&lt;br /&gt;
&lt;br /&gt;
 This simple workaround describes how to &#039;&#039;&#039;add a custom Javascript code&#039;&#039;&#039; that is triggered right after the page is loaded. It may have numerous applications, especially when you deal with a custom JS/HTML code. It may be used to hide form elements (&amp;lt;input&amp;gt;  tags), make them read-only, display alert messages, etc.&lt;br /&gt;
&lt;br /&gt;
 To run any Javascript code right after page load use the Query ready() function. It will be executed when the page is being loaded. For example when you add the following code to one of your question definitions...:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 jQuery(document).ready(&lt;br /&gt;
&lt;br /&gt;
    function(){&lt;br /&gt;
&lt;br /&gt;
        alert(&#039;onload alert!&#039;);&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
 );&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ...it will display a pop-up message immediately after the page has been loaded.&lt;br /&gt;
&lt;br /&gt;
 Some of the applications of this trick I&#039;ve explored are:&lt;br /&gt;
&lt;br /&gt;
 a) Hiding the form elements by calling in your Custom_On_Load:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;document.getElementById(&amp;quot;answer73166X16X54&amp;quot;).style.display=&#039;none&#039;;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 Note: As of svn build 9755, you can now dynamically reference the questions input fields by using the {SGQ} keyword. You can rewrite the previous example like this:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;document.getElementById(&amp;quot;answer{SGQ}&amp;quot;).style.display=&#039;none&#039;;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 this makes it a little easier when exporting surveys, so you don&#039;t have to worry about manually entering each questions SurveyGroupQuestion ID.&lt;br /&gt;
&lt;br /&gt;
 b) Making the elements read only:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;document.getElementById(&amp;quot;answer73166X16X54&amp;quot;).readOnly=true;&amp;lt;/syntaxhighlight&amp;gt; where the &amp;quot;answer73166X16X54&amp;quot; structure has been described in one of other workarounds above.&lt;br /&gt;
&lt;br /&gt;
 c) For Hiding by a lot of elements by calling in your Customer_On_Load&lt;br /&gt;
&lt;br /&gt;
 jQuery searchs in html document for input-fields with radio type, if his answer text empty then do the display css set to none.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 jQuery(document).ready(&lt;br /&gt;
&lt;br /&gt;
            function() {&lt;br /&gt;
&lt;br /&gt;
              jQuery(&#039;input:radio&#039;).each(&lt;br /&gt;
&lt;br /&gt;
                function() {&lt;br /&gt;
&lt;br /&gt;
                  var s = jQuery(this);&lt;br /&gt;
&lt;br /&gt;
                  var c = s.parent().children(&#039;.answertext&#039;);&lt;br /&gt;
&lt;br /&gt;
                  for(var i=0; i &amp;lt; c.length; i++) {&lt;br /&gt;
&lt;br /&gt;
                    var a = jQuery(c[i]]);&lt;br /&gt;
&lt;br /&gt;
                    if(this.id &amp;lt;/u&amp;gt; a.attr(&#039;for&#039;) &amp;amp;&amp;amp; a.text() == &#039;&#039;) {&lt;br /&gt;
&lt;br /&gt;
                      s.css({ &#039;display&#039; : &#039;none&#039; });&lt;br /&gt;
&lt;br /&gt;
                      a.css({ &#039;display&#039; : &#039;none&#039; });&lt;br /&gt;
&lt;br /&gt;
                      break;&lt;br /&gt;
&lt;br /&gt;
                    }&lt;br /&gt;
&lt;br /&gt;
                  }&lt;br /&gt;
&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
              )&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
          );&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ==Advanced usage==&lt;br /&gt;
&lt;br /&gt;
 If you want to place global Javascript code using the above jQuery(document).ready function then the best place to do this is the template javascript file template.js. You can edit this file using the template editor. Please be aware that placing it in the template javascript file will make the function available to all surveys using that template. If needed just create a new template copy for your survey.&lt;br /&gt;
&lt;br /&gt;
 Alternatively you can place the jQuery(document).ready function in the group description to make a Javascript function only available to a certain question group.&lt;br /&gt;
&lt;br /&gt;
 ==Language-specific Javascript code==&lt;br /&gt;
&lt;br /&gt;
 There is an easy way to find out the current language and execute according Javascript using jQuery: The &amp;lt;html&amp;gt; tag of any survey pages contains an &#039;lang&#039; attribute which holds the current language code. You can read that language code by using the followin code&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 jQuery(document).ready(&lt;br /&gt;
&lt;br /&gt;
    function(){&lt;br /&gt;
&lt;br /&gt;
        languagecode=$(&#039;html&#039;).attr(&#039;lang&#039;);&lt;br /&gt;
&lt;br /&gt;
        alert(&#039;This is the current language code: &#039;+languagecode);&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
 );&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 For an English survey the above code would show a messagebox with &amp;quot;This is the current language code: en&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 =Custom onload function in multi-language survey=&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with: 1.85+ (7253), IE 6/7, FireFox 3.0, Safari 3.2,&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 To use custom onload functions, as above, in multi-language surveys you must define the functions in the question source for &#039;&#039;&#039;all&#039;&#039;&#039; languages.&lt;br /&gt;
&lt;br /&gt;
 While this initially seems to be a bit tedious, it actually can be useful - you can alter your onload functions depending on the language in use. For example, you can dynamically display alerts or element contents in the current language.&lt;br /&gt;
&lt;br /&gt;
 =Skipping the welcome page=&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with: 1.85 (second code snippet)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;Note: As of version 1.91, there is a survey option letting you skip the welcome page, so this workaround is not needed.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Solution 1:&#039;&#039;&#039; Include this Javascript in your welcome template, in the file welcome.pstpl for all welcome page, or in the source of the welcome text for one survey:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 jQuery(document).ready(function($) {&lt;br /&gt;
&lt;br /&gt;
 document.limesurvey.move.value = &#039;movenext&#039;;&lt;br /&gt;
&lt;br /&gt;
 document.limesurvey.submit(); });&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 It will reproduce the onclick event of the submit button and submit the form.&lt;br /&gt;
&lt;br /&gt;
 Drawback of course is that users will see the page flashing up.&lt;br /&gt;
&lt;br /&gt;
 Therefore, you may want to announce &amp;quot;... loading survey ...&amp;quot; as a description of your welcome page (in the admin interface when creating the survey), to pretend loading something big.&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Solution 2:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 function custom_on_load(){&lt;br /&gt;
&lt;br /&gt;
   document.limesurvey.move.value = &#039;movenext&#039;;&lt;br /&gt;
&lt;br /&gt;
   document.limesurvey.submit();&lt;br /&gt;
&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 window.setTimeout( &#039;custom_on_load()&#039;,1);&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 =Filter answers of a question with the answer of another=&lt;br /&gt;
&lt;br /&gt;
 ===Method 1===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with: 1.70 - 1.72&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, this is easier to do using the the array_filter attribute, or relevance equations in general.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 If you want to filter the answer of a question with another answer, you can use this workaround.&lt;br /&gt;
&lt;br /&gt;
 First, use answer code like that: XX for the first question, and XXYYY for the second one.&lt;br /&gt;
&lt;br /&gt;
 Answer of the second question filter if the 2 first letters are the answer of the first question.&lt;br /&gt;
&lt;br /&gt;
 We use 1000X1X1 and 1000X1X2 for the example, question had to be on separate page (question by question for example).The second question had to be a dropdown list (we can do similar workaround, but droplis is the best). You can do this using JQuery.  It leaves the answer in the select box, but disables it.  You could also replace &amp;quot;disable&amp;quot; with &amp;quot;remove&amp;quot; to get rid of it altogether.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 var previousQuestionAnswer = &amp;quot;{INSERTANS:1000X1X1}&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
 var currentQuestionID = &amp;quot;#answer1000X1X1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
    // See if the answer for the previous question matches an answer in the current question&lt;br /&gt;
&lt;br /&gt;
    // (other than &#039;No Answer&#039;)&lt;br /&gt;
&lt;br /&gt;
    // If so, disable it.&lt;br /&gt;
&lt;br /&gt;
    if (previousQuestionAnswer!=&#039;No Answer&#039;) {&lt;br /&gt;
&lt;br /&gt;
        $(currentQuestionID).children().each(function(index, Element)&lt;br /&gt;
&lt;br /&gt;
        {&lt;br /&gt;
&lt;br /&gt;
            if ($(this).attr(&#039;text&#039;) == previousQuestionAnswer)&lt;br /&gt;
&lt;br /&gt;
                { $(this).attr(&#039;disabled&#039;, true); }&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
        );}&lt;br /&gt;
&lt;br /&gt;
 }); // End of JQuery ready function&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ===Method 2===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with 1.92 + Firefox 9.0&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 If you have a country, state, and city set of questions (or similar), you could code answer options as:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Q1 Country&#039;&#039;&#039; &#039;&#039;Single choice list (ratio, dropdown)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 X country#&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Q2 State&#039;&#039;&#039; &#039;&#039;Single choice list (dropdown)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 XY state#&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Q3 City&#039;&#039;&#039; &#039;&#039;Single choice list (dropdown)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 XYZZ city#&lt;br /&gt;
&lt;br /&gt;
 Now you must put the following Javascript code in the source of question 2 (State):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
        // Get the countryCode (first character of the country)&lt;br /&gt;
&lt;br /&gt;
        var countryCode = &#039;{INSERTANS:1000X1X1}&#039;.substr(0, 1).toUpperCase();&lt;br /&gt;
&lt;br /&gt;
        // Loop through all dropdown options and remove those with codes not starting with the countryCode&lt;br /&gt;
&lt;br /&gt;
        $(&#039;select[id&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&amp;quot;answer&amp;quot;] option&#039;).each(function(i){&lt;br /&gt;
&lt;br /&gt;
            if($(this).attr(&#039;value&#039;)  &amp;amp;&amp;amp; $(this).attr(&#039;value&#039;).substr(0, 1).toUpperCase() != countryCode) {&lt;br /&gt;
&lt;br /&gt;
                $(this).remove();&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
        });&lt;br /&gt;
&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 And the following code in the source of question 3 (City):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
        // Get the stateCode (two first characters of the state)&lt;br /&gt;
&lt;br /&gt;
        var stateCode = &#039;{INSERTANS:1000X1X2}&#039;.substr(0, 2).toUpperCase();&lt;br /&gt;
&lt;br /&gt;
        // Loop through all dropdown options and remove those with codes not starting with the stateCode&lt;br /&gt;
&lt;br /&gt;
        $(&#039;select[id&amp;lt;/div&amp;gt;=&amp;quot;answer&amp;quot;] option&#039;).each(function(i){&lt;br /&gt;
&lt;br /&gt;
            if($(this).attr(&#039;value&#039;)  &amp;amp;&amp;amp; $(this).attr(&#039;value&#039;).substr(0, 2).toUpperCase() != stateCode) {&lt;br /&gt;
&lt;br /&gt;
                $(this).remove();&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
        });&lt;br /&gt;
&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 Each question must be in different pages of survey to work, i.e. in a question by question survey, or in diferent groups in a group by group survey.&lt;br /&gt;
&lt;br /&gt;
 Note that if you choose a two characters answer option code in the State question, i.e. a XYY answer option code, you must change the &#039;&#039;substr(0, 2)&#039;&#039; part of code in question 3 to &#039;&#039;substr(0, 3)&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 =Filter answers of a multiple numeric type question=&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with: 1.90+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, this is easier to do using the the array_filter attribute, or relevance equations in general.  In 1.92, array_filter works with all questions that have sub-questions (e.g. also works for multiple numeric and multiple short text).&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 If you want to filter a question of type &amp;quot;multiple numeric&amp;quot;, you have to modify the workaround.&lt;br /&gt;
&lt;br /&gt;
 Note that this workaround assumes that the code for each of the subquestions are a numeric sequence 1,2,3...&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $(document).ready(function(){&lt;br /&gt;
&lt;br /&gt;
    // Match elements with labels using htmlFor and a loop&lt;br /&gt;
&lt;br /&gt;
    var labels = document.getElementsByTagName(&#039;LABEL&#039;);&lt;br /&gt;
&lt;br /&gt;
    for (var i = 0; i &amp;lt; labels.length; i++) {&lt;br /&gt;
&lt;br /&gt;
        if (labels[i].htmlFor != &#039;&#039;) {&lt;br /&gt;
&lt;br /&gt;
             var elem = document.getElementById(labels[i].htmlFor);&lt;br /&gt;
&lt;br /&gt;
             if (elem)&lt;br /&gt;
&lt;br /&gt;
                elem.label = labels[i];&lt;br /&gt;
&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    var answerFilter=&amp;quot;{INSERTANS:96553X63X759}&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
    for (i=0; i&amp;lt;30; i++){&lt;br /&gt;
&lt;br /&gt;
      var iLabel = document.getElementById(&#039;answer96553X63X760&#039;+(i+1]].label.innerHTML;&lt;br /&gt;
&lt;br /&gt;
     if (answerFilter.search(iLabel) == -1){&lt;br /&gt;
&lt;br /&gt;
       // Hide element&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question760&#039;).find(&#039;li&#039;).eq(i).hide();&lt;br /&gt;
&lt;br /&gt;
       // Set value of hidden elements to zero&lt;br /&gt;
&lt;br /&gt;
       document.getElementById(&#039;answer96553X63X760&#039;+(i+1)).value = 0;&lt;br /&gt;
&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
 });&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Use an answer to prefill another question (default value)=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.72&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;And tested with: 1.91+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, this is easier to do using the enhanced defaults feature, which lets you pre-fill most question types with default values.  In 1.91, you could set defaults for list and multiple choice questions.  In 1.92, you can set defaults for any text-entry question too.  Moreover, the defaults can be [[Expression Manager|Expression Manager]] compatible equations or tailored text.  Finally, with 1.92, defaults are properly managed even when set on the same page.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround gives you the ablility to use an answer to fill the default value for another question. It&#039;s explained for free text question type but can be adapted for another question type.&lt;br /&gt;
&lt;br /&gt;
We use SGQA identifier. For example, we use SGQA 1000X10X20 and 1000X10X21 to prefill 1000X11X30 and 1000X11X31. For the script to work, the question has to be on a different page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
 $(&#039;#answer1000X11X30&#039;).val(&#039;{INSERTANS:1000X10X20}&#039;);&lt;br /&gt;
&lt;br /&gt;
 $(&#039;#answer1000X11X31&#039;).val(&#039;{INSERTANS:1000X10X21}&#039;);&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want use two times the value of an integer input, you can also use this to prefill a question that you hide via CSS.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
 $(&#039;#answer1000X2X2&#039;).val(parseInt(&#039;{INSERTANS:1000X1X1}&#039;)*2);&lt;br /&gt;
&lt;br /&gt;
 $(&amp;quot;#question2&amp;quot;).hide();&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you can use {INSERTANS:1000X2X2} for giving you twice the value of the user input from question 1.&lt;br /&gt;
&lt;br /&gt;
=Dynamic Sum=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, this is easier to do with [[Expression Manager|Expression Manager]] using the sum() function.  Not only will sums be dynamic, but they wille exclude irrelevant values, so you can array_filter a multiple numeric question and get the sum of just the answers that are visible.  This [[Expression Manager HowTos|#Calculate assessment values at runtime and store the results in the survey data|HowTo example]] demonstrates the dynamic sum feature.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;Also note, as of version 1.92, the following workaround will fail, since it includes a a regular expression containing curly braces.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This script is used with a &amp;quot;Multiple Options&amp;quot; type question calculate a total price based on how which checkboxes are selected. The prices are listed as part of the answer. The answers are set up like this: &amp;quot;USB Mouse ($20)&amp;quot;. The script uses the number between the &amp;quot;($&amp;quot; and the &amp;quot;)&amp;quot; as the price for that item. You can adapt the script to if you need to change the currency or need to sum something other than money.&lt;br /&gt;
&lt;br /&gt;
This script works when used in a question-by-question format.  It does not work when there are more than one question on a page. I think it can be adapted to work, but I haven&#039;t done the coding yet.&lt;br /&gt;
&lt;br /&gt;
Put the following code into body of your question:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script language=Javascript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// General definitions&lt;br /&gt;
&lt;br /&gt;
// Define a regular expression to match the labels containing information about an answer&lt;br /&gt;
&lt;br /&gt;
// In LimeSurvey, these labels start with &amp;quot;answer...&amp;quot;&lt;br /&gt;
&lt;br /&gt;
var answerRegex = /^answer/;&lt;br /&gt;
&lt;br /&gt;
// Find all answer checkboxes in the document and set their&lt;br /&gt;
&lt;br /&gt;
// onchange events to updatePrice&lt;br /&gt;
&lt;br /&gt;
function Custom_On_Load()&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   // Find all input elements&lt;br /&gt;
&lt;br /&gt;
   var inputList=document.getElementsByTagName(&amp;quot;input&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
   // Loop through each, looking for checkboxes&lt;br /&gt;
&lt;br /&gt;
   var i;&lt;br /&gt;
&lt;br /&gt;
   for( i=0; i&amp;lt; inputList.length;i++ )&lt;br /&gt;
&lt;br /&gt;
   {&lt;br /&gt;
&lt;br /&gt;
       // If input item does not have an ID, skip&lt;br /&gt;
&lt;br /&gt;
       if (! (inputList[i].id)) { continue; }&lt;br /&gt;
&lt;br /&gt;
       // Skip to next if ID doesn&#039;t start with &amp;quot;answer&amp;quot;&lt;br /&gt;
&lt;br /&gt;
       if (!answerRegex.test(inputList[i].id)) { continue; }&lt;br /&gt;
&lt;br /&gt;
       // Skip to next if not a checkbox&lt;br /&gt;
&lt;br /&gt;
       if (inputList[i].type.toUpperCase()!=&#039;CHECKBOX&#039;)  { continue; }&lt;br /&gt;
&lt;br /&gt;
       // This is an answer checkbox!&lt;br /&gt;
&lt;br /&gt;
       // Setup onchange event&lt;br /&gt;
&lt;br /&gt;
       inputList[i].onclick = updatePrice;&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
       // Load initial sum&lt;br /&gt;
&lt;br /&gt;
   updatePrice();&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function updatePrice()&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
var labels=document.getElementsByTagName(&amp;quot;LABEL&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
// Define a regular expression to match a price inside parenthesis&lt;br /&gt;
&lt;br /&gt;
// For example: ($29) or ($29.54).&lt;br /&gt;
&lt;br /&gt;
// Set up&lt;br /&gt;
&lt;br /&gt;
priceRegex = /\(\$(\d*\.{0,1}\d+)\)/;&lt;br /&gt;
&lt;br /&gt;
// Loop through all the labels, looking for labels corresponding to&lt;br /&gt;
&lt;br /&gt;
// answers that have a price in them.&lt;br /&gt;
&lt;br /&gt;
var i;&lt;br /&gt;
&lt;br /&gt;
var total = 0;&lt;br /&gt;
&lt;br /&gt;
for( i=0; i&amp;lt;labels.length;i++ )&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   var myArray;    // Define array used for regex matching&lt;br /&gt;
&lt;br /&gt;
   var inputID;    // Define field element&lt;br /&gt;
&lt;br /&gt;
   // Get the ID of the field corresponding to the label using the&lt;br /&gt;
&lt;br /&gt;
   // &amp;quot;htmlFor&amp;quot; attribute&lt;br /&gt;
&lt;br /&gt;
   // (FYI, there are some labels that will have to be screened out&lt;br /&gt;
&lt;br /&gt;
   // because they don&#039;t correspond to an answer)&lt;br /&gt;
&lt;br /&gt;
   // Does the label start with &amp;quot;answer&amp;quot;?&lt;br /&gt;
&lt;br /&gt;
   // If not: exit.&lt;br /&gt;
&lt;br /&gt;
   if (!answerRegex.test(labels[i].htmlFor)) { continue; }&lt;br /&gt;
&lt;br /&gt;
   // First make sure this element exists&lt;br /&gt;
&lt;br /&gt;
   // If it doesn&#039;t, go to the next element&lt;br /&gt;
&lt;br /&gt;
   // If it does, it will be defined in inputID&lt;br /&gt;
&lt;br /&gt;
   if (! (inputID = document.getElementById(labels[i].htmlFor)) ) { continue; }&lt;br /&gt;
&lt;br /&gt;
   // See if the corresponding answer is a checkbox that is checked.&lt;br /&gt;
&lt;br /&gt;
   // If not, go to next label&lt;br /&gt;
&lt;br /&gt;
   if (inputID.type.toUpperCase()!=&#039;CHECKBOX&#039;)  { continue; }&lt;br /&gt;
&lt;br /&gt;
   if (!inputID.checked) { continue; }&lt;br /&gt;
&lt;br /&gt;
   // This is label for an answer.&lt;br /&gt;
&lt;br /&gt;
   // The innerHTML will give us the text of the label&lt;br /&gt;
&lt;br /&gt;
   // The price information will be in the form ($XX.XX)&lt;br /&gt;
&lt;br /&gt;
   // which in contained in the label text.&lt;br /&gt;
&lt;br /&gt;
   // Find a match for a decimal number inside the pattern &amp;quot;($&amp;quot; and &amp;quot;)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   if [[myArray = priceRegex.exec(labels[i].innerHTML]] != null)&lt;br /&gt;
&lt;br /&gt;
   {&lt;br /&gt;
&lt;br /&gt;
       // Keep a running tally&lt;br /&gt;
&lt;br /&gt;
       total += parseFloat(myArray[1]);&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
  // Update total price on form&lt;br /&gt;
&lt;br /&gt;
  document.getElementById(&amp;quot;totalPrice&amp;quot;).value = &amp;quot;$&amp;quot; + formatCurrency(total);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function formatCurrency(num) {&lt;br /&gt;
&lt;br /&gt;
  num = isNaN(num) || num &amp;lt;u&amp;gt; &#039;&#039; || num &amp;lt;/u&amp;gt; null ? 0.00 : num;&lt;br /&gt;
&lt;br /&gt;
  return parseFloat(num).toFixed(2);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Put the following code in the help section (or wherever you want the sum to appear):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;Total Cost for selected accessories: &amp;lt;input type=&amp;quot;readonly&amp;quot; value=&amp;quot;&amp;quot; id=&amp;quot;totalPrice&amp;quot; /&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Focus on the first Input field=&lt;br /&gt;
&lt;br /&gt;
(&#039;&#039;Tested with: Limesurvey 1.80 / IE6/7, Firefox 3, Safari, Opera, chrome&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.91, there is a built-in JavaScript function called  focusFirst() to focus on the first visible element.  It uses jQuery, so is more robust than this example.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again an onload Function is needed for this tasks. I have done it the DOM way with compatibility to IE6/7.&lt;br /&gt;
&lt;br /&gt;
Put the following code into the startpage.pstpl of your template, right before the &amp;lt;/head&amp;gt; closing tag:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   function focusFirst(Event)&lt;br /&gt;
&lt;br /&gt;
   {&lt;br /&gt;
&lt;br /&gt;
       var i=0;&lt;br /&gt;
&lt;br /&gt;
       while(document.forms[0].elements[i].type == &amp;quot;hidden&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
       {&lt;br /&gt;
&lt;br /&gt;
           i++;&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       document.forms[0].elements[i].focus();&lt;br /&gt;
&lt;br /&gt;
       return;&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   if(ie)&lt;br /&gt;
&lt;br /&gt;
   { window.attachEvent(&amp;quot;onload&amp;quot;, focusFirst); }&lt;br /&gt;
&lt;br /&gt;
   else&lt;br /&gt;
&lt;br /&gt;
   { document.addEventListener(&amp;quot;load&amp;quot;, focusFirst, true); }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; I am using this with version 1.80. As changes happened to the templates in the last release, you might need to add the following before the code, if your template is older than 1.80 stable and does not include this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   var ie = false;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will need this for the var ie to be set. Without this var, the function will not work with ie.&lt;br /&gt;
&lt;br /&gt;
=Answer questions by keypress=&lt;br /&gt;
&lt;br /&gt;
(&#039;&#039;Tested with: IE7, Firefox 3&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
This workaround allow to answer the question on key 0-9 (0 is for the 10 answer).&lt;br /&gt;
&lt;br /&gt;
Follow issues are supported at the moment:&lt;br /&gt;
*Yes-No Questions&lt;br /&gt;
*List Questions (radio)&lt;br /&gt;
*other radio questions&lt;br /&gt;
&lt;br /&gt;
In lists the answer limit is ten.&lt;br /&gt;
&lt;br /&gt;
You supply the template &amp;quot;endpage&amp;quot; of your template with the following script.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
jQuery(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
   jQuery(document).bind(&#039;keypress&#039;, function(e){&lt;br /&gt;
&lt;br /&gt;
       if (48 &amp;lt;= e.which &amp;amp;&amp;amp; e.which &amp;lt;= 57) {&lt;br /&gt;
&lt;br /&gt;
           jQuery(&#039;input:radio&#039;).each(function() {&lt;br /&gt;
&lt;br /&gt;
               var v = jQuery(this).val();&lt;br /&gt;
&lt;br /&gt;
               var c = (e.which &amp;lt;u&amp;gt; 48) ? 10 : e.which - 48;&lt;br /&gt;
&lt;br /&gt;
               if(v &amp;lt;/u&amp;gt; &#039;Y&#039; || v &amp;lt;u&amp;gt; &#039;N&#039;) {&lt;br /&gt;
&lt;br /&gt;
                   v = (v &amp;lt;/u&amp;gt; &#039;Y&#039;) ? 1 : 2;&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               if(v == c) {&lt;br /&gt;
&lt;br /&gt;
                   jQuery(this).click();&lt;br /&gt;
&lt;br /&gt;
                   jQuery(&#039;#limesurvey input:submit&#039;).click();&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   })&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Math notation in LimeSurvey=&lt;br /&gt;
#download the js file from [http://mathcs.chapman.edu/~jipsen/mathml/asciimathdownload.html AsciiMath script]&lt;br /&gt;
#copy it in the /scripts/ folder in your installation&lt;br /&gt;
#modify the startpage.psptl of the template you want to use adding the reference to the script (if you use an older version make sure that you copy the template folder first!) for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;ASCIIMathML.js&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the notation where you need it!&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; If you use internet explorer or safari you will need to download the plugin as well, but firefox does the lot for you.&lt;br /&gt;
&lt;br /&gt;
Finally, if you are confident with the limesurvey structure you could add the editor which support math notation and change the reference to the editor you want to use in the configuration file. here is the [http://www.imathas.com/editordemo/demo.html link for a TinyMCE with math support].&lt;br /&gt;
&lt;br /&gt;
=Reverse array_filter (for pre-1.90)=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.85+ (7253), IE 6/7, FireFox 3.0, Safari 3.2, Chrome 2.0&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;Note: Version 1.91 natively supports this functionality via the array_filter_exclude advanced quation option.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This can be used to filter the answers of an array question to be displayed based on the answers of a multi option question that were &#039;&#039;&#039;NOT&#039;&#039;&#039; selected. A possible application would be to have a multi-option question asking which products were purchased, followed by 2 array questions - one asking to rate the purchased products and another asking why the remaining products were not purchased. Another would be to ask about sessions attended at a conference as in [http://www.limesurvey.org/en/support/forums/5-can-i-do-this-with-limesurvey/27970-reverse-of-arrayfilter.html this forum thread] and pictured below. There is a live [http://www.partnersinc.biz/surveys//index.php?sid=43358&amp;amp;newtest;=Y&amp;amp;lang;=en demo here]&lt;br /&gt;
&lt;br /&gt;
[[File:sessions_645x344.gif]]&lt;br /&gt;
&lt;br /&gt;
We&#039;ll use the above example to explain the process as follows:&lt;br /&gt;
#In group 1 - Create a &#039;&#039;SessionsAttended&#039;&#039; multi-options question&lt;br /&gt;
#In group 1 - Create a &#039;&#039;SessionsNotAttended&#039;&#039; multi-options question with identical answers as &#039;&#039;SessionsAttended&#039;&#039; and hide it with styles or conditions&lt;br /&gt;
#In group 2 - Create a &#039;&#039;RateSessionsAttended&#039;&#039; array question with an [http://docs.limesurvey.org/tiki-index.php?page=Question+attributes&amp;amp;structure;=English+Instructions+for+LimeSurvey#array_filter array_filter] based on &#039;&#039;SessionsAttended&#039;&#039;&lt;br /&gt;
#In group 2 - Create a &#039;&#039;ReasonNotAttended&#039;&#039; array question with an [http://docs.limesurvey.org/tiki-index.php?page=Question+attributes&amp;amp;structure;=English+Instructions+for+LimeSurvey#array_filter array_filter] based on &#039;&#039;SessionsNotAttended&#039;&#039;&lt;br /&gt;
#In group 1 - Place JavaScript/jQeury listeners on each of the checkboxes in &#039;&#039;SessionsAttended&#039;&#039; that would toggle the corresponding checkbox in &#039;&#039;SessionsNotAttended&#039;&#039; to the opposite state&lt;br /&gt;
&lt;br /&gt;
The JavaScript/jQuery code used would be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
       // The toggle function&lt;br /&gt;
&lt;br /&gt;
   function toggle(q1, q2) {&lt;br /&gt;
&lt;br /&gt;
       if ($(q1).attr(&#039;checked&#039;) == false ) {&lt;br /&gt;
&lt;br /&gt;
           $(q2).attr(&#039;checked&#039;, true);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       else {&lt;br /&gt;
&lt;br /&gt;
           $(q2).attr(&#039;checked&#039;, false);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   // Initialize the SessionNotAttended checkboxes to &amp;quot;checked&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   toggle (&#039;#answer11111X22X331&#039;, &#039;#answer11111X22X441&#039;);&lt;br /&gt;
&lt;br /&gt;
   toggle (&#039;#answer11111X22X332&#039;, &#039;#answer11111X22X442&#039;);&lt;br /&gt;
&lt;br /&gt;
   toggle (&#039;#answer11111X22X333&#039;, &#039;#answer11111X22X443&#039;);&lt;br /&gt;
&lt;br /&gt;
   toggle (&#039;#answer11111X22X334&#039;, &#039;#answer11111X22X444&#039;);&lt;br /&gt;
&lt;br /&gt;
   // The jQuery listeners on the SessionAttended checkboxes&lt;br /&gt;
&lt;br /&gt;
   // that toggle the SessionNotAttended checkboxes&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#answer11111X22X331&#039;).change(function() {&lt;br /&gt;
&lt;br /&gt;
       toggle (&#039;#answer11111X22X331&#039;, &#039;#answer11111X22X441&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#answer11111X22X332&#039;).change(function() {&lt;br /&gt;
&lt;br /&gt;
       toggle (&#039;#answer11111X22X332&#039;, &#039;#answer11111X22X442&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#answer11111X22X333&#039;).change(function() {&lt;br /&gt;
&lt;br /&gt;
       toggle (&#039;#answer11111X22X333&#039;, &#039;#answer11111X22X443&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#answer11111X22X334&#039;).change(function() {&lt;br /&gt;
&lt;br /&gt;
       toggle (&#039;#answer11111X22X334&#039;, &#039;#answer11111X22X444&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some notes about the code:&lt;br /&gt;
*The code is in an onload function defined in the first question of group 1 - see [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#Custom_onload_function workarounds here]&lt;br /&gt;
*Both &#039;&#039;SessionsAttended&#039;&#039; and &#039;&#039;SessionsNotAttended&#039;&#039; must be in the same group for the toggling to work&lt;br /&gt;
*This case only uses 4 checkboxes but could be expanded as required&lt;br /&gt;
*In this case the survey ID is 11111, the group ID is 22, &#039;&#039;SessionsAttended&#039;&#039; ID is 33 and SessionsNotAttended ID is 44 - these would need to be modified for your survey&lt;br /&gt;
*The toggle function looks for the state of a checkbox in &#039;&#039;SessionsAttended&#039;&#039; and sets the corresponding checkbox in &#039;&#039;SessionsNotAttended&#039;&#039; to the opposite state&lt;br /&gt;
*The &amp;quot;Initialize&amp;quot; section sets the state of &#039;&#039;SessionsNotAttended&#039;&#039; checkboxes whenever we navigate to the group&lt;br /&gt;
*The &amp;quot;Listener&amp;quot; section uses jQuery listeners to detect any change in the &#039;&#039;SessionsAttended&#039;&#039; checkboxes and then toggle the corresponding &#039;&#039;SessionsNotAttended&#039;&#039; checkbox&lt;br /&gt;
&lt;br /&gt;
Some general notes about the questions:&lt;br /&gt;
*CSS can be used to hide &#039;&#039;SessionsNotAttended&#039;&#039; (div#question44 { display: none; }) if you don&#039;t want to use conditions (because maybe you&#039;ve got [http://docs.limesurvey.org/tiki-index.php?page=Optional+settings&amp;amp;structure;=English+Instructions+for+LimeSurvey#Survey_Behavior $deletenonvalues set to 1])&lt;br /&gt;
*&#039;&#039;RateSessionsAttended&#039;&#039; and &#039;&#039;ReasonNotAttended&#039;&#039; are another group to avoid things popping in and out of existence as &#039;&#039;SessionsAttended&#039;&#039; is answered&lt;br /&gt;
*[http://docs.limesurvey.org/tiki-index.php?page=Setting+conditions&amp;amp;structure;=English+Instructions+for+LimeSurvey Conditions] are used to ensure that &#039;&#039;RateSessionsAttended&#039;&#039; only appears if some sessions are selected and &#039;&#039;ReasonNotAttended&#039;&#039; only appears if no sessions are selected&lt;br /&gt;
&lt;br /&gt;
=Filter Ranking Question With Multiple-Options=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90, IE 7/8, FireFox 3/4, Safari 5.0, Chrome 10.0&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, most of this is easier to do using the the array_filter attribute, or relevance equations in general.  They all work on the same page, and fully support cascading relevance.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround applies a filter to a ranking question based on the checked boxes of a previous multiple-options question. There are two methods - one for filter and ranking questions being on the same page and a slightly different one for the filter question being on a page before the ranking question.&lt;br /&gt;
&lt;br /&gt;
There is a [http://www.partnersinc.biz/surveys//index.php?sid=96314&amp;amp;newtest;=Y&amp;amp;lang;=en demo of both methods here].&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FOR BOTH METHODS:&#039;&#039;&#039;&lt;br /&gt;
*[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_ Set up your survey to use JavaScript].&lt;br /&gt;
*Place the following script in your template.js file. This function will be accessed by either method.&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// A function to filter choices in a ranking question&lt;br /&gt;
&lt;br /&gt;
function rankFilter(q1ID, q2ID, prevPage) {&lt;br /&gt;
&lt;br /&gt;
   // If filter question is on a previous page, hide Q1 and check all &amp;quot;visible&amp;quot; boxes&lt;br /&gt;
&lt;br /&gt;
   if(prevPage == 1) {&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q1ID+&#039; li[id&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&amp;quot;javatbd&amp;quot;]:visible input.checkbox&#039;).attr(&#039;checked&#039;, true);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q1ID+&#039;&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   handleChecked(q1ID, q2ID);&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#question&#039;+q1ID+&#039; input.checkbox&#039;).click(function() {&lt;br /&gt;
&lt;br /&gt;
       handleChecked(q1ID, q2ID);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   function handleChecked(q1ID, q2ID) {&lt;br /&gt;
&lt;br /&gt;
       // Find the survey and group IDs&lt;br /&gt;
&lt;br /&gt;
       if($( &#039;input#fieldnames&#039; ).length != 0) {&lt;br /&gt;
&lt;br /&gt;
           var fieldNames = $( &#039;input#fieldnames&#039; ).attr(&#039;value&#039;);&lt;br /&gt;
&lt;br /&gt;
           var tmp = fieldNames.split(&#039;X&#039;);&lt;br /&gt;
&lt;br /&gt;
           var sID = tmp[0];&lt;br /&gt;
&lt;br /&gt;
           var gID = tmp[1];&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       // Loop through all Q1 options&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q1ID+&#039; input.checkbox&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
           // Find the answer code and value&lt;br /&gt;
&lt;br /&gt;
           var tmp2 = $(this).attr(&#039;id&#039;).split(&#039;X&#039;+gID+&#039;X&#039;+q1ID+&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
           var ansCode = tmp2[1];&lt;br /&gt;
&lt;br /&gt;
           var ansTxt = $(this).next(&#039;label&#039;).text();&lt;br /&gt;
&lt;br /&gt;
           // If option is checked and not in rank choices or output, add it to the rank choices&lt;br /&gt;
&lt;br /&gt;
           if($(this).attr(&#039;checked&#039;) == true&lt;br /&gt;
&lt;br /&gt;
                          &amp;amp;&amp;amp; $(&#039;#question&#039;+q2ID+&#039; select.select option[value=&amp;quot;&#039;+ansCode+&#039;&amp;quot;]&#039;).length == 0&lt;br /&gt;
&lt;br /&gt;
                          &amp;amp;&amp;amp; $(&#039;#question&#039;+q2ID+&#039; .output input[id&amp;lt;/div&amp;gt;=&amp;quot;fvalue_&amp;quot;][value=&amp;quot;&#039;+ansCode+&#039;&amp;quot;]&#039;).length == 0) {&lt;br /&gt;
&lt;br /&gt;
               $(&#039;&amp;lt;option value=&amp;quot;&#039;+ansCode+&#039;&amp;quot;&amp;gt;&#039;+ansTxt+&#039;&amp;lt;/option&amp;gt;&#039;).appendTo(&#039;#question&#039;+q2ID+&#039; select.select&#039;);&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
           // If option is unchecked...&lt;br /&gt;
&lt;br /&gt;
           else if($(this).attr(&#039;checked&#039;) == false) {&lt;br /&gt;
&lt;br /&gt;
               // Remove it from the rank choices&lt;br /&gt;
&lt;br /&gt;
               $(&#039;#question&#039;+q2ID+&#039; select.select option[value=&amp;quot;&#039;+ansCode+&#039;&amp;quot;]&#039;).remove();&lt;br /&gt;
&lt;br /&gt;
               // Remove it from the rank output and reset hidden values&lt;br /&gt;
&lt;br /&gt;
$(&#039;#question&#039;+q2ID+&#039; .output input[id&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&amp;quot;fvalue_&amp;quot;][value=&amp;quot;&#039;+ansCode+&#039;&amp;quot;]&#039;).attr(&#039;value&#039;, &#039;&#039;).siblings(&#039;input.text&#039;).val(&#039;&#039;).siblings(&#039;img&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // Clean up empty inputs in the rank output table&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q2ID+&#039; .output table tr&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
           var nextRow = $(this).next(&#039;tr&#039;);&lt;br /&gt;
&lt;br /&gt;
           if($(&#039;input.text&#039;, this).val() == &#039;&#039; &amp;amp;&amp;amp; $(&#039;input.text&#039;, nextRow).val() != &#039;&#039;) {&lt;br /&gt;
&lt;br /&gt;
               $(&#039;input.text&#039;, this).val($(&#039;input.text&#039;, nextRow).val());&lt;br /&gt;
&lt;br /&gt;
               $(&#039;input.text&#039;, nextRow).val(&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
               $(&#039;input[id&amp;lt;/div&amp;gt;=&amp;quot;fvalue_&amp;quot;]&#039;, this).attr(&#039;value&#039;, $(&#039;input[id&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&amp;quot;fvalue_&amp;quot;]&#039;, nextRow).attr(&#039;value&#039;));&lt;br /&gt;
&lt;br /&gt;
               $(&#039;input[id&amp;lt;/div&amp;gt;=&amp;quot;fvalue_&amp;quot;]&#039;, nextRow).attr(&#039;value&#039;, &#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // Show the scissors for the last populated rank output row&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q2ID+&#039; .output table img[id&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&amp;quot;cut_&amp;quot;]&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q2ID+&#039; .output table input.text[value!=&amp;quot;&amp;quot;]:last&#039;).siblings(&#039;img[id&amp;lt;/div&amp;gt;=&amp;quot;cut_&amp;quot;]&#039;).show();&lt;br /&gt;
&lt;br /&gt;
       // Hide extra rank output rows&lt;br /&gt;
&lt;br /&gt;
       var optNum = $(&#039;#question&#039;+q1ID+&#039; input.checkbox:checked&#039;).length;&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q2ID+&#039; .output table tr&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q2ID+&#039; .output table tr:lt(&#039;+(optNum+1)+&#039;)&#039;).show();&lt;br /&gt;
&lt;br /&gt;
       // Hide and clear the ranking question if there are less than 2 checked options in Q1&lt;br /&gt;
&lt;br /&gt;
       if(optNum &amp;lt; 2) {&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+q2ID+&#039;&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+q2ID+&#039; input.text&#039;).val(&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+q2ID+&#039; input[id&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&amp;quot;fvalue_&amp;quot;]&#039;).attr(&#039;value&#039;, &#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       else {&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+q2ID+&#039;&#039;).show();&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       // A work around for the built in max-answers function&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q2ID+&#039; select.select&#039;).attr(&#039;disabled&#039;, true);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q2ID+&#039; td.output tr:visible&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
           if($(&#039;input.text&#039;, this).val() == &#039;&#039;) {&lt;br /&gt;
&lt;br /&gt;
               $(&#039;#question&#039;+q2ID+&#039; select.select&#039;).attr(&#039;disabled&#039;, false);&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   // A listener to work around the built in max-answers function&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#question&#039;+q2ID+&#039; td.rank&#039;).click(function (event) {&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q2ID+&#039; select.select&#039;).attr(&#039;disabled&#039;, true);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q2ID+&#039; td.item input.text&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
           if ($(this).val() == &#039;&#039;) {&lt;br /&gt;
&lt;br /&gt;
               $(&#039;#question&#039;+q2ID+&#039; select.select&#039;).attr(&#039;disabled&#039;, false);&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FOR BOTH FILTER AND RANKING QUESTIONS ON SAME PAGE:&#039;&#039;&#039;&lt;br /&gt;
*Create a multiple options question and a ranking question on the same page (in the same group).&lt;br /&gt;
*Both questions &#039;&#039;&#039;MUST&#039;&#039;&#039; have identical sub-questions and sub-question codes.&lt;br /&gt;
*Place the following script in the source of one of the questions.&lt;br /&gt;
*Replace &amp;quot;MM&amp;quot; with the ID of the multiple options question and &amp;quot;RR&amp;quot; with the ID of the ranking question.&lt;br /&gt;
*The function will hide the ranking question unless at least two options are selected in the multiple options question, in which case, it will only show the options selected.&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       rankFilter(MM, RR);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FOR FILTER AND RANKING QUESTIONS ON SEPARATE PAGES:&#039;&#039;&#039;&lt;br /&gt;
*Create a multiple options question on page 1.&lt;br /&gt;
*Create a multiple options question and a ranking question on page 2.&lt;br /&gt;
*All three questions &#039;&#039;&#039;MUST&#039;&#039;&#039; have identical sub-questions and sub-question codes.&lt;br /&gt;
*Set the multiple options on page 2 to be filtered by the multiple options on page 1.&lt;br /&gt;
*Place the following script in the source of one of the questions on page 2.&lt;br /&gt;
*Replace &amp;quot;MM&amp;quot; with the ID of the multiple options question and &amp;quot;RR&amp;quot; with the ID of the ranking question. Do not modify the &amp;quot;1&amp;quot;.&lt;br /&gt;
*The function will hide the multiple options question. If at least 2 options were selected in the multiple options on page 1, the corresponding options will be checked in the hidden multiple options question which will then be used to control the display of the ranking question.&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       rankFilter(MM, RR, 1);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Filter &amp;quot;Array by Column&amp;quot; Question With &amp;quot;Multiple-Options&amp;quot;=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.91, IE 7/8, FireFox 3/4, Safari 5.0, Chrome 10.0&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround applies a filter to an &amp;quot;Array by Column&amp;quot; question based on the checked boxes of a previous multiple-options question. There are two methods - one for filter and array questions being on the same page and a slightly different one for the filter question being on a page before the array question.&lt;br /&gt;
&lt;br /&gt;
There is a [http://www.partnersinc.biz/surveys//index.php?sid=74213&amp;amp;newtest;=Y&amp;amp;lang;=en demo of both methods here].&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FOR BOTH METHODS:&#039;&#039;&#039;&lt;br /&gt;
*[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_ Set up your survey to use JavaScript].&lt;br /&gt;
*Place the following scripts in your template.js file. These functions will be accessed by either method.&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
   function filterArrByCol(qMultiOpt, qArray, prevPage) {&lt;br /&gt;
&lt;br /&gt;
       // If filter question is on a previous page, hide Q1 and check all &amp;quot;visible&amp;quot; boxes&lt;br /&gt;
&lt;br /&gt;
       if(prevPage == 1) {&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qMultiOpt+&#039; li[id&amp;lt;/div&amp;gt;=&amp;quot;javatbd&amp;quot;]:visible input.checkbox&#039;).attr(&#039;checked&#039;, true);&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qMultiOpt+&#039;&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       // Assign classes to the answer cells&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+qArray+&#039; table.question tbody td&#039;).each(function(i){&lt;br /&gt;
&lt;br /&gt;
           var classArr = $(this).attr(&#039;class&#039;).split(&#039;answer_cell_00&#039;);&lt;br /&gt;
&lt;br /&gt;
           var ansCode = classArr[1];&lt;br /&gt;
&lt;br /&gt;
           $(this).addClass(&#039;ans-&#039;+ansCode+&#039; filtered&#039;);&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // Assign classes to the answer label cells&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+qArray+&#039; table.question tbody tr:eq(0) td&#039;).each(function(i){&lt;br /&gt;
&lt;br /&gt;
           var classArr2 = $(this).attr(&#039;class&#039;).split(&#039; ans-&#039;);&lt;br /&gt;
&lt;br /&gt;
           var ansCode2 = classArr2[1];&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qArray+&#039; table.question thead tr:eq(0) th:eq(&#039;+i+&#039;)&#039;).addClass(&#039;ans-&#039;+ansCode2+&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // Fire the filter function on page load&lt;br /&gt;
&lt;br /&gt;
       filterArr(qMultiOpt, qArray);&lt;br /&gt;
&lt;br /&gt;
       // Listener on multi-opt checkboxes to fire the filter function&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+qMultiOpt+&#039; input.checkbox&#039;).click(function(){&lt;br /&gt;
&lt;br /&gt;
           filterArr(qMultiOpt, qArray);&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // On submit, clear all hidden radios of array&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#movenextbtn, #movesubmitbtn&#039;).click(function(){&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qArray+&#039; td.filtered:hidden&#039;).each(function(i){&lt;br /&gt;
&lt;br /&gt;
               $(&#039;input.radio&#039;, this).attr(&#039;checked&#039;, false);&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           return true;&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   function filterArr(qMultiOpt, qArray) {&lt;br /&gt;
&lt;br /&gt;
       if($(&#039;#question&#039;+qMultiOpt+&#039; input.checkbox:checked&#039;).length &amp;lt; 1) {&lt;br /&gt;
&lt;br /&gt;
           // Hide the array if no multi-opt options are checked&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qArray+&#039;&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       else {&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qArray+&#039;&#039;).show();&lt;br /&gt;
&lt;br /&gt;
           // Hide all columns of array&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qArray+&#039; table.question tbody td, #question&#039;+qArray+&#039; table.question thead th&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
           // Loop through multi-opt checkboxes and, if checked, show corresponding column of array&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qMultiOpt+&#039; input.checkbox&#039;).each(function(i){&lt;br /&gt;
&lt;br /&gt;
               if($(this).attr(&#039;checked&#039;) == true) {&lt;br /&gt;
&lt;br /&gt;
                   var classArr3 = $(this).attr(&#039;id&#039;).split(&#039;X&#039;+qMultiOpt);&lt;br /&gt;
&lt;br /&gt;
                   var ansCode3 = classArr3[1];&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;#question&#039;+qArray+&#039; .ans-&#039;+ansCode3+&#039;&#039;).show();&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FOR BOTH FILTER AND ARRAY QUESTIONS ON SAME PAGE:&#039;&#039;&#039;&lt;br /&gt;
*Create a multiple options question and an array-by-column question on the same page (in the same group).&lt;br /&gt;
*Both questions &#039;&#039;&#039;MUST&#039;&#039;&#039; have identical sub-questions and sub-question codes.&lt;br /&gt;
*Place the following script in the source of one of the questions.&lt;br /&gt;
*Replace &amp;quot;MM&amp;quot; with the ID of the multiple options question and &amp;quot;AA&amp;quot; with the ID of the ranking question.&lt;br /&gt;
*The function will hide the array question unless at least one option is selected in the multiple-options question, in which case, it will only show the corresponding array column(s).&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       filterArrByCol(MM, AA);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FOR FILTER AND ARRAY QUESTIONS ON SEPARATE PAGES:&#039;&#039;&#039;&lt;br /&gt;
*Create a multiple options question on page 1.&lt;br /&gt;
*Create a multiple options question and an array-by-column question on page 2.&lt;br /&gt;
*All three questions &#039;&#039;&#039;MUST&#039;&#039;&#039; have identical sub-questions and sub-question codes.&lt;br /&gt;
*Set the multiple options on page 2 to be filtered by the multiple options on page 1.&lt;br /&gt;
*Place the following script in the source of one of the questions on page 2.&lt;br /&gt;
*Replace &amp;quot;MM&amp;quot; with the ID of the multiple options question and &amp;quot;AA&amp;quot; with the ID of the array question. Do not modify the &amp;quot;1&amp;quot;.&lt;br /&gt;
*The function will hide the multiple options question. If options were selected in the multiple options on page 1, the corresponding options will be checked in the hidden multiple options question which will then be used to control the display of the array columns.&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       filterArrByCol(MM, AA, 1);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Auto-tabbing between text input fields=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 6/7, FireFox 3.0, Safari 3.2, Chrome 2.0&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This is a workaround to facilitate auto-tabbing between text input questions in a single group using a [http://plugins.jquery.com/project/autotab jQuery plugin by Mathachew] and the Maximum characters attribute of questions.&lt;br /&gt;
&lt;br /&gt;
The behaviour will be: When the maximum number of characters has been entered into an input field, the focus (cursor) will be automatically moved to the next input field. When the backspace key is used to remove all characters from a field, the focus will be moved to the previous field. It&#039;s very useful in surveys having many text input questions to avoid having to manually tab or click between fields.&lt;br /&gt;
&lt;br /&gt;
You can view a small demo survey [http://www.partnersinc.biz/surveys//index.php?sid=11327&amp;amp;newtest;=Y&amp;amp;lang;=en here].&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#Visit [http://plugins.jquery.com/node/4046 http://plugins.jquery.com/node/4046], download the plugin script and save it as &#039;&#039;jquery.autotab-1.1b.js&#039;&#039; in the template folder.&lt;br /&gt;
#Link to the script by placing &#039;&#039;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;{TEMPLATEURL}jquery.autotab-1.1b.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&#039;&#039; within the &#039;&#039;&amp;lt;head&amp;gt;&#039;&#039; tag of startpage.pstpl.&lt;br /&gt;
#[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_ Set up your survey to use JavaScript].&lt;br /&gt;
#Create the text based questions that auto-tabbing is to be applied to. (All must be in the same group if you&#039;re using group by group presentation)&lt;br /&gt;
#Define a Maximum characters attribute for all questions that the autotab is applied to. (See [http://docs.limesurvey.org/tiki-index.php?page=Question+attributes&amp;amp;structure;=English+Instructions+for+LimeSurvey#maximum_chars documentation here])&lt;br /&gt;
#In the source of the first question of the group that contains the auto-tabbed questions, add the following code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#answerSSSSSXGGXAA&#039;).focus(); //initially focus on the first input&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#answerSSSSSXGGXAA&#039;).autotab({ target: &#039;answerSSSSSXGGXBB&#039; });&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#answerSSSSSXGGXBB&#039;).autotab({ previous: &#039;answerSSSSSXGGXAA&#039;, target: &#039;answerSSSSSXGGXCC&#039; });&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#answerSSSSSXGGXCC&#039;).autotab({ previous: &#039;answerSSSSSXGGXBB&#039;, target: &#039;answerSSSSSXGGXDD&#039; });&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#answerSSSSSXGGXDD&#039;).autotab({ previous: &#039;answerSSSSSXGGXCC&#039; });&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example has 4 fields to be auto-tabbed between - all instances of the following must be replaced to be compatible with your survey (See image below):&lt;br /&gt;
*SSSSS -&amp;gt; Survey ID&lt;br /&gt;
*GG -&amp;gt; Group ID&lt;br /&gt;
*AA -&amp;gt; First question&lt;br /&gt;
*BB -&amp;gt; Second question&lt;br /&gt;
*CC -&amp;gt; Third question&lt;br /&gt;
*DD -&amp;gt; Last question&lt;br /&gt;
&lt;br /&gt;
[[File:ids_343x252.gif]]&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;target&#039;&#039; parameter defines where the next input is and the &#039;&#039;previous&#039;&#039; parameter defines (you guessed it) the previous input.&lt;br /&gt;
&lt;br /&gt;
This plugin also has limited capability of formatting the input text - see comments in the plugin script.&lt;br /&gt;
&lt;br /&gt;
=Custom response listeners=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.85+ (7253), IE 6/7, FireFox 3.0, Safari 3.2, Chrome 2.0&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Listeners can be used to perform functions when a change in an input is detected. There are many uses such as the [http://docs.limesurvey.org/tiki-index.php?page=Workarounds#Reverse_array_filter Reverse array_filter] but a simple one would be to warn a respondent if they enter a value that may be too high.&lt;br /&gt;
&lt;br /&gt;
We can use the [http://docs.jquery.com/Events/change jQuery change( ) event] to fire a function whenever there is a change to the input. The function will look for an input value higher than 10 and, if found, will warn the respondent.&lt;br /&gt;
#[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_ Set up your survey to use JavaScript].&lt;br /&gt;
#Place the script below in the source of one of the questions on the page where:&lt;br /&gt;
**11111 is the survey ID&lt;br /&gt;
**22 is the group ID&lt;br /&gt;
**33 is the question ID&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#answer11111X22X33&#039;).change(function() {&lt;br /&gt;
&lt;br /&gt;
           if ( $(&#039;#answer11111X22X33&#039;).val() &amp;gt; 10 ) {&lt;br /&gt;
&lt;br /&gt;
               alert (&amp;quot;That&#039;s an awful lot. Are you sure?&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Text input masks=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 7, FireFox 3.0, Safari 3.2, Chrome 2.0&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;We&#039;re considering adding this as a built-in feature for version 1.92 (e.g. an advanced question attribute).&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There may be instances where you would like to place a mask on a text input - for example only allowing respondents to enter the correct characters for a North American phone number [[Expression Manager|Expression Manager]] rand() function.  This can be part of a relevance equation to randomly control which questions are shown; or you can create an Equation question type to store the random value, and let that question be part of downstream relevance equations.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround allows you to generate a random number and then populate a hidden question with that number. You can then use this question to control the display of subsequent questions with [http://docs.limesurvey.org/tiki-index.php?page=Setting+conditions&amp;amp;structure;=English+Instructions+for+LimeSurvey Conditions]. It&#039;s useful if you have several sets of questions that you would like to randomly present to participants - see this  [http://www.limesurvey.org/en/support/forums/5-can-i-do-this-with-limesurvey/29579-experiment-with-random-questions.html forum post].&lt;br /&gt;
&lt;br /&gt;
There is a small demo [http://www.partnersinc.biz/surveys//index.php?sid=12659&amp;amp;newtest;=Y&amp;amp;lang;=en here].&lt;br /&gt;
&lt;br /&gt;
In the demo, in the first group, we generate a random number between 1 and 4 and populate a hidden question with it. Then in the second group we have 4 questions, each showing conditional on the answer of the first question.&lt;br /&gt;
&lt;br /&gt;
Implementation for this demo is as follows:&lt;br /&gt;
#Turn off &#039;&#039;$filterxsshtml&#039;&#039; to allow insertion of JavaScript in the questions. (See [http://docs.limesurvey.org/tiki-index.php?page=Optional+settings&amp;amp;structure;=English+Instructions+for+LimeSurvey#Filtering_dangerous_HTML_tags_in_survey_objects documentation here])&lt;br /&gt;
#Set up the template to use custom onload functions. (See the [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#Custom_onload_function workaround here])&lt;br /&gt;
#In the first group add a &amp;quot;Short free text&amp;quot; question (We&#039;re going to hide this with JavaScript)&lt;br /&gt;
#In the source of that question add the following onload function. (See [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._ How to use script here])&lt;br /&gt;
#In the following groups add the questions that are conditional on the answer of the first question.&lt;br /&gt;
&lt;br /&gt;
Onload code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
function Custom_On_Load(){&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Find a random number between 1 and 4&lt;br /&gt;
&lt;br /&gt;
       var randNumber = Math.floor(Math.random()*4 + 1);&lt;br /&gt;
&lt;br /&gt;
       // Populate and hide the hidden question&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input#answerSSSSSXGGXQQ&#039;).val(randNumber);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#questionQQ&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
       /***********************************************************/&lt;br /&gt;
&lt;br /&gt;
       // This just tells the user which number has been selected&lt;br /&gt;
&lt;br /&gt;
       // You can remove this from your onload function&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input#setNumber&#039;).val(randNumber);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input#setNumber&#039;).css({&lt;br /&gt;
&lt;br /&gt;
           &#039;margin-left&#039;:&#039;0.5em&#039;,&lt;br /&gt;
&lt;br /&gt;
           &#039;width&#039;:&#039;1.5em&#039;,&lt;br /&gt;
&lt;br /&gt;
           &#039;text-align&#039;:&#039;center&#039;,&lt;br /&gt;
&lt;br /&gt;
           &#039;font-weight&#039;:&#039;bold&#039;&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input#setNumber&#039;).attr(&#039;disabled&#039;, true);&lt;br /&gt;
&lt;br /&gt;
       /***********************************************************/&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &#039;&#039;&#039;SSSSS&#039;&#039;&#039; is the survey ID, &#039;&#039;&#039;GG&#039;&#039;&#039; is the group ID and &#039;&#039;&#039;QQ&#039;&#039;&#039; is the hidden question ID.&lt;br /&gt;
&lt;br /&gt;
Increase or decrease the maximum value of the random number by modifying the first section. For example to get a number between 1 and 10 you would use this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
var randNumber = Math.floor(Math.random()*10 + 1);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The third section of code just populates a placeholder element that I use to tell the participant what&#039;s going on. You can remove it from your code.&lt;br /&gt;
&lt;br /&gt;
=Minimum number of required answers in an array=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 6/7, FireFox 3.0, Safari 3.2,&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92 all array style questions have the min_answers and max_answers options, so this script is obsolete.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround allows you to specify a &#039;&#039;&#039;minimum number&#039;&#039;&#039; of answers required in an array question. It is an alternative to the &amp;quot;Mandatory&amp;quot; parameter which specifies that &#039;&#039;&#039;all&#039;&#039;&#039; answers are required. It could also be easily modified to specify a maximum number of answers.&lt;br /&gt;
&lt;br /&gt;
We accomplish this by placing an onload function in the source of the array question. This function hides the Next/Submit button and displays a warning element until it detects a minimum number of responses. It then hides the warning and shows the Next/Submit button.&lt;br /&gt;
&lt;br /&gt;
There is a demo [http://www.partnersinc.biz/surveys//index.php?sid=97166&amp;amp;newtest;=Y&amp;amp;lang;=en here].&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#Turn off &#039;&#039;$filterxsshtml&#039;&#039; to allow insertion of JavaScript in the questions. (See [http://docs.limesurvey.org/tiki-index.php?page=Optional+settings&amp;amp;structure;=English+Instructions+for+LimeSurvey#Filtering_dangerous_HTML_tags_in_survey_objects documentation here])&lt;br /&gt;
#Set up the template to use custom onload functions. (See the [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#Custom_onload_function workaround here])&lt;br /&gt;
#In the source of the array question add the following onload function. (See [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._ How to use script here])&lt;br /&gt;
#Modify the &#039;&#039;SETTINGS&#039;&#039; section of the code as required.&lt;br /&gt;
&lt;br /&gt;
Onload code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Wait until the document is fully loaded&lt;br /&gt;
&lt;br /&gt;
$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
   /********************** SETTINGS **********************/&lt;br /&gt;
&lt;br /&gt;
   // The text to appear in the warning element&lt;br /&gt;
&lt;br /&gt;
   var warningText = &#039;Please answer at least 4 to continue&#039;;&lt;br /&gt;
&lt;br /&gt;
   // The question ID&lt;br /&gt;
&lt;br /&gt;
   var questionId = 137;&lt;br /&gt;
&lt;br /&gt;
   // The minimum number of answers required&lt;br /&gt;
&lt;br /&gt;
   var minNumber = 4;&lt;br /&gt;
&lt;br /&gt;
   /******************************************************/&lt;br /&gt;
&lt;br /&gt;
   // Create the warning element and place it after the submit button&lt;br /&gt;
&lt;br /&gt;
   var el = document.createElement(&#039;div&#039;);&lt;br /&gt;
&lt;br /&gt;
   el.setAttribute(&#039;id&#039;,&#039;warning&#039;);&lt;br /&gt;
&lt;br /&gt;
   document.body.appendChild(el);&lt;br /&gt;
&lt;br /&gt;
   $( &#039;#warning&#039; ).css({&lt;br /&gt;
&lt;br /&gt;
       &#039;border&#039;:&#039;1px solid #333333&#039;,&lt;br /&gt;
&lt;br /&gt;
       &#039;width&#039;:&#039;200px&#039;,&lt;br /&gt;
&lt;br /&gt;
       &#039;padding&#039;:&#039;3px&#039;,&lt;br /&gt;
&lt;br /&gt;
       &#039;color&#039;:&#039;red&#039;&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#warning&#039;).html(warningText);&lt;br /&gt;
&lt;br /&gt;
   $(&#039;input[type=&amp;quot;submit&amp;quot;]&#039;).after($(&#039;#warning&#039;));&lt;br /&gt;
&lt;br /&gt;
   // Detect the initial number of checked answers &amp;amp; display Next/Submit button accordingly&lt;br /&gt;
&lt;br /&gt;
   var inputInitCount = 0;&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#question&#039; + questionId + &#039; input&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
       if ($( this ).attr(&#039;checked&#039;) == true ) {&lt;br /&gt;
&lt;br /&gt;
           inputInitCount++;&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   if (inputInitCount &amp;gt; (minNumber - 1)) {&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input[type=&amp;quot;submit&amp;quot;]&#039;).show();&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#warning&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   else {&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#warning&#039;).show();&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input[type=&amp;quot;submit&amp;quot;]&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   // Listener to detect number of checked answers &amp;amp; display Next/Submit button accordingly&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#question&#039; + questionId + &#039; input.radio, #question&#039;+questionId+&#039; tbody[id&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&amp;quot;javatbd&amp;quot;] td&#039;).click(function() {&lt;br /&gt;
&lt;br /&gt;
       var inputCount = 0;&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039; + questionId + &#039; input.radio&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
           if ($( this ).attr(&#039;checked&#039;) == true ) {&lt;br /&gt;
&lt;br /&gt;
               inputCount++;&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       if (inputCount &amp;gt; (minNumber - 1)) {&lt;br /&gt;
&lt;br /&gt;
           $(&#039;input[type=&amp;quot;submit&amp;quot;]&#039;).show();&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#warning&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       else {&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#warning&#039;).show();&lt;br /&gt;
&lt;br /&gt;
           $(&#039;input[type=&amp;quot;submit&amp;quot;]&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       // The original functions of the click event&lt;br /&gt;
&lt;br /&gt;
       checkconditions(this.value, this.name, this.type);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Minimum elapsed time before moving forward in survey=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.91, IE 7/8, Firefox 7.0, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround interrupts the Next/Submit function and checks the amount of time elapsed since the page loaded. If the time is less than the minimum dictated, the respondent is alerted and not allowed to proceed. It is useful if you want to enforce a minimum amount of time spent viewing a page.&lt;br /&gt;
#[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_ Set up your survey to use JavaScript].&lt;br /&gt;
#Place the script below in the source of one of the questions on the page, replacing &amp;quot;TT&amp;quot; with the minimum number of seconds required before advancing is allowed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       minTime(TT);&lt;br /&gt;
&lt;br /&gt;
       function minTime(minTime) {&lt;br /&gt;
&lt;br /&gt;
           var startTime = new Date();&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#movenextbtn, #movesubmitbtn&#039;).click(function(){&lt;br /&gt;
&lt;br /&gt;
               var endTime = new Date();&lt;br /&gt;
&lt;br /&gt;
               if[[endTime - startTime)/1000 &amp;lt;= minTime) {&lt;br /&gt;
&lt;br /&gt;
                    alert (&#039;You must spend at least &#039;+minTime+&#039; seconds on the question.&#039;);&lt;br /&gt;
&lt;br /&gt;
                    return false;&lt;br /&gt;
&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
                else {&lt;br /&gt;
&lt;br /&gt;
                    return true;&lt;br /&gt;
&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
            });&lt;br /&gt;
&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 =Minimum number of characters in Long free text or Huge free text questions=&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with: 1.91, IE 7/8, Firefox 7.0, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/div&amp;gt;As of version 1.91, you can use regular expression masks (validation) to specify the minimum number of required characters.  However, even if the question is mandatory, it can still be blank.&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/div&amp;gt;As of version  1.92, if you make the question mandatory and use a validation mask to specify the minimum number of characters, then the user will be forced to answer the question.  Note that unlike 1.91, they can submit their current answers, even if partially invalid (so they are stored in the database), but they will not ber able to proceed to the next page until they have passed all mandatory and validity checks.&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 This workaround interrupts the Next/Submit function and checks the number of characters entered in a Long free text or Huge free text question. If the number is less than the minimum dictated, the respondent is alerted and not allowed to proceed.&lt;br /&gt;
&lt;br /&gt;
 #[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_|Set up your survey to use JavaScript].&lt;br /&gt;
&lt;br /&gt;
 #Place the script below in the source of one of the questions on the page, replace &amp;quot;QQ&amp;quot; with the question ID and &amp;quot;CC&amp;quot; with the minimum number of characters required before advancing is allowed.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
        minChar(QQ, CC);&lt;br /&gt;
&lt;br /&gt;
        function minChar(qID, minChars) {&lt;br /&gt;
&lt;br /&gt;
            $(&#039;#movenextbtn, #movesubmitbtn&#039;).click(function(){&lt;br /&gt;
&lt;br /&gt;
                if($(&#039;#question&#039;+qID+&#039; textarea&#039;).val().replace(/ /g,&#039;&#039;).length &amp;lt; minChars) {&lt;br /&gt;
&lt;br /&gt;
                    alert (&#039;You must enter at least &#039;+minChars+&#039; characters.&#039;);&lt;br /&gt;
&lt;br /&gt;
                    return false;&lt;br /&gt;
&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
                else {&lt;br /&gt;
&lt;br /&gt;
                    return true;&lt;br /&gt;
&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
            });&lt;br /&gt;
&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 =Variable Length Array (Multi Flexible Text) question=&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with: 1.90+, IE 6/7/8, FireFox 3.0, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 This workaround allows a respondent to add or remove rows of an Array (Multi Flexible Text) question. It&#039;s useful to avoid the page being cluttered with unnecessary array rows.&lt;br /&gt;
&lt;br /&gt;
 A function is placed in the template.js file of your template (use template editor). This function hides all of the array rows except the first and inserts two elements that when clicked show or hide rows accordingly.&lt;br /&gt;
&lt;br /&gt;
 There is a demo [http://www.partnersinc.biz/surveys//index.php?sid=53132&amp;amp;newtest;=Y&amp;amp;lang;=en|here].&lt;br /&gt;
&lt;br /&gt;
 It must be noted that you can not make this question Mandatory as the respondent will have no way to complete hidden fields. If you want the displayed fields to be mandatory you will need to validate them in another function or modify this function to only allow the addition of rows if all fields in the last row are completed and then disable those fields - that, however, is a little over the top for this example.&lt;br /&gt;
&lt;br /&gt;
 Implementation is as follows:&lt;br /&gt;
&lt;br /&gt;
 #Set up your survey to use JavaScript (See instructions [http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_|here])&lt;br /&gt;
&lt;br /&gt;
 #Add the following script to your &#039;&#039;template.js&#039;&#039; file.&lt;br /&gt;
&lt;br /&gt;
 #Replace &amp;quot;QQ&amp;quot; in the function call at the end with the question ID.&lt;br /&gt;
&lt;br /&gt;
 #Create one or more Array (Multi Flexible Text) questions&lt;br /&gt;
&lt;br /&gt;
 #If you want to apply it to more arrays on the same page simply add more calls with the appropriate question IDs. (eg. varLengthArray(1); varLengthArray(2);...)&lt;br /&gt;
&lt;br /&gt;
 Onload code:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
        // A function to add or remove rows of an Array (Multi Flexible)(Text) question&lt;br /&gt;
&lt;br /&gt;
        function varLengthArray(qID) {&lt;br /&gt;
&lt;br /&gt;
            if ($(&#039;#question&#039;+qID+&#039;&#039;).length &amp;gt; 0) {&lt;br /&gt;
&lt;br /&gt;
                // The HTML content of the Add/Remove elements - modify as you wish&lt;br /&gt;
&lt;br /&gt;
                var addContent = &#039;[+]&#039;;&lt;br /&gt;
&lt;br /&gt;
                var removeContent = &#039;[-]&#039;;&lt;br /&gt;
&lt;br /&gt;
                // Create the Add and Remove elements &amp;amp; insert them&lt;br /&gt;
&lt;br /&gt;
                var el1 = document.createElement(&#039;div&#039;);&lt;br /&gt;
&lt;br /&gt;
                el1.setAttribute(&#039;id&#039;,&#039;addButton&#039;+qID);&lt;br /&gt;
&lt;br /&gt;
                document.body.appendChild(el1);&lt;br /&gt;
&lt;br /&gt;
                var el2 = document.createElement(&#039;div&#039;);&lt;br /&gt;
&lt;br /&gt;
                el2.setAttribute(&#039;id&#039;,&#039;removeButton&#039;+qID);&lt;br /&gt;
&lt;br /&gt;
                document.body.appendChild(el2);&lt;br /&gt;
&lt;br /&gt;
                // Move them to after the array&lt;br /&gt;
&lt;br /&gt;
                $( &#039;div#addButton&#039;+qID ).appendTo($( &#039;#question&#039; + qID + &#039; table.question&#039; ).parent(]];&lt;br /&gt;
&lt;br /&gt;
               $( &#039;div#removeButton&#039;+qID ).appendTo($( &#039;#question&#039; + qID + &#039; table.question&#039; ).parent());&lt;br /&gt;
&lt;br /&gt;
               // Insert their HTML&lt;br /&gt;
&lt;br /&gt;
               $( &#039;div#addButton&#039;+qID ).html( addContent );&lt;br /&gt;
&lt;br /&gt;
               $( &#039;div#removeButton&#039;+qID ).html( removeContent );&lt;br /&gt;
&lt;br /&gt;
               // Style the elements - you can modify here if you wish&lt;br /&gt;
&lt;br /&gt;
               $( &#039;div#addButton&#039;+qID ).css({&lt;br /&gt;
&lt;br /&gt;
                   &#039;margin&#039;:&#039;10px 0 0 10px&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;padding&#039;:&#039;1px&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;text-align&#039;:&#039;center&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;font-weight&#039;:&#039;bold&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;width&#039;:&#039;auto&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;cursor&#039;:&#039;pointer&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;float&#039;:&#039;left&#039;&lt;br /&gt;
&lt;br /&gt;
               });&lt;br /&gt;
&lt;br /&gt;
               $( &#039;div#removeButton&#039;+qID ).css({&lt;br /&gt;
&lt;br /&gt;
                   &#039;margin&#039;:&#039;10px 0 0 10px&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;padding&#039;:&#039;1px&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;text-align&#039;:&#039;center&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;font-weight&#039;:&#039;bold&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;width&#039;:&#039;auto&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;cursor&#039;:&#039;pointer&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;float&#039;:&#039;left&#039;&lt;br /&gt;
&lt;br /&gt;
               });&lt;br /&gt;
&lt;br /&gt;
               // Initially hide the Remove element&lt;br /&gt;
&lt;br /&gt;
               $( &#039;div#removeButton&#039;+qID ).hide();&lt;br /&gt;
&lt;br /&gt;
               // Call the functions below when clicked&lt;br /&gt;
&lt;br /&gt;
               $( &#039;div#addButton&#039;+qID ).click(function (event) {&lt;br /&gt;
&lt;br /&gt;
                   addRow(qID);&lt;br /&gt;
&lt;br /&gt;
               });&lt;br /&gt;
&lt;br /&gt;
               $( &#039;div#removeButton&#039;+qID ).click(function (event) {&lt;br /&gt;
&lt;br /&gt;
                   removeRow(qID);&lt;br /&gt;
&lt;br /&gt;
               });&lt;br /&gt;
&lt;br /&gt;
               // Function to add a row, also shows the Remove element and hides the&lt;br /&gt;
&lt;br /&gt;
               //Add element if all rows are shown&lt;br /&gt;
&lt;br /&gt;
               function addRow(qID) {&lt;br /&gt;
&lt;br /&gt;
                   var arrayRow = &#039;#question&#039; + qID + &#039; table.question tbody&#039;;&lt;br /&gt;
&lt;br /&gt;
                   var rowCount = $( arrayRow ).size() - 1;&lt;br /&gt;
&lt;br /&gt;
                   $( arrayRow + &#039;[name=&amp;quot;hidden&amp;quot;]:first&#039; ).attr(&#039;name&#039;, &#039;visible&#039;).show();&lt;br /&gt;
&lt;br /&gt;
                   $( &#039;div#removeButton&#039;+qID ).show();&lt;br /&gt;
&lt;br /&gt;
                   if ( $( arrayRow + &#039;:eq(&#039; + rowCount + &#039;)&#039; ).attr(&#039;name&#039;) == &#039;visible&#039; )  {&lt;br /&gt;
&lt;br /&gt;
                       $( &#039;div#addButton&#039;+qID ).hide();&lt;br /&gt;
&lt;br /&gt;
                   }&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               // Function to remove a row, also clears the contents of the removed row,&lt;br /&gt;
&lt;br /&gt;
               // shows the Add element if the last row is hidden and hides the Remove&lt;br /&gt;
&lt;br /&gt;
               // element if only the first row is shown&lt;br /&gt;
&lt;br /&gt;
               function removeRow(qID) {&lt;br /&gt;
&lt;br /&gt;
                   var arrayRow = &#039;#question&#039; + qID + &#039; table.question tbody&#039;;&lt;br /&gt;
&lt;br /&gt;
                   var rowCount = $( arrayRow ).size() - 1;&lt;br /&gt;
&lt;br /&gt;
                   $( arrayRow + &#039;[name=&amp;quot;visible&amp;quot;]:last input[type=&amp;quot;text&amp;quot;]&#039; ).val(&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
                   $( arrayRow + &#039;[name=&amp;quot;visible&amp;quot;]:last&#039; ).attr(&#039;name&#039;, &#039;hidden&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
                   $( &#039;div#addButton&#039;+qID ).show();&lt;br /&gt;
&lt;br /&gt;
                   if ( $( arrayRow + &#039;:eq(1)&#039; ).attr(&#039;name&#039;) == &#039;hidden&#039; )  {&lt;br /&gt;
&lt;br /&gt;
                       $( &#039;div#removeButton&#039;+qID ).hide();&lt;br /&gt;
&lt;br /&gt;
                   }&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               // Just some initialization stuff&lt;br /&gt;
&lt;br /&gt;
               var arrayRow = &#039;#question&#039; + qID + &#039; table.question tbody&#039;;&lt;br /&gt;
&lt;br /&gt;
               var rowCount = &#039;&#039;;&lt;br /&gt;
&lt;br /&gt;
               // Initially hide all except first row or any rows with populated inputs&lt;br /&gt;
&lt;br /&gt;
               $( arrayRow ).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
                   if ( i &amp;gt; 0 ) {&lt;br /&gt;
&lt;br /&gt;
                       // We also need to give the hidden rows a name cause IE doesn&#039;t&lt;br /&gt;
&lt;br /&gt;
                       // recognize jQuery :visible selector consistently&lt;br /&gt;
&lt;br /&gt;
                       $( this ).attr(&#039;name&#039;, &#039;hidden&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
                       $(&#039;input[type=text]&#039;, this).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
                           if ($(this).attr(&#039;value&#039;) != &#039;&#039;) {&lt;br /&gt;
&lt;br /&gt;
                               $(this).parents(&#039;tbody:eq(0)&#039;).attr(&#039;name&#039;, &#039;visible&#039;).show();&lt;br /&gt;
&lt;br /&gt;
                               $( &#039;div#removeButton&#039;+qID ).show();&lt;br /&gt;
&lt;br /&gt;
                           }&lt;br /&gt;
&lt;br /&gt;
                       });&lt;br /&gt;
&lt;br /&gt;
                       rowCount = i;&lt;br /&gt;
&lt;br /&gt;
                   }&lt;br /&gt;
&lt;br /&gt;
               });&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       // Call the function with a question ID&lt;br /&gt;
&lt;br /&gt;
       varLengthArray(QQ);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Expandable Array=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 6/7, FireFox 3.5, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround allows you to present an array question incrementally. That is to say that initially only the first option (row) in the array is shown. When that option is answered the next is shown and so-on.&lt;br /&gt;
&lt;br /&gt;
A JavaScript function is placed in the source of the array question. This function hides all of the array rows except the first and then displays them as options are answered.&lt;br /&gt;
&lt;br /&gt;
There is a demo [http://www.partnersinc.biz/surveys//index.php?sid=94958&amp;amp;newtest;=Y&amp;amp;lang;=en here].&lt;br /&gt;
&lt;br /&gt;
The workaround supports following question types:&lt;br /&gt;
*Array (flexible labels)&lt;br /&gt;
*Array (flexible labels) by column&lt;br /&gt;
*Array (Yes/No/Uncertain)&lt;br /&gt;
*Array (Increase, Same, Decrease)&lt;br /&gt;
*Array (Flexible Labels) dual scale&lt;br /&gt;
*Array (10 point choice)&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#Set up your survey to use JavaScript. (See [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._ documentation here])&lt;br /&gt;
#Create one or more Array questions&lt;br /&gt;
#In the source of the first array question add the following script.&lt;br /&gt;
#Replace &amp;quot;QQ&amp;quot; in the function call at the end of the script with the question ID of the array you would like to manipulate.&lt;br /&gt;
#If you want to apply it to more arrays on the same page, simply add more calls with the appropriate question IDs. (eg. expandingArray(1); expandingArray(2);...)&lt;br /&gt;
&lt;br /&gt;
Onload code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // A function to show subsequent rows of an array as options are checked&lt;br /&gt;
&lt;br /&gt;
       function expandingArray(qID) {&lt;br /&gt;
&lt;br /&gt;
           // Build an array of the question rows&lt;br /&gt;
&lt;br /&gt;
           var arrayRow = &#039;#question&#039; + qID + &#039; table.question tbody tr&#039;;&lt;br /&gt;
&lt;br /&gt;
           // Initially hide all rows unless an input was previously checked&lt;br /&gt;
&lt;br /&gt;
           $( arrayRow ).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
               if ( $( arrayRow  + &#039;:eq(&#039; + i + &#039;) input.radio:checked&#039; ).length != 0 ) {&lt;br /&gt;
&lt;br /&gt;
                   $( this ).attr(&#039;name&#039;, &#039;clickedRow&#039;);&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               else {&lt;br /&gt;
&lt;br /&gt;
                   $( this ).attr(&#039;name&#039;, &#039;hidden&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Now show the first hidden row&lt;br /&gt;
&lt;br /&gt;
           addRow();&lt;br /&gt;
&lt;br /&gt;
           // Add another row when an option is checked for the first time&lt;br /&gt;
&lt;br /&gt;
           $( &#039;#question&#039; + qID + &#039; td.answer input.radio&#039; ).click(function (event) {&lt;br /&gt;
&lt;br /&gt;
               if ($( this ).parents(&#039;tr:eq(0)&#039;).attr(&#039;name&#039;) != &#039;clickedRow&#039;) {&lt;br /&gt;
&lt;br /&gt;
                   addRow();&lt;br /&gt;
&lt;br /&gt;
                   $( this ).parents(&#039;tr:eq(0)&#039;).attr(&#039;name&#039;, &#039;clickedRow&#039;);&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               // The original function of the click event&lt;br /&gt;
&lt;br /&gt;
               checkconditions(this.value, this.name, this.type);&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Add another row when an table cell is clicked for the first time&lt;br /&gt;
&lt;br /&gt;
           $( &#039;#question&#039; + qID + &#039; table.question tbody td&#039; ).click(function (event) {&lt;br /&gt;
&lt;br /&gt;
               if ($( this ).parents(&#039;tr:eq(0)&#039;).attr(&#039;name&#039;) != &#039;clickedRow&#039;) {&lt;br /&gt;
&lt;br /&gt;
                   addRow();&lt;br /&gt;
&lt;br /&gt;
                   $( this ).parents(&#039;tr:eq(0)&#039;).attr(&#039;name&#039;, &#039;clickedRow&#039;);&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Function to add a row&lt;br /&gt;
&lt;br /&gt;
           function addRow() {&lt;br /&gt;
&lt;br /&gt;
               $( arrayRow + &#039;[name=&amp;quot;hidden&amp;quot;]:first&#039; ).attr(&#039;name&#039;, &#039;visible&#039;).show();&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       // Call the function with a question ID&lt;br /&gt;
&lt;br /&gt;
       expandingArray(QQ);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Partially Randomized Answers - Multiple Options &amp;amp; List (radio) questions=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 6/7, FireFox 3.0, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround allows the answers of Multiple Options &amp;amp; List (radio) questions to be randomized while always keeping one answer at the end of the list. It&#039;s useful if you want to randomize, say, the first 4 of your answers but always have the fifth displayed last as in the image below:&lt;br /&gt;
&lt;br /&gt;
[[File:random_336x179gif.gif]]&lt;br /&gt;
&lt;br /&gt;
An onload function is placed in the source of a question. After the randomizing has occurred this function moves the answer with the highest answer code to the end of the list.&lt;br /&gt;
&lt;br /&gt;
There is a demo [http://www.partnersinc.biz/surveys//index.php?sid=89344&amp;amp;newtest;=Y&amp;amp;lang;=en here].&lt;br /&gt;
&lt;br /&gt;
Some conditions on the use of this are:&lt;br /&gt;
*For Select/radio type questions it will only work if the [http://docs.limesurvey.org/tiki-index.php?page=Optional+settings&amp;amp;structure;=English+Instructions+for+LimeSurvey#Survey_Behavior $shownoanswer option] is set to 0 in config.php. (&amp;quot;No answer&amp;quot; is removed from the end of questions)&lt;br /&gt;
*You must use sequential numbers, starting at 1 as response codes. (See image below)&lt;br /&gt;
&lt;br /&gt;
[[File:random_700x154.png]]&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#Turn off &#039;&#039;$filterxsshtml&#039;&#039; to allow insertion of JavaScript in the questions. (See [http://docs.limesurvey.org/tiki-index.php?page=Optional+settings&amp;amp;structure;=English+Instructions+for+LimeSurvey#Filtering_dangerous_HTML_tags_in_survey_objects documentation here])&lt;br /&gt;
#Create one or more Multiple Options or List (radio) questions with sequential response codes. Set the [http://docs.limesurvey.org/tiki-index.php?page=Question+attributes&amp;amp;structure;=English+Instructions+for+LimeSurvey#random_order random_order question attribute] to 1.&lt;br /&gt;
#In the source of the first question add the following onload function. (See [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._ How to use script here])&lt;br /&gt;
#Replace &amp;quot;SSSSS&amp;quot;, &amp;quot;GG&amp;quot;, &amp;quot;QQ&amp;quot; in the function call at the end with the survey ID, group ID and question ID respectively.&lt;br /&gt;
#If you want to apply it to more questions on the same page simply add more calls with the appropriate IDs. (eg. partRand(11111, 22, 1); partRand(11111, 22, 2); ...)&lt;br /&gt;
&lt;br /&gt;
Onload code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Function to allow randomization of all answers except the last one in Multiple options and List/radio questions&lt;br /&gt;
&lt;br /&gt;
       function partRand(sID, gID, qID) {&lt;br /&gt;
&lt;br /&gt;
           // Find the number of answers&lt;br /&gt;
&lt;br /&gt;
           var ansCount = &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
           $( &#039;div#question&#039; + qID + &#039; td.answer li&#039; ).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
               ansCount = (i + 1);&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Place the last answer created at the end of the list&lt;br /&gt;
&lt;br /&gt;
           $( &#039;input#answer&#039; + sID + &#039;X&#039; + gID + &#039;X&#039; + qID + ansCount + &#039;&#039; ).parent().appendTo($( &#039;#question&#039; + qID + &#039; td.answer ul&#039; ));&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       // Call the function with the SID, GID and QID&lt;br /&gt;
&lt;br /&gt;
       partRand(SSSSS, GG, QQ);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Partially Randomized Answers - List (dropdown) questions=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 6/7, FireFox 3.0, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround, similar to the one above, allows the answers of List (dropdown) questions to be randomized while always keeping one answer at the end of the list. It&#039;s useful if you want to randomize, say, the first 4 of your answers but always have the fifth displayed last.&lt;br /&gt;
&lt;br /&gt;
An onload function is placed in the source of a question. After the randomizing has occurred this function moves the answer with the highest answer code to the end of the list.&lt;br /&gt;
&lt;br /&gt;
There is a demo [http://www.partnersinc.biz/surveys//index.php?sid=89344&amp;amp;newtest;=Y&amp;amp;lang;=en here].&lt;br /&gt;
&lt;br /&gt;
A condition is that you must use sequential numbers, starting at 1 as response codes. (See image below)&lt;br /&gt;
&lt;br /&gt;
[[File:random_700x154.png]]&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#Turn off &#039;&#039;$filterxsshtml&#039;&#039; to allow insertion of JavaScript in the questions. (See [http://docs.limesurvey.org/tiki-index.php?page=Optional+settings&amp;amp;structure;=English+Instructions+for+LimeSurvey#Filtering_dangerous_HTML_tags_in_survey_objects documentation here])&lt;br /&gt;
#Create one or more List (dropdown) questions with sequential response codes. Set the [http://docs.limesurvey.org/tiki-index.php?page=Question+attributes&amp;amp;structure;=English+Instructions+for+LimeSurvey#random_order random_order question attribute] to 1.&lt;br /&gt;
#In the source of the first question add the following onload function. (See [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._ How to use script here])&lt;br /&gt;
#Replace &amp;quot;SSSSS&amp;quot;, &amp;quot;GG&amp;quot;, &amp;quot;QQ&amp;quot; in the function call at the end with the survey ID, group ID and question ID respectively.&lt;br /&gt;
#If you want to apply it to more questions on the same page simply add more calls with the appropriate IDs. (eg. partRandDD(11111, 22, 1); partRandDD(11111, 22, 2); ...)&lt;br /&gt;
&lt;br /&gt;
Onload code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
   // Function to allow randomization of all answers&lt;br /&gt;
&lt;br /&gt;
   //except the last one in List/dropdown questions&lt;br /&gt;
&lt;br /&gt;
   function partRandDD(sID, gID, qID) {&lt;br /&gt;
&lt;br /&gt;
       // Find the number of answers&lt;br /&gt;
&lt;br /&gt;
       var ansCount = &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
       $( &#039;div#question&#039; + qID + &#039; select option&#039; ).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
           ansCount = i;&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // Place the last answer created at the end of the list&lt;br /&gt;
&lt;br /&gt;
$( &#039;option[value=&amp;quot;&#039; + ansCount + &#039;&amp;quot;]&#039; ).appendTo($( &#039;div#question&#039; + qID + &#039; select&#039; ));&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   // Call the function with the SID, GID and QID&lt;br /&gt;
&lt;br /&gt;
   partRandDD(89344, 72, 244);&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Partially Randomized Answers - Multiple numerical input=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, Safari 5.1&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround, similar to the ones above, allows the answers of Multiple numerical input questions to be randomized while always keeping one answer at the end of the list. It&#039;s useful if you want to randomize, say, the first 4 of your answers but always have the fifth displayed last.&lt;br /&gt;
&lt;br /&gt;
An onload function is placed in the source of a question. After the randomizing has occurred this function moves the answer with the highest answer code to the end of the list.&lt;br /&gt;
&lt;br /&gt;
A condition is that you must use sequential numbers, starting at 1 as response codes. (See image below)&lt;br /&gt;
&lt;br /&gt;
[[File:random_700x154.png]]&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#Turn off &#039;&#039;$filterxsshtml&#039;&#039; to allow insertion of JavaScript in the questions. (See [http://docs.limesurvey.org/tiki-index.php?page=Optional+settings&amp;amp;structure;=English+Instructions+for+LimeSurvey#Filtering_dangerous_HTML_tags_in_survey_objects documentation here])&lt;br /&gt;
#Create one or more Multiple numerical input question with sequential response codes. Set the [http://docs.limesurvey.org/tiki-index.php?page=Question+attributes&amp;amp;structure;=English+Instructions+for+LimeSurvey#random_order random_order question attribute] to 1.&lt;br /&gt;
#In the source of the first question add the following onload function. (See [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._ How to use script here])&lt;br /&gt;
#Replace &amp;quot;SSSSS&amp;quot;, &amp;quot;GG&amp;quot;, &amp;quot;QQ&amp;quot; in the function call at the end with the survey ID, group ID and question ID respectively.&lt;br /&gt;
#If you want to apply it to more questions on the same page simply add more calls with the appropriate IDs. (eg. partRandDD(11111, 22, 1); partRandDD(11111, 22, 2); ...)&lt;br /&gt;
&lt;br /&gt;
Onload code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Function to allow randomization of all answers except the last one in multiple numeric input questions&lt;br /&gt;
&lt;br /&gt;
       function partRand(sID, gID, qID) {&lt;br /&gt;
&lt;br /&gt;
           // Find the number of answers&lt;br /&gt;
&lt;br /&gt;
           var ansCount = &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
           $( &#039;div#question&#039; + qID + &#039; div.answers li&#039; ).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
               ansCount = (i - 1);&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Place the last answer created at the end of the list - but before the first helping sum&lt;br /&gt;
&lt;br /&gt;
           $( &#039;li#javatbd&#039; + sID + &#039;X&#039; + gID + &#039;X&#039; + qID + ansCount + &#039;&#039; ).insertBefore($( &#039;div#question&#039; + qID + &#039; div.answers li.multiplenumerichelp&#039; ).first());&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       // Call the function with the SID, GID and QID&lt;br /&gt;
&lt;br /&gt;
       partRand(SID, GID, QID);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using this solution for Multiple numerical input questions might be a bit more complicated than for other question types. All answers are organized in an unordered list (&amp;lt;ul&amp;gt;) structure. However, if advanced question settings like &#039;&#039;Equals sum value&#039;&#039; are used, LimeSurvey adds helping information (e.g. sum of all entries and remainder) to the same unordered list using the class &#039;&#039;multiplenumerichelp&#039;&#039; for these additional list items. The above example  assumes that at least one of these list items is present and moves the last answer to the position right above the first helper item. Without such advanced settings, the code will most certainly need adaptation.&lt;br /&gt;
&lt;br /&gt;
=Making one (or more) rows of an array mandatory=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 6/7, Firefox 3.0, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround allows you to define one or more rows of an array question as mandatory (instead of all of them which the &amp;quot;Mandatory&amp;quot; question setting does). It is [http://www.partnersinc.biz/surveys//index.php?sid=26842&amp;amp;newtest;=Y&amp;amp;lang;=en demonstrated here].&lt;br /&gt;
&lt;br /&gt;
A JavaScript function interrupts the submit function and checks if the inputs in the mandatory row(s) are populated. If not, an alert is popped up, the offending inputs are turned pink and the submit is aborted. Otherwise the submit goes ahead.&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#Turn off &#039;&#039;$filterxsshtml&#039;&#039; to allow insertion of JavaScript in the questions (see [http://docs.limesurvey.org/tiki-index.php?page=Optional+settings&amp;amp;structure;=English+Instructions+for+LimeSurvey#Filtering_dangerous_HTML_tags_in_survey_objects documentation here]).&lt;br /&gt;
#Create the array question.&lt;br /&gt;
#In the source of the array question add the following script (see [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._ How to use script here]).&lt;br /&gt;
#Modify the warningText (line10)as required.&lt;br /&gt;
#Replace &amp;quot;QQ&amp;quot; (lines 13 and 14)  with the question ID and add calls as necessary for more rows - the example code renders rows 1 and 3 mandatory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$(document).ready(function () {&lt;br /&gt;
&lt;br /&gt;
 // Interrupt the submit function&lt;br /&gt;
&lt;br /&gt;
 $(&#039;form#limesurvey&#039;).submit(function () {&lt;br /&gt;
&lt;br /&gt;
   // Override the built-in &amp;quot;disable navigation buttons&amp;quot; feature&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#moveprevbtn, #movenextbtn, #movesubmitbtn&#039;).attr(&#039;disabled&#039;, &#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
   var empty = 0;&lt;br /&gt;
&lt;br /&gt;
   var warningText = &#039;Please complete the highlighted inputs.&#039;;&lt;br /&gt;
&lt;br /&gt;
   // Call the mandatory row function with question IDs and row numbers&lt;br /&gt;
&lt;br /&gt;
   mandatoryRow(QQ, 1);&lt;br /&gt;
&lt;br /&gt;
   mandatoryRow(QQ, 3);&lt;br /&gt;
&lt;br /&gt;
   // A function to render rows of an array mandatory&lt;br /&gt;
&lt;br /&gt;
   function mandatoryRow(qID, rowNum) {&lt;br /&gt;
&lt;br /&gt;
     $(&#039;div#question&#039; + qID + &#039; table.question tbody[id&amp;lt;/div&amp;gt;=&amp;quot;javatbd&amp;quot;]:eq(&#039; + Number(rowNum - 1) + &#039;) input[type=&amp;quot;text&amp;quot;]&#039;).each(function (i) {&lt;br /&gt;
&lt;br /&gt;
       if ($(this).val() == &#039;&#039;) {&lt;br /&gt;
&lt;br /&gt;
         $(this).css(&#039;background-color&#039;, &#039;pink&#039;);&lt;br /&gt;
&lt;br /&gt;
         empty = 1;&lt;br /&gt;
&lt;br /&gt;
       } else {&lt;br /&gt;
&lt;br /&gt;
         $(this).css(&#039;background-color&#039;, &#039;#FFFFFF&#039;);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
     });&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   if (empty == 1) {&lt;br /&gt;
&lt;br /&gt;
     alert(warningText);&lt;br /&gt;
&lt;br /&gt;
     return false;&lt;br /&gt;
&lt;br /&gt;
   } else {&lt;br /&gt;
&lt;br /&gt;
     return true;&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Randomly displaying one of a few YouTube videos, and recording which was displayed=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested in 1.85+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Jason Cleeland has created and documented a method to randomly display one of a number of youtube videos in a single question, and save which one was displayed.&lt;br /&gt;
&lt;br /&gt;
http://www.aptigence.com.au/home/archives/23-Random-display-of-videos-in-a-question-2-YouTube.html&lt;br /&gt;
&lt;br /&gt;
=Randomly displaying one of a few pictures, and recording which was displayed=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested in 1.91+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The following steps allow you to randomly display one of a few pictures and record in the dataset which picture was displayed. We use four pictures in this example, but you can easily adapt these scripts according to your needs.&lt;br /&gt;
&lt;br /&gt;
1. Create a new sub-directory &#039;&#039;&#039;pic&#039;&#039;&#039; in your LimeSurvey folder.&lt;br /&gt;
&lt;br /&gt;
2. Copy four pictures (named &#039;&#039;1.jpg&#039;&#039;, &#039;&#039;2.jpg&#039;&#039;, &#039;&#039;3.jpg&#039;&#039;, and &#039;&#039;4.jpg&#039;&#039;) in this pic sub-directory.&lt;br /&gt;
&lt;br /&gt;
3. Deactivate the &#039;&#039;Filter HTML for XSS&#039;&#039; function in LimeSurvey&#039;s &#039;&#039;Global Settings&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
4. Create a &#039;&#039;&#039;Short free text&#039;&#039;&#039; question where you want these pictures to be displayed.&lt;br /&gt;
&lt;br /&gt;
5. Figure out the [http://docs.limesurvey.org/SGQA+identifier SGQA Identifier] of this question (e.g., 12345X67X89).&lt;br /&gt;
&lt;br /&gt;
6. Paste the following code as question text after activating the editor&#039;s &#039;&#039;Source&#039;&#039; view and replace both SSSSSXGGXQQ strings with your SGQA identifier:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please have a look at this picture:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$(document).ready(&lt;br /&gt;
&lt;br /&gt;
function(){&lt;br /&gt;
&lt;br /&gt;
// Find a random number (here between 1 and 4)&lt;br /&gt;
&lt;br /&gt;
var randNumber = Math.floor(Math.random()*4 + 1);&lt;br /&gt;
&lt;br /&gt;
// Save the number as answer of this question&lt;br /&gt;
&lt;br /&gt;
$(&#039;input#answerSSSSSXGGXQQ&#039;).val(randNumber);&lt;br /&gt;
&lt;br /&gt;
// Hide this answer field&lt;br /&gt;
&lt;br /&gt;
document.getElementById(&amp;quot;answerSSSSSXGGXQQ&amp;quot;).style.display=&#039;none&#039;;&lt;br /&gt;
&lt;br /&gt;
// Show the picture&lt;br /&gt;
&lt;br /&gt;
picString = &#039;&amp;lt;img src=&amp;quot;pic/&#039; + String(randNumber) + &#039;.jpg&amp;quot;&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
document.getElementById(&#039;pic&#039;).innerHTML = picString;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;pic&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to display the number of this picture in a later question, use the following code as question text (don&#039;t forget to replace the SSSSSXGGXQQ string acordingly):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You saw picture number {INSERTANS:SSSSSXGGXQQ}.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Perhaps you want to display the same picture again in a later question, but a little bit smaller (100px width, 100px height)? Just paste the following code as question text after activating the editor&#039;s &#039;&#039;Source&#039;&#039; view, and replace the SSSSSXGGXQQ string acordingly:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here you see the picture again: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$(document).ready(&lt;br /&gt;
&lt;br /&gt;
function(){&lt;br /&gt;
&lt;br /&gt;
// Get the picture number from previous question&lt;br /&gt;
&lt;br /&gt;
var randNumber = &amp;quot;{INSERTANS:SSSSSXGGXQQ}&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
// Show picture&lt;br /&gt;
&lt;br /&gt;
picString = &#039;&amp;lt;img width=&amp;quot;100&amp;quot; height=&amp;quot;100&amp;quot; src=&amp;quot;pic/&#039; + String(randNumber) + &#039;.jpg&amp;quot;&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
document.getElementById(&#039;pic&#039;).innerHTML = picString;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;pic&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Multiple numerical input with max_num_value defined in token (personalized limit)=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested in 1.85+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, max_num_value can be an experession, so you can simply enter the {TOKEN} or other variable in that question attribute.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To make personalized survey with multiple numerical input when max_num_value (Maximum sum value) is different for each user and is loaded from the token use following tricks:&lt;br /&gt;
*Create 1st group with numerical input field (1000X10X11). &amp;quot;Limit&amp;quot;&lt;br /&gt;
*Add java script into this question:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
function Custom_On_Load(){&lt;br /&gt;
&lt;br /&gt;
  document.getElementById(&#039;answer1000X10X11&#039;).value=&#039;{TOKEN:ATTRIBUTE_1}&#039;;&lt;br /&gt;
&lt;br /&gt;
  document.getElementById(&#039;answer1000X10X11&#039;).readOnly=1;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where:&lt;br /&gt;
&lt;br /&gt;
TOKEN:ATTRIBUTE_1 is individual limit defined in token.&lt;br /&gt;
&lt;br /&gt;
readOnly=1 // user shouldn&#039;t change it.&lt;br /&gt;
*Create 2nd group with multiple numerical input and add &amp;quot;Max value from SGQA&amp;quot; with 1000X10X11 as argument.&lt;br /&gt;
&lt;br /&gt;
Note: If you don&#039;t want to show first field with numerical input (and show definied limit in different way) you can add 2 lines to above script to hide whole question:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
document.getElementById(&#039;question85&#039;).style.display=&#039;none&#039;;&lt;br /&gt;
&lt;br /&gt;
document.getElementById(&#039;display85&#039;).value=&#039;&#039;;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where:&lt;br /&gt;
&lt;br /&gt;
question85 and display85 are field names.&lt;br /&gt;
&lt;br /&gt;
Note: It&#039;s no possible to create it into one group, because all SGQA references can only refer to data on a previous page because when clicking next the answer is stored at the DB and the SGQA is replaced by querying the database.&lt;br /&gt;
&lt;br /&gt;
=Default values in array questions=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.87+ (7557), IE 6/7, Firefox 3.5, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of Version 1.92, many more question types support default values.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround uses JavaScript to allow you to pre-check default answers in all sub-questions of an array type question. You can select a column of the array to be checked as the page loads. The script first checks to see if a sub-question has already been answered and, if not, checks the default answer.&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#[http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._ Set up your survey to use JavaScript].&lt;br /&gt;
#Create the array question.&lt;br /&gt;
#In the source of the array question add the following script.&lt;br /&gt;
#Replace&amp;quot;QQ&amp;quot; with the question ID and &amp;quot;CC&amp;quot; with the column number to be checked.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // A function to pre-check a column of an array&lt;br /&gt;
&lt;br /&gt;
       function checkedDefault(qID, column) {&lt;br /&gt;
&lt;br /&gt;
           var checkedCol = column - 1;&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039; + qID + &#039; table.question tbody tr&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
               if ($(&#039;input.radio[checked=true]&#039;, this).length == 0) {&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;input.radio:eq(&#039; + checkedCol + &#039;)&#039;, this).attr(&#039;checked&#039;, true);&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       // Call the function with a question ID and column number&lt;br /&gt;
&lt;br /&gt;
       checkedDefault(QQ, CC);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Record group view time=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.87+ (8518), IE 6/7, Firefox 3.5, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, group view time is accurately recorded in the timings table if you choose the Record Timings survey option.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround uses JavaScript to populate a hidden question with the total time that a respondent views a group. If used in a group with only one question, it could be used to track the amount of time required to answer the question.&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#[http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._ Set up your survey to use JavaScript].&lt;br /&gt;
#In the group, create a short-text question. We will hide this later with JavaScript and populate it with the elapsed time.&lt;br /&gt;
#Place the following script in the source of the short-text question.&lt;br /&gt;
#Replace &amp;quot;QQ&amp;quot; in line 6 with the ID of the short-text question.&lt;br /&gt;
&lt;br /&gt;
The script populates the hidden question with the elapsed time since the group was opened. If a respondent leaves the group and then returns, the timer continues up from the elapsed time of the last visit.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function(){&lt;br /&gt;
&lt;br /&gt;
       // call the functions with the hidden timer question ID&lt;br /&gt;
&lt;br /&gt;
       runTimer(QQ);&lt;br /&gt;
&lt;br /&gt;
       function runTimer(timeQID) {&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+timeQID).hide();&lt;br /&gt;
&lt;br /&gt;
           var initSec = &#039;0&#039;;&lt;br /&gt;
&lt;br /&gt;
           // Check for elapsed time from previous visits&lt;br /&gt;
&lt;br /&gt;
           if ($(&#039;#question&#039;+timeQID+&#039; input.text&#039;).val()) {&lt;br /&gt;
&lt;br /&gt;
               var initTime = $(&#039;#question&#039;+timeQID+&#039; input.text&#039;).val();&lt;br /&gt;
&lt;br /&gt;
               initTimeArr = initTime.split(&#039;:&#039;);&lt;br /&gt;
&lt;br /&gt;
               initSec = Number[[initTimeArr[0]*3600]]+Number[[initTimeArr[1]*60]]+Number(initTimeArr[2]);&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
           // Run the timer update function&lt;br /&gt;
&lt;br /&gt;
           recordTime(initSec, timeQID);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   // Timer update function&lt;br /&gt;
&lt;br /&gt;
   function recordTime(elapsedSec, timeQID){&lt;br /&gt;
&lt;br /&gt;
       elapsedSec++;&lt;br /&gt;
&lt;br /&gt;
       var h = Math.floor(elapsedSec / 3600);&lt;br /&gt;
&lt;br /&gt;
       var m = Math.floor(elapsedSec % 3600 / 60);&lt;br /&gt;
&lt;br /&gt;
       var s = Math.floor(elapsedSec % 3600 % 60);&lt;br /&gt;
&lt;br /&gt;
       var elapsedTime = [[h &amp;gt; 0 ? h + &amp;quot;:&amp;quot; : &amp;quot;00:&amp;quot;) + (m &amp;gt; 0 ? (m &amp;lt; 10 ? &amp;quot;0&amp;quot; : &amp;quot;&amp;quot;) + m + &amp;quot;:&amp;quot; : &amp;quot;00:&amp;quot;) + (s &amp;lt; 10 ? &amp;quot;0&amp;quot; : &amp;quot;&amp;quot;) + s);&lt;br /&gt;
&lt;br /&gt;
        $(&#039;#question&#039;+timeQID+&#039; input.text&#039;).val(elapsedTime);&lt;br /&gt;
&lt;br /&gt;
        // Run the timer update function every second&lt;br /&gt;
&lt;br /&gt;
        setTimeout(&#039;recordTime(&#039;+elapsedSec+&#039;, &#039;+timeQID+&#039;)&#039;,1000);&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 =Toggle visibility of groups=&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with: 1.90+, IE 6/7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;Version 1.92 supports group-level relevance, making this workaround obsolete.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 This workaround uses JavaScript to toggle the visibility of groups in an &amp;quot;all in one&amp;quot; survey. Initially the groups are hidden and there are links inserted to display the groups. It&#039;s useful to avoid the page being cluttered with many groups and lets the respondent focus on one at a time.&lt;br /&gt;
&lt;br /&gt;
 It&#039;s [http://www.partnersinc.biz/surveys//index.php?sid=33613&amp;amp;newtest;=Y&amp;amp;lang;=en|demonstrated here].&lt;br /&gt;
&lt;br /&gt;
 Implementation is as follows:&lt;br /&gt;
&lt;br /&gt;
 #[http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._|Set up your survey to use JavaScript].&lt;br /&gt;
&lt;br /&gt;
 #Set the survey to run in &amp;quot;all in one&amp;quot; mode.&lt;br /&gt;
&lt;br /&gt;
 #Add your groups and questions.&lt;br /&gt;
&lt;br /&gt;
 #Place the following script in the source of one of the questions in the first group.&lt;br /&gt;
&lt;br /&gt;
 The comments in the script are pretty self-explanatory but it does the following:&lt;br /&gt;
&lt;br /&gt;
 #initially hides all of the groups&lt;br /&gt;
&lt;br /&gt;
 #inserts a link above each one to toggle its display&lt;br /&gt;
&lt;br /&gt;
 #some styles are added to the clickable links but these could be done in template.css instead&lt;br /&gt;
&lt;br /&gt;
 #shows any groups that have an unanswered mandatory after a submit attempt&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    $(document).ready(function(){&lt;br /&gt;
&lt;br /&gt;
       // Insert show/hide elements before all group wrapper divs&lt;br /&gt;
&lt;br /&gt;
        $(&#039;&amp;lt;div class=&amp;quot;groupToggler&amp;quot;&amp;gt;&amp;lt;span&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;/div&amp;gt;&#039;).insertBefore(&#039;div[id&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&amp;quot;group-&amp;quot;]&#039;);&lt;br /&gt;
&lt;br /&gt;
        // Add some text to the show/hide elements&lt;br /&gt;
&lt;br /&gt;
        $(&#039;.groupToggler span&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
            ($( this ).text(&#039;Show/Hide Group &#039;+(i+1)+&#039;&#039;]];&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // Add some styles to the show/hide elements&lt;br /&gt;
&lt;br /&gt;
       $(&#039;.groupToggler&#039;).css({&lt;br /&gt;
&lt;br /&gt;
           &#039;padding&#039;:&#039;5px 0 10px 0&#039;,&lt;br /&gt;
&lt;br /&gt;
           &#039;text-align&#039;:&#039;center&#039;&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       $(&#039;.groupToggler span&#039;).css({&lt;br /&gt;
&lt;br /&gt;
           &#039;text-decoration&#039;:&#039;underline&#039;,&lt;br /&gt;
&lt;br /&gt;
           &#039;cursor&#039;:&#039;pointer&#039;&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // Add some hover effects to the show/hide elements&lt;br /&gt;
&lt;br /&gt;
       $(&amp;quot;.groupToggler span&amp;quot;).hover(&lt;br /&gt;
&lt;br /&gt;
           function () {&lt;br /&gt;
&lt;br /&gt;
               $(this).css({&lt;br /&gt;
&lt;br /&gt;
                   &#039;text-decoration&#039;:&#039;none&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;font-weight&#039;:&#039;bold&#039;&lt;br /&gt;
&lt;br /&gt;
               });&lt;br /&gt;
&lt;br /&gt;
           },&lt;br /&gt;
&lt;br /&gt;
           function () {&lt;br /&gt;
&lt;br /&gt;
               $(this).css({&lt;br /&gt;
&lt;br /&gt;
                   &#039;text-decoration&#039;:&#039;underline&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;font-weight&#039;:&#039;normal&#039;&lt;br /&gt;
&lt;br /&gt;
               });&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       );&lt;br /&gt;
&lt;br /&gt;
       // Initially hide all of the groups&lt;br /&gt;
&lt;br /&gt;
       // Toggle their visibility when the show/hide element is clicked&lt;br /&gt;
&lt;br /&gt;
       $(&#039;.groupToggler span&#039;).click(function() {&lt;br /&gt;
&lt;br /&gt;
           $(this).parent().next().toggle();&lt;br /&gt;
&lt;br /&gt;
           return false;&lt;br /&gt;
&lt;br /&gt;
       }).parent().next().hide();&lt;br /&gt;
&lt;br /&gt;
       // Display any groups that have unanswered mandatories&lt;br /&gt;
&lt;br /&gt;
       $(&#039;.errormandatory&#039;).parents(&#039;div[id&amp;lt;/div&amp;gt;=&amp;quot;group-&amp;quot;]&#039;).show();&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Use jQuery Autocomplete plugin to suggest answers for text inputs=&lt;br /&gt;
&lt;br /&gt;
== 1.90 and previous versions==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 6/7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround uses the [http://docs.jquery.com/Plugins/Autocomplete jQuery Autocomplete] plugin to provide a respondent a list of suggested answers that the they can select from as they type in a text input.&lt;br /&gt;
&lt;br /&gt;
Although the plugin allows for much more complex applications, the two that I use most frequently are outlined below. The first method uses a relatively small list of suggestions that is stored in an array locally. The second is a little more complex - it uses a remote CSV file of suggestions that is accessed through AJAX an PHP.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve put together a small demonstration [http://www.partnersinc.biz/surveys//index.php?sid=78611&amp;amp;newtest;=Y&amp;amp;lang;=en here] and implementation is as follows.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Both methods:&#039;&#039;&#039;&lt;br /&gt;
*[http://docs.jquery.com/Plugins/Autocomplete Download the plugin]&lt;br /&gt;
*Place the files &#039;&#039;jquery.autocomplete.css&#039;&#039; and &#039;&#039;jquery.autocomplete.js&#039;&#039; in your template directory&lt;br /&gt;
*Add the following code inside the &amp;lt;head&amp;gt; element of startpage.pstpl&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;{TEMPLATEURL}jquery.autocomplete.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;link rel=&amp;quot;stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot; href=&amp;quot;{TEMPLATEURL}jquery.autocomplete.css&amp;quot; /&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Method 1 (&amp;quot;States&amp;quot; question in the demo):&#039;&#039;&#039;&lt;br /&gt;
*Create a text input question&lt;br /&gt;
*Add the following script to the source of the text question&lt;br /&gt;
*Replace &amp;quot;QQ&amp;quot; with the ID of the text input question&lt;br /&gt;
*Replace the states with your list of suggestions (comma separated)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       var q1ID = QQ;&lt;br /&gt;
&lt;br /&gt;
       var states = &amp;quot;Alabama,Alaska,Arizona,Arkansas,California,Colorado,Connecticut,Delaware,&lt;br /&gt;
&lt;br /&gt;
       District of Columbia,Florida,Georgia,Hawaii,Idaho,Illinois,Indiana,Iowa,Kansas,Kentucky,&lt;br /&gt;
&lt;br /&gt;
       Louisiana,Maine,Montana,Nebraska,Nevada,New Hampshire,New Jersey,New Mexico,New York,&lt;br /&gt;
&lt;br /&gt;
       North Carolina,North Dakota,Ohio,Oklahoma,Oregon,Maryland,Massachusetts,Michigan,&lt;br /&gt;
&lt;br /&gt;
       Minnesota,Mississippi,Missouri,Pennsylvania,Rhode Island,South Carolina,South Dakota,&lt;br /&gt;
&lt;br /&gt;
       Tennessee,Texas,Utah,Vermont,Virginia,Washington,West Virginia,Wisconsin,Wyoming&amp;quot;.split(&#039;,&#039;);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q1ID+&#039; input.text&#039;).autocomplete(states, {&lt;br /&gt;
&lt;br /&gt;
           matchContains: true,&lt;br /&gt;
&lt;br /&gt;
           minChars: 0&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Method 2 (&amp;quot;Countries&amp;quot; question in the demo):&#039;&#039;&#039;&lt;br /&gt;
*Place the CSV file of suggestions in your template directory (you can download my demo CSV [http://www.partnersinc.biz/surveys/templates/default_autocompleting_input/countries2.csv here])&lt;br /&gt;
*Place a PHP file containing the code below in your template directory&lt;br /&gt;
*Replace &amp;quot;countries2.csv&amp;quot; with your CSV filename (you could make this more universal by passing the filename in the URL)&lt;br /&gt;
*This file will grab the contents of the CSV and encode them in JSON format that the JavaScript can use&lt;br /&gt;
*Place the JavaScript code below in ths source of the text question&lt;br /&gt;
*Replace &amp;quot;QQ&amp;quot; with the ID of the text input question&lt;br /&gt;
*Replace &amp;quot;templates/yourTemplate/countries.php&amp;quot; with the path to the PHP file (from LimeSurvey root)&lt;br /&gt;
*This script will grab the jsonized data from the PHP file and load it into an array that the plugin can use&lt;br /&gt;
&lt;br /&gt;
PHP code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
   $countriesArr = array();&lt;br /&gt;
&lt;br /&gt;
   $file_handle = fopen(&amp;quot;countries2.csv&amp;quot;, &amp;quot;r&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
   while (!feof($file_handle) ) {&lt;br /&gt;
&lt;br /&gt;
       $line_of_text = fgetcsv($file_handle);&lt;br /&gt;
&lt;br /&gt;
       array_push($countriesArr, $line_of_text[0]);&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   fclose($file_handle);&lt;br /&gt;
&lt;br /&gt;
   echo json_encode($countriesArr);&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
JavaScript code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       var qID = QQ;&lt;br /&gt;
&lt;br /&gt;
       var url = &amp;quot;templates/yourTemplate/countries.php&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
       var countriesArr = new Array();&lt;br /&gt;
&lt;br /&gt;
       $.getJSON(url,function(data){&lt;br /&gt;
&lt;br /&gt;
           $(data).each(function(i, item){&lt;br /&gt;
&lt;br /&gt;
               countriesArr.push(item);&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qID+&#039; input.text&#039;).autocomplete(countriesArr, {&lt;br /&gt;
&lt;br /&gt;
               matchContains: true,&lt;br /&gt;
&lt;br /&gt;
               minChars: 0&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 1.91 and later versions==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.91+, IE 6/7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround uses the [http://jqueryui.com/demos/autocomplete/ Autocomplete widget] included with jQuery UI to provide a respondent a list of suggested answers that the they can select from as they type in a text input.&lt;br /&gt;
&lt;br /&gt;
Although the plugin allows for much more complex applications, the two that I use most frequently are outlined below. The first method uses a relatively small list of suggestions that is stored in an array locally. The second is a little more complex - it uses a remote CSV file of suggestions that is accessed through AJAX an PHP.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Both methods:&#039;&#039;&#039;&lt;br /&gt;
*Add the following styles to the end of your &#039;template.css&#039; file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;/* Autocomplete styles */&lt;br /&gt;
&lt;br /&gt;
ul.ui-autocomplete {&lt;br /&gt;
&lt;br /&gt;
   width: 250px !important;&lt;br /&gt;
&lt;br /&gt;
   padding: 5px 10px;&lt;br /&gt;
&lt;br /&gt;
   list-style: none;&lt;br /&gt;
&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Method 1 (use local JavaScript array for data):&#039;&#039;&#039;&lt;br /&gt;
*Create a text input question&lt;br /&gt;
*Add the following script to the source of the text question&lt;br /&gt;
*Replace &amp;quot;QQ&amp;quot; with the ID of the text input question&lt;br /&gt;
*Replace the states with your list of suggestions (comma separated)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       var q1ID = QQ;&lt;br /&gt;
&lt;br /&gt;
       var states = &amp;quot;Alabama,Alaska,Arizona,Arkansas,California,Colorado,Connecticut,Delaware,&lt;br /&gt;
&lt;br /&gt;
       District of Columbia,Florida,Georgia,Hawaii,Idaho,Illinois,Indiana,Iowa,Kansas,Kentucky,&lt;br /&gt;
&lt;br /&gt;
       Louisiana,Maine,Montana,Nebraska,Nevada,New Hampshire,New Jersey,New Mexico,New York,&lt;br /&gt;
&lt;br /&gt;
       North Carolina,North Dakota,Ohio,Oklahoma,Oregon,Maryland,Massachusetts,Michigan,&lt;br /&gt;
&lt;br /&gt;
       Minnesota,Mississippi,Missouri,Pennsylvania,Rhode Island,South Carolina,South Dakota,&lt;br /&gt;
&lt;br /&gt;
       Tennessee,Texas,Utah,Vermont,Virginia,Washington,West Virginia,Wisconsin,Wyoming&amp;quot;.split(&#039;,&#039;);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q1ID+&#039; input.text&#039;).autocomplete({&lt;br /&gt;
&lt;br /&gt;
           source: states&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Method 2 (use remote CSV file for data):&#039;&#039;&#039;&lt;br /&gt;
*Place the CSV file of suggestions in your template directory (you can download my demo CSV [http://www.partnersinc.biz/surveys/templates/default_autocompleting_input/countries2.csv here])&lt;br /&gt;
*Place a PHP file containing the code below in your template directory&lt;br /&gt;
*Replace &amp;quot;countries2.csv&amp;quot; with your CSV filename (you could make this more universal by passing the filename in the URL)&lt;br /&gt;
*This file will grab the contents of the CSV and encode them in JSON format that the JavaScript can use&lt;br /&gt;
*Place the JavaScript code below in ths source of the text question&lt;br /&gt;
*Replace &amp;quot;QQ&amp;quot; with the ID of the text input question&lt;br /&gt;
*Replace &amp;quot;templates/yourTemplate/countries.php&amp;quot; with the path to the PHP file (from LimeSurvey root)&lt;br /&gt;
*This script will grab the jsonized data from the PHP file and load it into an array that the plugin can use&lt;br /&gt;
&lt;br /&gt;
PHP code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
   $countriesArr = array();&lt;br /&gt;
&lt;br /&gt;
   $file_handle = fopen(&amp;quot;countries2.csv&amp;quot;, &amp;quot;r&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
   while (!feof($file_handle) ) {&lt;br /&gt;
&lt;br /&gt;
       $line_of_text = fgetcsv($file_handle);&lt;br /&gt;
&lt;br /&gt;
       array_push($countriesArr, $line_of_text[0]);&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   fclose($file_handle);&lt;br /&gt;
&lt;br /&gt;
   echo json_encode($countriesArr);&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
JavaScript code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
       $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       var qID = QQ;&lt;br /&gt;
&lt;br /&gt;
       var url = &amp;quot;templates/yourTemplate/countries.php&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
       var dataArr = [];&lt;br /&gt;
&lt;br /&gt;
       $.getJSON(url,function(data){&lt;br /&gt;
&lt;br /&gt;
           $.each(data,function(i, item){&lt;br /&gt;
&lt;br /&gt;
               dataArr.push(item);&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
          $(&#039;#question&#039;+qID+&#039; input.text&#039;).autocomplete({&lt;br /&gt;
&lt;br /&gt;
               source: dataArr&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Use autocomplete to populate several fields==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.91+, IE 7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround uses the [http://jqueryui.com/demos/autocomplete/ Autocomplete widget] included with jQuery UI and the [http://plugins.jquery.com/project/csv jquery.csv.js] plugin to provide a respondent with a list of suggested answers as they type in a text input and then to automatically populate other fields depending on the selection.&lt;br /&gt;
&lt;br /&gt;
For example, if you have 3 questions - &amp;quot;Name&amp;quot;, &amp;quot;ID&amp;quot; and &amp;quot;Email&amp;quot; - you can use this workaround to autocomplete the &amp;quot;Name&amp;quot; question and then the &amp;quot;ID&amp;quot; and &amp;quot;Email&amp;quot; questions can be automatically populated with values associated with the selected name.&lt;br /&gt;
*Download the [http://plugins.jquery.com/project/csv jquery.csv.js] plugin and place it in your template folder&lt;br /&gt;
*Add the following line to your startpage.pstpl BEFORE the tag for template.js&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;{TEMPLATEURL}jquery.csv.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
*Create your CSV file with 3 columns (name, ID, email) as in this example and place it in your template folder&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;Bob,    Bob&#039;s ID,    Bob&#039;s email&lt;br /&gt;
&lt;br /&gt;
Andy,    Andy&#039;s ID,    Andy&#039;s email&lt;br /&gt;
&lt;br /&gt;
Sam,    Sam&#039;s ID,    Sam&#039;s email&lt;br /&gt;
&lt;br /&gt;
Tony,    Tony&#039;s ID,    Tony&#039;s email&lt;br /&gt;
&lt;br /&gt;
Fred,    Fred&#039;s ID,    Fred&#039;s email&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
*Create your 3 questions - &amp;quot;Name&amp;quot;, &amp;quot;ID&amp;quot; and &amp;quot;Email&amp;quot;. They must be in the same group/page.&lt;br /&gt;
*Add the following styles to the end of your &#039;template.css&#039; file&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;/* Autocomplete styles */&lt;br /&gt;
&lt;br /&gt;
ul.ui-autocomplete {&lt;br /&gt;
&lt;br /&gt;
   width: 250px !important;&lt;br /&gt;
&lt;br /&gt;
   padding: 5px 10px;&lt;br /&gt;
&lt;br /&gt;
   list-style: none;&lt;br /&gt;
&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
*Add the following script to the source of one of the questions&lt;br /&gt;
*Replace:&lt;br /&gt;
**&amp;quot;NN&amp;quot; with the &amp;quot;Name&amp;quot; question ID&lt;br /&gt;
**&amp;quot;II&amp;quot; with the &amp;quot;ID&amp;quot; question ID&lt;br /&gt;
**&amp;quot;EE&amp;quot; with the &amp;quot;Email&amp;quot; question ID&lt;br /&gt;
*Modify the path to your CSV file&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       var qNameID = NN;&lt;br /&gt;
&lt;br /&gt;
       var qIDID = II;&lt;br /&gt;
&lt;br /&gt;
       var qEmailID = EE;&lt;br /&gt;
&lt;br /&gt;
       var url = &amp;quot;upload/templates/yourTemplate/yourCsvFile.csv&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
       // Create an array to hold the names&lt;br /&gt;
&lt;br /&gt;
       var namesArr = new Array();&lt;br /&gt;
&lt;br /&gt;
       // Grab the CSV contents&lt;br /&gt;
&lt;br /&gt;
       $.get(url,function(data){&lt;br /&gt;
&lt;br /&gt;
           // Convert CSV contents to an array of arrays&lt;br /&gt;
&lt;br /&gt;
           fullArray = jQuery.csv()(data);&lt;br /&gt;
&lt;br /&gt;
           // Load the names array&lt;br /&gt;
&lt;br /&gt;
           $(fullArray).each(function(i, item){&lt;br /&gt;
&lt;br /&gt;
               namesArr.push(item[0]);&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Initialise the autocomplete plugin&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qNameID+&#039; input.text&#039;).autocomplete({&lt;br /&gt;
&lt;br /&gt;
               source: namesArr,&lt;br /&gt;
&lt;br /&gt;
               // Event fired when a selection is made (ui.item.value refers to the selected item)&lt;br /&gt;
&lt;br /&gt;
               select: function(event, ui) {&lt;br /&gt;
&lt;br /&gt;
                   // Find the &amp;quot;ID&amp;quot; and &amp;quot;Email&amp;quot; values associated with the selected name value and load those questions&lt;br /&gt;
&lt;br /&gt;
                   $(fullArray).each(function(i, item){&lt;br /&gt;
&lt;br /&gt;
                       if(item[0] == ui.item.value) {&lt;br /&gt;
&lt;br /&gt;
                           // The value from column 2 of the CSV&lt;br /&gt;
&lt;br /&gt;
                           $(&#039;#question&#039;+qIDID+&#039; input.text&#039;).val(item[1]);&lt;br /&gt;
&lt;br /&gt;
                           // The value from column 3 of the CSV&lt;br /&gt;
&lt;br /&gt;
                           $(&#039;#question&#039;+qEmailID+&#039; input.text&#039;).val(item[2]);&lt;br /&gt;
&lt;br /&gt;
                       }&lt;br /&gt;
&lt;br /&gt;
                   });&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Drag and Drop Rankings=&lt;br /&gt;
&lt;br /&gt;
==Drag and Drop Ranking - Version 1.90 and newer==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+ &amp;amp; 1.91RC4, IE 6/7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround is a modification of the workaround below and also uses [http://jqueryui.com/demos/sortable/#connect-lists JQuery connected sortables]. Thanks to the author of that workaround.&lt;br /&gt;
&lt;br /&gt;
[[File:Untitled-12.png]]&lt;br /&gt;
&lt;br /&gt;
Modifications include:&lt;br /&gt;
*Allow for multiple drag-n-drop ranking questions on a page&lt;br /&gt;
*Handle minimum and maximum answers settings&lt;br /&gt;
*Allow double clicking of items to add or remove them from the ranking list&lt;br /&gt;
*Work with the new shipped jQuery UI&lt;br /&gt;
&lt;br /&gt;
There is a &#039;&#039;&#039;[http://www.partnersinc.biz/surveys//index.php?sid=36981&amp;amp;newtest;=Y&amp;amp;lang;=en demonstrated here]&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_ Set up your survey to use JavaScript].&lt;br /&gt;
#Place the large script below in your template.js file.&lt;br /&gt;
#Place the small script below in the source a ranking question, (this applies the &amp;quot;dragDropRank&amp;quot; function to the question). Replace &amp;quot;QQ&amp;quot; with the ranking [http://docs.limesurvey.org/SGQA+identifier&amp;amp;structure;=English+Instructions+for+LimeSurvey#General_Description question ID].&lt;br /&gt;
**Note: the LimeSurvey translations will be automatically used for the &amp;quot;Choices&amp;quot; and &amp;quot;Rankings&amp;quot; header labels but can be overridden with custom labels - see the example calls below.&lt;br /&gt;
#Insert the CSS below at the end of template.css (these styles are for the default template).&lt;br /&gt;
&lt;br /&gt;
NOTE: I have not tested this workaround with conditions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Code for template.js:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
function dragDropRank(qID, choiceText, rankText) {&lt;br /&gt;
&lt;br /&gt;
   if(!choiceText) {&lt;br /&gt;
&lt;br /&gt;
       choiceText = $(&#039;#question&#039;+qID+&#039; td.label label&#039;).text();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   if(!rankText) {&lt;br /&gt;
&lt;br /&gt;
       rankText = $(&#039;#question&#039;+qID+&#039; td.output tr:first td:eq(1)&#039;).text();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   //Add a class to the question&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#question&#039;+qID+&#039;&#039;).addClass(&#039;dragDropRanking&#039;);&lt;br /&gt;
&lt;br /&gt;
   // Hide the original question in LimeSurvey (so that we can replace with drag and drop)&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#question&#039;+qID+&#039; .rank, #question&#039;+qID+&#039; .questionhelp&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
   // Turn off display of question (to override error checking built into LimeSurvey ranking question)&lt;br /&gt;
&lt;br /&gt;
   //$(&#039;#display&#039;+qID).val(&#039;off&#039;);&lt;br /&gt;
&lt;br /&gt;
   // Add connected sortables elements to the question&lt;br /&gt;
&lt;br /&gt;
   var htmlCode = &#039;&amp;lt;table class=&amp;quot;dragDropTable&amp;quot;&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
       &amp;lt;tbody&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
           &amp;lt;tr&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
               &amp;lt;td&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                   &amp;lt;span class=&amp;quot;dragDropHeader choicesLabel&amp;quot;&amp;gt;&#039;+choiceText+&#039;&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                   &amp;lt;div class=&amp;quot;ui-state-highlight dragDropChoices&amp;quot;&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                       &amp;lt;ul id=&amp;quot;sortable1&#039;+qID+&#039;&amp;quot; class=&amp;quot;connectedSortable&#039;+qID+&#039; dragDropChoiceList&amp;quot;&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                           &amp;lt;li&amp;gt;Choices&amp;lt;/li&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                       &amp;lt;/ul&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                   &amp;lt;/div&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
               &amp;lt;/td&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
               &amp;lt;td&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                   &amp;lt;span class=&amp;quot;dragDropHeader rankingLabel&amp;quot;&amp;gt;&#039;+rankText+&#039;&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                   &amp;lt;div class=&amp;quot;ui-state-highlight dragDropRanks&amp;quot;&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                       &amp;lt;ol id=&amp;quot;sortable2&#039;+qID+&#039;&amp;quot; class=&amp;quot;connectedSortable&#039;+qID+&#039; dragDropRankList&amp;quot;&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                           &amp;lt;li&amp;gt;Ranks&amp;lt;/li&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                       &amp;lt;/ol&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                   &amp;lt;/div&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
               &amp;lt;/td&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
           &amp;lt;/tr&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
       &amp;lt;/tbody&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                   &amp;lt;/table&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
   $(htmlCode).insertAfter(&#039;#question&#039;+qID+&#039; table.rank&#039;);&lt;br /&gt;
&lt;br /&gt;
   // Remove placeholder list items (have to have one item so that LimeSurvey doesn&amp;quot;t remove the &amp;lt;ul&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#sortable1&#039;+qID+&#039; li, #sortable2&#039;+qID+&#039; li&#039;).remove();&lt;br /&gt;
&lt;br /&gt;
   // Load any previously-set values&lt;br /&gt;
&lt;br /&gt;
   loadDragDropRank(qID);&lt;br /&gt;
&lt;br /&gt;
   // Find the number of LimeSurvey ranking inputs (&amp;quot;Maximum answers&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
   var maxAnswer = $(&#039;#question&#039;+qID+&#039; td.output input.text&#039;).length;&lt;br /&gt;
&lt;br /&gt;
   // Set up the connected sortable&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#sortable1&#039;+qID+&#039;, #sortable2&#039;+qID+&#039;&#039;).sortable({&lt;br /&gt;
&lt;br /&gt;
       connectWith: &#039;.connectedSortable&#039;+qID+&#039;&#039;,&lt;br /&gt;
&lt;br /&gt;
       placeholder: &#039;ui-sortable-placeholder&#039;,&lt;br /&gt;
&lt;br /&gt;
       helper: &#039;clone&#039;,&lt;br /&gt;
&lt;br /&gt;
       revert: 50,&lt;br /&gt;
&lt;br /&gt;
       receive: function(event, ui) {&lt;br /&gt;
&lt;br /&gt;
           if($(&#039;#sortable2&#039;+qID+&#039; li&#039;).length &amp;gt; maxAnswer) {&lt;br /&gt;
&lt;br /&gt;
               alert (&#039;You can only rank a maximum of &#039;+maxAnswer+&#039; choices.&#039;);&lt;br /&gt;
&lt;br /&gt;
               $(ui.sender).sortable(&#039;cancel&#039;);&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       },&lt;br /&gt;
&lt;br /&gt;
       stop: function(event, ui) {&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#sortable1&#039;+qID+&#039;&#039;).sortable(&#039;refresh&#039;);&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#sortable2&#039;+qID+&#039;&#039;).sortable(&#039;refresh&#039;);&lt;br /&gt;
&lt;br /&gt;
           updateDragDropRank(qID);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   }).disableSelection();&lt;br /&gt;
&lt;br /&gt;
   // Get the list of choices from the LimeSurvey question and copy them as items into the sortable choices list&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#CHOICES_&#039; + qID).children().each(function(index, Element) {&lt;br /&gt;
&lt;br /&gt;
       var liCode = &#039;&amp;lt;li class=&amp;quot;ui-state-default&amp;quot; id=&amp;quot;choice_&#039; + $(this).attr(&amp;quot;value&amp;quot;) + &#039;&amp;quot;&amp;gt;&#039; + this.text + &#039;&amp;lt;/li&amp;gt;&#039;&lt;br /&gt;
&lt;br /&gt;
       $(liCode).appendTo(&#039;#sortable1&#039;+qID+&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   // Allow users to double click to move to selections from list to list&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#sortable1&#039;+qID+&#039; li&#039;).live(&#039;dblclick&#039;, function() {&lt;br /&gt;
&lt;br /&gt;
       if($(&#039;#sortable2&#039;+qID+&#039; li&#039;).length == maxAnswer) {&lt;br /&gt;
&lt;br /&gt;
           alert (&#039;You can only rank a maximum of &#039;+maxAnswer+&#039; choices.&#039;);&lt;br /&gt;
&lt;br /&gt;
           return false;&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       else {&lt;br /&gt;
&lt;br /&gt;
           $(this).appendTo(&#039;#sortable2&#039;+qID+&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#sortable1&#039;+qID+&#039;&#039;).sortable(&#039;refresh&#039;);&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#sortable2&#039;+qID+&#039;&#039;).sortable(&#039;refresh&#039;);&lt;br /&gt;
&lt;br /&gt;
           updateDragDropRank(qID);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#sortable2&#039;+qID+&#039; li&#039;).live(&#039;dblclick&#039;, function() {&lt;br /&gt;
&lt;br /&gt;
       $(this).appendTo(&#039;#sortable1&#039;+qID+&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#sortable2&#039;+qID+&#039;&#039;).sortable(&#039;refresh&#039;);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#sortable1&#039;+qID+&#039;&#039;).sortable(&#039;refresh&#039;);&lt;br /&gt;
&lt;br /&gt;
       updateDragDropRank(qID);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// This function copies the drag and drop sortable data into the LimeSurvey ranking list.&lt;br /&gt;
&lt;br /&gt;
function updateDragDropRank(qID)&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   // Reload the LimeSurvey choices select element&lt;br /&gt;
&lt;br /&gt;
   var rankees = [];&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#sortable2&#039;+qID+&#039; li&#039;).each(function(index) {&lt;br /&gt;
&lt;br /&gt;
       $(this).attr(&#039;value&#039;, index+1);&lt;br /&gt;
&lt;br /&gt;
       // Get value of ranked item&lt;br /&gt;
&lt;br /&gt;
       var liID = $(this).attr(&amp;quot;id&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
       liIDArray = liID.split(&#039;_&#039;);&lt;br /&gt;
&lt;br /&gt;
       // Save to an array&lt;br /&gt;
&lt;br /&gt;
       rankees[rankees.length] = { &amp;quot;r_name&amp;quot;:$(this).text(),&amp;quot;r_value&amp;quot;:liIDArray[1] };&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#question&#039;+qID+&#039; input[name&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&amp;quot;RANK_&amp;quot;]&#039;).each(function(index) {&lt;br /&gt;
&lt;br /&gt;
       if (rankees.length &amp;gt; index) {&lt;br /&gt;
&lt;br /&gt;
           $(this).val(rankees[index].r_name);&lt;br /&gt;
&lt;br /&gt;
           //alert (rankees[index].r_value);&lt;br /&gt;
&lt;br /&gt;
           $(this).next(&#039;input&#039;).attr(&#039;value&#039;, rankees[index].r_value);&lt;br /&gt;
&lt;br /&gt;
       } else {&lt;br /&gt;
&lt;br /&gt;
           $(this).val(&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
           $(this).next().val(&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
     });&lt;br /&gt;
&lt;br /&gt;
   // Reload the LimeSurvey choices select element (we need this for &amp;quot;Minimum answers&amp;quot; code)&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#question&#039;+qID+&#039; td.label select option&#039;).remove();&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#sortable1&#039;+qID+&#039; li&#039;).each(function(index) {&lt;br /&gt;
&lt;br /&gt;
       var liText = $(this).text();&lt;br /&gt;
&lt;br /&gt;
       var liID = $(this).attr(&#039;id&#039;);&lt;br /&gt;
&lt;br /&gt;
       liIDArray = liID.split(&#039;_&#039;);&lt;br /&gt;
&lt;br /&gt;
       var optionCode = &#039;&amp;lt;option value=&amp;quot;&#039;+liIDArray[1]+&#039;&amp;quot;&amp;gt;&#039;+liText+&#039;&amp;lt;/option&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
       $(optionCode).appendTo(&#039;#question&#039;+qID+&#039; td.label select&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   // Hack for IE6&lt;br /&gt;
&lt;br /&gt;
   if ($.browser.msie &amp;amp;&amp;amp; $.browser.version.substr(0,1)&amp;lt;7) {&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+qID+&#039; select&#039;).show();&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+qID+&#039; select&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// This function is called on page load to see if there are any items already ranked (from a previous visit&lt;br /&gt;
&lt;br /&gt;
// or cached due to a page change.  If so, the already-ranked items are loaded into the sortable list&lt;br /&gt;
&lt;br /&gt;
function loadDragDropRank(qID)&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   var rankees = [];&lt;br /&gt;
&lt;br /&gt;
   // Loop through each item in the built-in LimeSurvey ranking list looking for non-empty values&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#question&#039;+qID+&#039; input[name&amp;lt;/div&amp;gt;=&amp;quot;RANK_&amp;quot;]&#039;).each(function(index) {&lt;br /&gt;
&lt;br /&gt;
       // Check to see if the current item has a value&lt;br /&gt;
&lt;br /&gt;
       if ($(this).val()) {&lt;br /&gt;
&lt;br /&gt;
           // Item has a value - save to the array&lt;br /&gt;
&lt;br /&gt;
           // Use this element to contain the name and the next for the value (numeric)&lt;br /&gt;
&lt;br /&gt;
           rankees[rankees.length] = { &amp;quot;r_name&amp;quot;:$(this).val(),&amp;quot;r_value&amp;quot;:$(this).next().val() };&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   // Now that we have a list of all the pre-ranked items, populate the sortable list&lt;br /&gt;
&lt;br /&gt;
   // Note that the items *won&amp;quot;t* appear in the main list because LimeSurvey has removed them.&lt;br /&gt;
&lt;br /&gt;
   $.each(rankees, function(index, value) {&lt;br /&gt;
&lt;br /&gt;
       // Create the items in the sortable&lt;br /&gt;
&lt;br /&gt;
       var liCode = &#039;&amp;lt;li class=&amp;quot;ui-state-default&amp;quot; id=&amp;quot;choice_&#039; + value.r_value + &#039;&amp;quot;&amp;gt;&#039; + value.r_name + &#039;&amp;lt;/li&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
       $(liCode).appendTo(&#039;#sortable2&#039;+qID+&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Code in the source of the question(s) using the LimeSurvey translations for the &amp;quot;Choices&amp;quot; and &amp;quot;Rankings&amp;quot; element header labels&#039;&#039;&#039; (replace &amp;quot;QQ&amp;quot; with the ranking [http://docs.limesurvey.org/SGQA+identifier&amp;amp;structure;=English+Instructions+for+LimeSurvey#General_Description question ID]):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       dragDropRank(QQ);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Code in the source of the question(s) using custom text for the &amp;quot;Choices&amp;quot; and &amp;quot;Rankings&amp;quot; element header labels&#039;&#039;&#039; (replace &amp;quot;QQ&amp;quot; with the ranking [http://docs.limesurvey.org/SGQA+identifier&amp;amp;structure;=English+Instructions+for+LimeSurvey#General_Description question ID]):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       dragDropRank(QQ, &#039;Custom Choices Label&#039;, &#039;Custom Rankings Label&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Styles for template.css:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* Drag-n-drop ranking styles */&lt;br /&gt;
&lt;br /&gt;
.dragDropTable {&lt;br /&gt;
&lt;br /&gt;
   border: 0 none;&lt;br /&gt;
&lt;br /&gt;
   border-collapse: collapse;&lt;br /&gt;
&lt;br /&gt;
   width: 100%;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.dragDropTable td {&lt;br /&gt;
&lt;br /&gt;
   vertical-align: top;&lt;br /&gt;
&lt;br /&gt;
   width: 50%;&lt;br /&gt;
&lt;br /&gt;
   padding-right: 20px;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.dragDropTable .dragDropHeader {&lt;br /&gt;
&lt;br /&gt;
   font-weight: bold;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.dragDropTable .dragDropChoices,&lt;br /&gt;
&lt;br /&gt;
.dragDropTable .dragDropRanks {&lt;br /&gt;
&lt;br /&gt;
   margin: 5px 0 0 0;&lt;br /&gt;
&lt;br /&gt;
   background: transparent none;&lt;br /&gt;
&lt;br /&gt;
   border: 0 none;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.dragDropTable .dragDropChoiceList,&lt;br /&gt;
&lt;br /&gt;
.dragDropTable .dragDropRankList {&lt;br /&gt;
&lt;br /&gt;
   float: left;&lt;br /&gt;
&lt;br /&gt;
   width: 100%;&lt;br /&gt;
&lt;br /&gt;
   min-height: 2.4em;&lt;br /&gt;
&lt;br /&gt;
   _height: 2.4em; /* IE6 and below hack */&lt;br /&gt;
&lt;br /&gt;
   margin: 0;&lt;br /&gt;
&lt;br /&gt;
   padding: 0;&lt;br /&gt;
&lt;br /&gt;
   list-style-type: none;&lt;br /&gt;
&lt;br /&gt;
   background: #FBFBFB none;&lt;br /&gt;
&lt;br /&gt;
   border: 1px solid #CCCCCC;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.dragDropTable .dragDropChoiceList li,&lt;br /&gt;
&lt;br /&gt;
.dragDropTable .dragDropRankList li {&lt;br /&gt;
&lt;br /&gt;
   margin: 3px;&lt;br /&gt;
&lt;br /&gt;
   *margin-left: -13px; /* IE7 and below */&lt;br /&gt;
&lt;br /&gt;
   padding: 3px;&lt;br /&gt;
&lt;br /&gt;
   min-height: 1.3em;&lt;br /&gt;
&lt;br /&gt;
   _height: 1.3em; /* IE6 and below hack */&lt;br /&gt;
&lt;br /&gt;
   font-weight: normal;&lt;br /&gt;
&lt;br /&gt;
   cursor: move;&lt;br /&gt;
&lt;br /&gt;
   display: block; /* Force the li to full width */&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Drag and Drop Ranking using Images - Version 1.90 and newer==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+ &amp;amp; 1.91RC4, IE 6/7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround works in conjunction with the above workaround to allow ranking of images.&lt;br /&gt;
&lt;br /&gt;
[[File:Untitled-11.png]]&lt;br /&gt;
&lt;br /&gt;
There is a &#039;&#039;&#039;[http://www.partnersinc.biz/surveys//index.php?sid=36981&amp;amp;newtest;=Y&amp;amp;lang;=en demonstrated here]&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
&lt;br /&gt;
1) Follow the above workaround to get basic drag-n-drop functionality in your ranking question.&lt;br /&gt;
&lt;br /&gt;
2) Insert your images in the ranking question text or help section after any text that you wish to have there (we&#039;ll move them later with JavaScript).&lt;br /&gt;
&lt;br /&gt;
3) Give the images &#039;&#039;&#039;EXACTLY&#039;&#039;&#039; the same IDs as the answer code you would like them to be associated with:[[File:Untitled-8.png]]&lt;br /&gt;
&lt;br /&gt;
4) Place the first script below in your template.js file.&lt;br /&gt;
&lt;br /&gt;
5) Place the second script below in the source the ranking question &#039;&#039;&#039;AFTER&#039;&#039;&#039; the initial call for the dragDropRank function from the workaround above. Replace &amp;quot;QQ&amp;quot; with the ID of the ranking question (this applies the &amp;quot;dragDropRankImages&amp;quot; function to the question).&lt;br /&gt;
&lt;br /&gt;
6) Insert the CSS below at the end of template.css. Replace &amp;quot;11&amp;quot; with your question ID. These styles are for the default template using 50x50px images (as in the demo) and may need to be modified for other templates or image sizes.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Code for template.js:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
function dragDropRankImages(qID) {&lt;br /&gt;
&lt;br /&gt;
   $(&#039;.connectedSortable&#039;+qID+&#039; li&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
       // Remove any text in the sortable choice or rank items&lt;br /&gt;
&lt;br /&gt;
       $(this).text(&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
       // Move the images into the appropriate sortable list item&lt;br /&gt;
&lt;br /&gt;
       var liID = $(this).attr(&#039;id&#039;);&lt;br /&gt;
&lt;br /&gt;
       liIDArray = liID.split(&#039;_&#039;);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+qID+&#039; img#&#039;+liIDArray[1]+&#039;&#039;).appendTo(this);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Code in the source of the question(s):&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       dragDropRankImages(QQ);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Styles for template.css:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* Drag-n-drop for ranking images */&lt;br /&gt;
#question11 .dragDropTable {&lt;br /&gt;
&lt;br /&gt;
   width: auto;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
#question11 .dragDropTable .dragDropChoiceList,&lt;br /&gt;
#question11 .dragDropTable .dragDropRankList {&lt;br /&gt;
&lt;br /&gt;
   min-height: 60px;&lt;br /&gt;
&lt;br /&gt;
   _height: 60px; /* IE6 and below hack */&lt;br /&gt;
&lt;br /&gt;
   width: auto;&lt;br /&gt;
&lt;br /&gt;
   min-width: 60px;&lt;br /&gt;
&lt;br /&gt;
   _width: 60px; /* IE6 and below hack */&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
#question11 .dragDropTable li {&lt;br /&gt;
&lt;br /&gt;
   background: 0 none;&lt;br /&gt;
&lt;br /&gt;
   border: 0 none;&lt;br /&gt;
&lt;br /&gt;
   height: 50px;&lt;br /&gt;
&lt;br /&gt;
   width: 50px;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
#question11 .dragDropTable li img {&lt;br /&gt;
&lt;br /&gt;
   margin: 0;&lt;br /&gt;
&lt;br /&gt;
   padding: 0;&lt;br /&gt;
&lt;br /&gt;
   border: 0 none;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Drag and Drop Ranking for iPad - Version 1.91 and newer==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: LimeSurvey 1.91, iPad 2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround extends the above workarounds to work with the touch interface on iPads.&lt;br /&gt;
&lt;br /&gt;
1) Follow the &amp;quot;[http://docs.limesurvey.org/Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#Drag_and_Drop_Ranking_-_Version_1.90_and_newer Drag and Drop Ranking - Version 1.90 and newer]&amp;quot; workaround above to get basic drag-n-drop functionality in your ranking question.&lt;br /&gt;
&lt;br /&gt;
2) Download the [https://github.com/furf/jquery-ui-touch-punch jQuery.ui.touch-punch.js plugin] and save it in your template directory.&lt;br /&gt;
&lt;br /&gt;
3) Replace this line in your startpage.pstpl:&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;{TEMPLATEURL}template.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;With this:&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;{TEMPLATEURL}jquery.ui.touch-punch.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;{TEMPLATEURL}template.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Drag and Drop Ranking - Version 1.86==&lt;br /&gt;
&lt;br /&gt;
Tested with 1.86 on IE 7,8, FireFox 3, Chrome, and Safari 4&lt;br /&gt;
&lt;br /&gt;
This workaround uses [http://jqueryui.com/demos/sortable/#connect-lists JQuery connected sortables] to modify a ranking question and allow the survey taker to drag and drop choices instead of clicking.  The nice thing is that the choices can be easily re-arranged or removed from the ranking, all by drag and drop.&lt;br /&gt;
&lt;br /&gt;
I used it for a voting application and some of the element names reflect that use.&lt;br /&gt;
&lt;br /&gt;
It looks best when some CSS is added to control the appearance of the boxers around each choice.&lt;br /&gt;
&lt;br /&gt;
[[File:drag-n-drop.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   // Question ID global variable&lt;br /&gt;
&lt;br /&gt;
    var questionID;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Grab the question ID[[File:drag-n-drop.png]]&lt;br /&gt;
&lt;br /&gt;
       // This is something with a class of &amp;quot;ranking&amp;quot; and an ID that starts with &amp;quot;questionXXXXX&amp;quot;.  The X&#039;s represent the question ID&lt;br /&gt;
&lt;br /&gt;
       var entire_questionID = $(&amp;quot;.ranking[id&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&#039;question&#039;]&amp;quot;).attr(&#039;id&#039;);&lt;br /&gt;
&lt;br /&gt;
       // Get just the question number (ID)&lt;br /&gt;
&lt;br /&gt;
       var patt=/\d+$/;&lt;br /&gt;
&lt;br /&gt;
       questionID=patt.exec(entire_questionID);&lt;br /&gt;
&lt;br /&gt;
       // Hide the original quetion in LimeSurvey (so that we can replace with drag and drop)&lt;br /&gt;
&lt;br /&gt;
       $(&amp;quot;.rank, .questionhelp&amp;quot;).hide();&lt;br /&gt;
&lt;br /&gt;
       // Turn off display of question (to override error checking built into LimeSurvey ranking question)&lt;br /&gt;
&lt;br /&gt;
       $(&amp;quot;#display&amp;quot;+questionID).val(&amp;quot;off&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
       // Add connected sortables to the question&lt;br /&gt;
&lt;br /&gt;
       var html_code = &amp;quot;&amp;lt;table style=&#039;border: medium none ; width: 770px; margin-left: auto; \&lt;br /&gt;
&lt;br /&gt;
                                margin-right: auto;&#039;&amp;gt;&amp;lt;tbody&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td style=&#039;width: 590px; vertical-align: top;&#039;&amp;gt;&amp;lt;h3&amp;gt;List of Candidates:&amp;lt;/h3&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
               &amp;lt;div class=&#039;ui-state-highlight&#039; style=&#039;margin: 5px; float: left;&#039; id=&#039;ballot_list&#039;&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                               &amp;lt;ul id=&#039;sortable1&#039; class=&#039;connectedSortable&#039;&amp;gt;&amp;lt;li&amp;gt;Candidates&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/td&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
               &amp;lt;td style=&#039;vertical-align: top;&#039;&amp;gt;&amp;lt;h3&amp;gt;Your selections:&amp;lt;/h3&amp;gt;&amp;lt;div class=&#039;ui-state-highlight&#039; \&lt;br /&gt;
&lt;br /&gt;
                               style=&#039;margin: 5px; float: left;&#039; id=&#039;voting_selections&#039;&amp;gt;&amp;lt;ol id=&#039;sortable2&#039; class=&#039;connectedSortable&#039;&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
               &amp;lt;li&amp;gt;Voting Area&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/tbody&amp;gt;&amp;lt;/table&amp;gt;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
       $(html_code).appendTo(&amp;quot;#question&amp;quot; + questionID);&lt;br /&gt;
&lt;br /&gt;
       // Remove list items (have to have one item so that LimeSurvey doesn&#039;t remove the &amp;lt;ul&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
       $(&amp;quot;#sortable1 li, #sortable2 li&amp;quot;).remove();&lt;br /&gt;
&lt;br /&gt;
       // Load any previously-set values&lt;br /&gt;
&lt;br /&gt;
       loadRanking();&lt;br /&gt;
&lt;br /&gt;
       // Load jQuery UI&lt;br /&gt;
&lt;br /&gt;
       $.getScript(&amp;quot;/scripts/jquery/jquery-ui.js&amp;quot;, function() {&lt;br /&gt;
&lt;br /&gt;
           // After JQuery UI finishes loading, set up the connected sortable.&lt;br /&gt;
&lt;br /&gt;
           $(&amp;quot;#sortable1, #sortable2&amp;quot;).sortable({&lt;br /&gt;
&lt;br /&gt;
               connectWith: &#039;.connectedSortable&#039;,&lt;br /&gt;
&lt;br /&gt;
               placeholder: &#039;ui-sortable-placeholder&#039;,&lt;br /&gt;
&lt;br /&gt;
               stop: function(event, ui) {&lt;br /&gt;
&lt;br /&gt;
                   $(&amp;quot;#sortable1&amp;quot;).sortable(&amp;quot;refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                   $(&amp;quot;#sortable2&amp;quot;).sortable(&amp;quot;refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                   updateRanking();&lt;br /&gt;
&lt;br /&gt;
                   }&lt;br /&gt;
&lt;br /&gt;
           }).disableSelection();&lt;br /&gt;
&lt;br /&gt;
           // Get the list of candidates from the built-in LimeSurvey question and copy them as items in sortable1&lt;br /&gt;
&lt;br /&gt;
           $(&amp;quot;#CHOICES_&amp;quot; + questionID).children().each(function(index, Element) {&lt;br /&gt;
&lt;br /&gt;
               li_tag = &amp;quot;&amp;lt;li class=&#039;ui-state-default&#039; id=&#039;choice_&amp;quot; + $(this).attr(&#039;value&#039;) + &amp;quot;&#039;&amp;gt;&amp;quot; + this.text + &amp;quot;&amp;lt;/li&amp;gt;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
               $(li_tag).appendTo(&amp;quot;#sortable1&amp;quot;); }    );&lt;br /&gt;
&lt;br /&gt;
           // Make sure the submit button is showing&lt;br /&gt;
&lt;br /&gt;
           $(&amp;quot;:submit[value|=&#039; Submit&#039;]&amp;quot;).show();&lt;br /&gt;
&lt;br /&gt;
           // Show a confirmation alert upon submit&lt;br /&gt;
&lt;br /&gt;
           $(&amp;quot;form&amp;quot;).submit(function() {&lt;br /&gt;
&lt;br /&gt;
               // Override the built-in &amp;quot;disable navigation buttons&amp;quot; feature&lt;br /&gt;
&lt;br /&gt;
               $(&#039;#moveprevbtn, #movenextbtn, #movesubmitbtn&#039;).attr(&#039;disabled&#039;, &#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
               var validated = confirm(&amp;quot;Cast your ballot now?&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
               if (validated) { return true; } else { return false; }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Allow users to double click to move to selection list&lt;br /&gt;
&lt;br /&gt;
           $(&amp;quot;#sortable1 li&amp;quot;).assignDblClick();&lt;br /&gt;
&lt;br /&gt;
       });  // End of JQuery UI loading&lt;br /&gt;
&lt;br /&gt;
   }); // End of JQuery ready function&lt;br /&gt;
&lt;br /&gt;
// Define the actions when an item is double clicked&lt;br /&gt;
&lt;br /&gt;
$.fn.assignDblClick = function()&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   $(this).dblclick(function(){&lt;br /&gt;
&lt;br /&gt;
       $(this).appendTo(&#039;#sortable2&#039;);&lt;br /&gt;
&lt;br /&gt;
       $(&amp;quot;#sortable1&amp;quot;).sortable(&amp;quot;refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
       $(&amp;quot;#sortable2&amp;quot;).sortable(&amp;quot;refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
       updateRanking();&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// This function copies the drag and drop sortable data into the standard LimeSurvey ranking structure.&lt;br /&gt;
&lt;br /&gt;
function updateRanking()&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   var rankees = [];&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#sortable2 li&#039;).each(function(index) {&lt;br /&gt;
&lt;br /&gt;
   $(this).attr(&amp;quot;value&amp;quot;, index+1);&lt;br /&gt;
&lt;br /&gt;
       // Get value of person&lt;br /&gt;
&lt;br /&gt;
       li_tag = $(this).attr(&#039;id&#039;);&lt;br /&gt;
&lt;br /&gt;
       li_tag_array = li_tag.split(&amp;quot;_&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
       // Save to an array&lt;br /&gt;
&lt;br /&gt;
       rankees[rankees.length] = { &#039;r_name&#039;:$(this).text(),&#039;r_value&#039;:li_tag_array[1] };&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   $(&amp;quot;input[name&amp;lt;/div&amp;gt;=&#039;RANK_&#039;]&amp;quot;).each(function(index) {&lt;br /&gt;
&lt;br /&gt;
       if (rankees.length &amp;gt; index) {&lt;br /&gt;
&lt;br /&gt;
           $(this).val(rankees[index].r_name);&lt;br /&gt;
&lt;br /&gt;
           $(this).next().val(rankees[index].r_value);&lt;br /&gt;
&lt;br /&gt;
       } else {&lt;br /&gt;
&lt;br /&gt;
           $(this).val(&amp;quot;&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
           $(this).next().val(&amp;quot;&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
     });&lt;br /&gt;
&lt;br /&gt;
   // Re-assign double click action to first list items and remove&lt;br /&gt;
&lt;br /&gt;
   // double click action from section list items&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#sortable1 li&#039;).unbind(&#039;dblclick&#039;).assignDblClick();&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#sortable2 li&#039;).unbind(&#039;dblclick&#039;);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// This function is called on page load to see if there are any items already ranked (from a previous visit&lt;br /&gt;
&lt;br /&gt;
// or cached due to a page change.  If so, the already-ranked items are loaded into the sortable list&lt;br /&gt;
&lt;br /&gt;
function loadRanking()&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   var rankees = [];&lt;br /&gt;
&lt;br /&gt;
   // Loop through each item in the built-in LimeSurvey ranking list looking for non-empty values&lt;br /&gt;
&lt;br /&gt;
   $(&amp;quot;input[name&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&#039;RANK_&#039;]&amp;quot;).each(function(index) {&lt;br /&gt;
&lt;br /&gt;
       // Check to see if the current item has a value&lt;br /&gt;
&lt;br /&gt;
       if ($(this).val()) {&lt;br /&gt;
&lt;br /&gt;
           // Item has a value - save to the array&lt;br /&gt;
&lt;br /&gt;
           // Use this element to contain the name and the next for the value (numeric)&lt;br /&gt;
&lt;br /&gt;
           rankees[rankees.length] = { &#039;r_name&#039;:$(this).val(),&#039;r_value&#039;:$(this).next().val() };&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   // Now that we have a list of all the pre-ranked items, populate the sortable list&lt;br /&gt;
&lt;br /&gt;
   // Note that the items *won&#039;t* appear in the main list because LimeSurvey has removed them.&lt;br /&gt;
&lt;br /&gt;
   $.each(rankees, function(index, value) {&lt;br /&gt;
&lt;br /&gt;
       // Create the items in the sortable&lt;br /&gt;
&lt;br /&gt;
       li_tag = &amp;quot;&amp;lt;li class=&#039;ui-state-default&#039; id=&#039;choice_&amp;quot; + value.r_value + &amp;quot;&#039;&amp;gt;&amp;quot; + value.r_name + &amp;quot;&amp;lt;/li&amp;gt;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
       $(li_tag).appendTo(&amp;quot;#sortable2&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Create MaxDiff question type=&lt;br /&gt;
&lt;br /&gt;
See the &amp;quot;[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Question+design%2C+layout+and+templating&amp;amp;structure;=English+Instructions+for+LimeSurvey Question design, layout and templating]&amp;quot; section for a workaround that uses JavaScript to convert an &#039;&#039;&#039;&#039;&#039;Array (flexible labels) by column&#039;&#039;&#039;&#039;&#039; question into a [http://en.wikipedia.org/wiki/MaxDiff MaxDiff] question type.&lt;br /&gt;
&lt;br /&gt;
[[File:max_diff_596x253.gif]]&lt;br /&gt;
&lt;br /&gt;
=In a checkbox matrix, have the &#039;none&#039; option in a row disable all other columns in that row=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: Limesurvey 1.90+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The questionId parameter is the base ID of the question matrix (multiflexible).&lt;br /&gt;
&lt;br /&gt;
numColumns and numRows speak for themselves&lt;br /&gt;
&lt;br /&gt;
specialColumns is an array of the columns that have the special ability that when one of them&lt;br /&gt;
&lt;br /&gt;
is checked, none of the others can be checked. E.g., a &#039;none of these&#039; and/or a &#039;do now know&#039; option.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
numColumns=13;&lt;br /&gt;
&lt;br /&gt;
numRows=18;&lt;br /&gt;
&lt;br /&gt;
questionId=&#039;28417X2X24&#039;;&lt;br /&gt;
&lt;br /&gt;
specialColumns=[1,12,13];&lt;br /&gt;
&lt;br /&gt;
function action(obj){&lt;br /&gt;
&lt;br /&gt;
   locator=obj.id.replace(&#039;cbox_&#039;+questionId, &#039;&#039;).split(&#039;_&#039;);&lt;br /&gt;
&lt;br /&gt;
   row=locator[0];&lt;br /&gt;
&lt;br /&gt;
   column=locator[1];&lt;br /&gt;
&lt;br /&gt;
   //alert(&#039;Action for row,column=&#039;+row+&#039;,&#039;+column);&lt;br /&gt;
&lt;br /&gt;
   my_id=&#039;#cbox_&#039;+questionId+row+&#039;_&#039;+column+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
   if($(my_id).attr(&#039;checked&#039;) == false) {&lt;br /&gt;
&lt;br /&gt;
       for( var i=1; i&amp;lt;=numColumns; i++ ) {&lt;br /&gt;
&lt;br /&gt;
           if(i==column) continue;&lt;br /&gt;
&lt;br /&gt;
           id=&#039;#cbox_&#039;+questionId+row+&#039;_&#039;+i&lt;br /&gt;
&lt;br /&gt;
           $(id).attr(&#039;disabled&#039;,false);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   } else {&lt;br /&gt;
&lt;br /&gt;
       for( var i=1; i&amp;lt;=numColumns; i++ ) {&lt;br /&gt;
&lt;br /&gt;
           if(i==column) continue;&lt;br /&gt;
&lt;br /&gt;
           id=&#039;#cbox_&#039;+questionId+row+&#039;_&#039;+i&lt;br /&gt;
&lt;br /&gt;
           aid=&#039;#answer&#039;+questionId+row+&#039;_&#039;+i&lt;br /&gt;
&lt;br /&gt;
           $(aid).val(0);&lt;br /&gt;
&lt;br /&gt;
           $(id).attr(&#039;checked&#039;,false);&lt;br /&gt;
&lt;br /&gt;
           $(id).attr(&#039;disabled&#039;,true);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function customOnLoad(){&lt;br /&gt;
&lt;br /&gt;
   for( var row=1; row&amp;lt;=numRows; row++ ) {&lt;br /&gt;
&lt;br /&gt;
       for( var k=0; k&amp;lt;specialColumns.length; k++ )&lt;br /&gt;
&lt;br /&gt;
       {&lt;br /&gt;
&lt;br /&gt;
           column=specialColumns[k];&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#cbox_&#039;+questionId+row+&#039;_&#039;+column).change(function() {&lt;br /&gt;
&lt;br /&gt;
               action(this);&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
jQuery(document).ready(&lt;br /&gt;
&lt;br /&gt;
   function(){&lt;br /&gt;
&lt;br /&gt;
   customOnLoad();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Last Option In Array (Numbers) (Checkboxes) Row Excludes All Others=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround uses JavaScript/jQuery to make the last option of each Array (Numbers) (Checkboxes) row exclude all other options in the same row.&lt;br /&gt;
&lt;br /&gt;
The script will uncheck all options in a row if the last option is checked and uncheck the last option in a row if any other options are checked.&lt;br /&gt;
&lt;br /&gt;
It&#039;s [http://www.partnersinc.biz/surveys//index.php?sid=22532&amp;amp;newtest;=Y&amp;amp;lang;=en demonstrated here].&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_ Set up your survey to use JavaScript].&lt;br /&gt;
#Place the following script in the source of the array question or the group description.&lt;br /&gt;
#Call the script by replacing &amp;quot;QQ&amp;quot; in line 6 with your array question ID (you can call the script for more array questions by copying this line with new IDs).&lt;br /&gt;
&lt;br /&gt;
NOTE: Care should be taken when using this script and conditional questions on the same page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Call the exclude function using question ID(s)&lt;br /&gt;
&lt;br /&gt;
       excludeOpt (QQ);&lt;br /&gt;
&lt;br /&gt;
       // A function to make the last option in each array row exclusive&lt;br /&gt;
&lt;br /&gt;
       function excludeOpt (qID) {&lt;br /&gt;
&lt;br /&gt;
           // Add some classes to the checkboxes so we can manipulate them&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qID+&#039; table.question tbody td&#039;).addClass(&#039;normalOpt&#039;);&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qID+&#039; table.question tbody&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
               $(&#039;td:last&#039;, this).removeClass(&#039;normalOpt&#039;).addClass(&#039;exlusiveOpt&#039;)&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // A listener on the checkbox cells&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qID+&#039; table.question tbody td&#039;).click(function (event) {&lt;br /&gt;
&lt;br /&gt;
               // Set some vars&lt;br /&gt;
&lt;br /&gt;
               var el = $(this).parent();&lt;br /&gt;
&lt;br /&gt;
               var optLength = $(&#039;td&#039;, el).length&lt;br /&gt;
&lt;br /&gt;
               // Uncheck the appropriate boxes in a row&lt;br /&gt;
&lt;br /&gt;
               if ($(this).hasClass(&#039;normalOpt&#039;)) {&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;td:last input[type=checkbox]&#039;, el).attr(&#039;checked&#039;, false);&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               else {&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;td&#039;, el).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
                       if (i &amp;lt; (optLength - 1)) {&lt;br /&gt;
&lt;br /&gt;
                           $(&#039;input[type=checkbox]&#039;, this).attr(&#039;checked&#039;, false);&lt;br /&gt;
&lt;br /&gt;
                       }&lt;br /&gt;
&lt;br /&gt;
                   });&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // A listener on the checkboxes&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qID+&#039; table.question tbody td input[type=checkbox]&#039;).click(function (event) {&lt;br /&gt;
&lt;br /&gt;
               // Set some vars&lt;br /&gt;
&lt;br /&gt;
               var el2 = $(this).parent().parent();&lt;br /&gt;
&lt;br /&gt;
               var optLength = $(&#039;td&#039;, el2).length&lt;br /&gt;
&lt;br /&gt;
               // Uncheck the appropriate boxes in a row&lt;br /&gt;
&lt;br /&gt;
               if ($(this).parent().hasClass(&#039;normalOpt&#039;)) {&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;td:last input[type=checkbox]&#039;, el2).attr(&#039;checked&#039;, false);&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               else {&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;td&#039;, el2).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
                       if (i &amp;lt; (optLength - 1)) {&lt;br /&gt;
&lt;br /&gt;
                           $(&#039;input[type=checkbox]&#039;, this).attr(&#039;checked&#039;, false);&lt;br /&gt;
&lt;br /&gt;
                       }&lt;br /&gt;
&lt;br /&gt;
                   });&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Load SVG Code From Drawing Tool=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround uses JavaScript/jQuery to load a drawing tool and store the results in a huge-text question.&lt;br /&gt;
&lt;br /&gt;
The drawing tool is supplied by [http://www.mainada.net/inputdraw/ mainada.net].&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#Go to [www.mainada.net/inputdraw/downloads|www.mainada.net/inputdraw/downloads], download the latest package and install all files in the root of your LS installation (you only really need &#039;&#039;&#039;inputdraw.js&#039;&#039;&#039;, &#039;&#039;&#039;inputdraw.non-commercial.v1.5.swf&#039;&#039;&#039; and &#039;&#039;&#039;swfobject.js&#039;&#039;&#039; but the others are cool to play with).&lt;br /&gt;
#Add the following to the &amp;lt;head&amp;gt; element of your template startpage.pstpl file to pull in the scripts:&lt;br /&gt;
&lt;br /&gt;
+~hs&amp;lt;span style=&amp;quot;color:hs&amp;lt;/span&amp;gt;hs&amp;lt;span style=&amp;quot;color:hs~&amp;lt;script src=&amp;quot;swfobject.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
+~hs&amp;lt;/span&amp;gt;hs&amp;lt;span style=&amp;quot;color:hs&amp;lt;/span&amp;gt;hs~&amp;lt;script src=&amp;quot;inputdraw.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
#Create a huge-text question and add the following script to the source of that question.&lt;br /&gt;
&lt;br /&gt;
The script will&amp;quot;&amp;gt;&lt;br /&gt;
*Automatically find the ID of the first huge-text question on the page&lt;br /&gt;
*Insert the drawing element into the huge-text question&lt;br /&gt;
*Hide the textarea of that question&lt;br /&gt;
*Populate it with the SVG code generated by the drawing element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Find the survey, group and question IDs&lt;br /&gt;
&lt;br /&gt;
       if($( &#039;input#fieldnames&#039; ).length != 0) {&lt;br /&gt;
&lt;br /&gt;
           var fieldNames = $(&#039;input#fieldnames&#039;).attr(&#039;value&#039;);&lt;br /&gt;
&lt;br /&gt;
           var tmp = fieldNames.split(&#039;X&#039;);&lt;br /&gt;
&lt;br /&gt;
           var sID = tmp[0];&lt;br /&gt;
&lt;br /&gt;
           var gID = tmp[1];&lt;br /&gt;
&lt;br /&gt;
           var qIDStr = $(&#039;div.text-huge:eq(0)&#039;).attr(&#039;id&#039;);&lt;br /&gt;
&lt;br /&gt;
           var tmp2 = qIDStr.split(&#039;question&#039;);&lt;br /&gt;
&lt;br /&gt;
           var qID = tmp2[1];&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       var textAreaID = &#039;answer&#039;+sID+&#039;X&#039;+gID+&#039;X&#039;+qID;&lt;br /&gt;
&lt;br /&gt;
       // Hide the textarea&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#&#039;+textAreaID+&#039;&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
       // Insert an element for the drawing tool&lt;br /&gt;
&lt;br /&gt;
   $(&#039;&amp;lt;div id=&amp;quot;place&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&#039;).insertBefore($(&#039;#&#039;+textAreaID+&#039;&#039;));&lt;br /&gt;
&lt;br /&gt;
       // Load the drawing tool&lt;br /&gt;
&lt;br /&gt;
   var draw = new InputDraw(&#039;inputdraw.non-commercial.v1.5.swf&#039;, &#039;place&#039;, {&lt;br /&gt;
&lt;br /&gt;
           id:textAreaID,&lt;br /&gt;
&lt;br /&gt;
           width:&#039;350&#039;,&lt;br /&gt;
&lt;br /&gt;
           height:&#039;100&#039;,&lt;br /&gt;
&lt;br /&gt;
           stroke_style:&#039;2 1 rgb(255,0,0)&#039;,&lt;br /&gt;
&lt;br /&gt;
           animation:60,&lt;br /&gt;
&lt;br /&gt;
           color:&#039;#CCCCCC&#039; ,&lt;br /&gt;
&lt;br /&gt;
           tools_color:&#039;0xd6c004&#039;,&lt;br /&gt;
&lt;br /&gt;
           clean:&#039;clear.png&#039;,&lt;br /&gt;
&lt;br /&gt;
           undo:&#039;undo.png&#039;,&lt;br /&gt;
&lt;br /&gt;
           disable:&#039;size opacity color&#039; // Get rid of most of the tools&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Add Navigation Buttons (Next and Previous) To Top Of Page=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Add the following to the end of template.js. It will insert a new div after the progress bar and then insert clones of the nav buttons in the new div.&lt;br /&gt;
&lt;br /&gt;
This example is for the default template in 1.90 or 1.91. The placement of the new div may need to be modified for other templates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Insert a new div after the progress bar&lt;br /&gt;
&lt;br /&gt;
       $(&#039;&amp;lt;div id=&amp;quot;navigator2&amp;quot; /&amp;gt;&#039;).insertAfter(&#039;#progress-wrapper&#039;);&lt;br /&gt;
&lt;br /&gt;
       // Style the new div&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#navigator2&#039;).css({&lt;br /&gt;
&lt;br /&gt;
           &#039;text-align&#039;:&#039;center&#039;&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // Insert clones of the nav buttons in the new div&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input.submit:eq(0)&#039;).clone().appendTo(&#039;#navigator2&#039;);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input.submit:eq(2)&#039;).clone().appendTo(&#039;#navigator2&#039;);&lt;br /&gt;
&lt;br /&gt;
       // Give the new buttons some new IDs&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#navigator2 input.submit&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
           var oldID = $(this).attr(&#039;id&#039;);&lt;br /&gt;
&lt;br /&gt;
           var newID = oldID + &#039;2&#039;;&lt;br /&gt;
&lt;br /&gt;
           $(this).attr(&#039;id&#039;, newID)&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:extra_buttons.png]]&lt;br /&gt;
&lt;br /&gt;
=How to &#039;&#039;add&#039;&#039; an opt out link to your survey using javascript.=&lt;br /&gt;
&lt;br /&gt;
Tested with: 1.91+, Firefox 5.0&lt;br /&gt;
&lt;br /&gt;
This javascript inserts a link to opt out of the survey above the progress bar.&lt;br /&gt;
&lt;br /&gt;
First see the section above entitled: &amp;quot;How to use Script (eg. JavaScript etc.) in LimeSurvey?&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Then insert the following code into to the source of a group description or a question. I used the group description.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt; &amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Find the survey ID&lt;br /&gt;
&lt;br /&gt;
       if($(&#039;input#fieldnames&#039;).length != 0) {&lt;br /&gt;
&lt;br /&gt;
           var fieldNames = $(&#039;input#fieldnames&#039;).attr(&#039;value&#039;);&lt;br /&gt;
&lt;br /&gt;
           var tmp = fieldNames.split(&#039;X&#039;);&lt;br /&gt;
&lt;br /&gt;
           var sID = tmp[0];&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       // Insert a new div after the progress bar&lt;br /&gt;
&lt;br /&gt;
       $(&#039;&amp;lt;div id=&amp;quot;optOutLink&amp;quot; /&amp;gt;&#039;).insertBefore(&#039;#progress-wrapper&#039;);&lt;br /&gt;
&lt;br /&gt;
       // Style the new div&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#optOutLink&#039;).css({&lt;br /&gt;
&lt;br /&gt;
           &#039;text-align&#039;:&#039;center&#039;&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // Insert opt out url in the new div&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#optOutLink&#039;).html(&#039;&amp;lt;P&amp;gt;&amp;lt;a href=&amp;quot;optout.php?lang=en&amp;amp;sid;=&#039;+sID+&#039;&amp;amp;token;={TOKEN}&amp;quot;&amp;gt; /&lt;br /&gt;
&lt;br /&gt;
               Click here to opt out of this survey.&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;&amp;lt;br&amp;gt;&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Anonymously track respondents answers across multiple surveys=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.91+ and 1.92+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround uses JavaScript/jQuery to enable tracking of respondents across multiple surveys ensuring anonymity (it does not use tokens).&lt;br /&gt;
&lt;br /&gt;
To do this you have to use this question in all the surveys you want to link respondents answers.&lt;br /&gt;
&lt;br /&gt;
This workaround create an ID by asking some partial personal information (like initials, birth month ...). The ID will be encrypted using a one-way function (in this case SHA-1) and stored in a brief text answer.&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_ Set up your survey to use JavaScript].&lt;br /&gt;
#Place the following code in the source of a brief text question.&lt;br /&gt;
#Optional: you can also add other select field to avoid collisions (e.g. for large population sample)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;This answers are used to generate your ID. These information will be encrypted, it will not be possible in any case to identify you neither from your answers nor from your ID.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;Initial of your name&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;select id=&amp;quot;field1&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;&amp;quot;&amp;gt;&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;A&amp;quot;&amp;gt;A&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;B&amp;quot;&amp;gt;B&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;C&amp;quot;&amp;gt;C&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;D&amp;quot;&amp;gt;D&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;E&amp;quot;&amp;gt;E&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;F&amp;quot;&amp;gt;F&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;G&amp;quot;&amp;gt;G&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;H&amp;quot;&amp;gt;H&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;I&amp;quot;&amp;gt;I&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;J&amp;quot;&amp;gt;J&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;K&amp;quot;&amp;gt;K&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;L&amp;quot;&amp;gt;L&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;M&amp;quot;&amp;gt;M&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;N&amp;quot;&amp;gt;N&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;O&amp;quot;&amp;gt;O&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;P&amp;quot;&amp;gt;P&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;Q&amp;quot;&amp;gt;Q&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;R&amp;quot;&amp;gt;R&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;S&amp;quot;&amp;gt;S&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;T&amp;quot;&amp;gt;T&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;U&amp;quot;&amp;gt;U&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;V&amp;quot;&amp;gt;V&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;W&amp;quot;&amp;gt;W&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;X&amp;quot;&amp;gt;X&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;Y&amp;quot;&amp;gt;Y&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;Z&amp;quot;&amp;gt;Z&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/select&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;Your birth month&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;select id=&amp;quot;field2&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;&amp;quot;&amp;gt;&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;01&amp;quot;&amp;gt;January&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;02&amp;quot;&amp;gt;February&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;03&amp;quot;&amp;gt;March&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;04&amp;quot;&amp;gt;April&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;05&amp;quot;&amp;gt;May&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;06&amp;quot;&amp;gt;June&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;07&amp;quot;&amp;gt;July&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;08&amp;quot;&amp;gt;August&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;09&amp;quot;&amp;gt;September&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;10&amp;quot;&amp;gt;October&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;11&amp;quot;&amp;gt;November&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;12&amp;quot;&amp;gt;December&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/select&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;http://crypto-js.googlecode.com/svn/tags/3.0.2/build/rollups/sha1.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
   $(&amp;quot;#answer{SGQ}&amp;quot;).attr(&#039;readonly&#039;, &#039;readonly&#039;);&lt;br /&gt;
&lt;br /&gt;
   //$(&amp;quot;#answer{SGQ}&amp;quot;).css(&#039;display&#039;, &#039;none&#039;); //uncomment this line for not displaying the code&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
$(&#039;#field1, #field2&#039;).bind(&#039;change keyup&#039;, function() {&lt;br /&gt;
&lt;br /&gt;
   if ($(&amp;quot;#field1&amp;quot;).val()==&#039;&#039; || $(&amp;quot;#field2&amp;quot;).val()==&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
       $(&amp;quot;#answer{SGQ}&amp;quot;).val(&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
   else {&lt;br /&gt;
&lt;br /&gt;
       var sha1 = CryptoJS.algo.SHA1.create();&lt;br /&gt;
&lt;br /&gt;
       sha1.update($(&amp;quot;#field1&amp;quot;).val());&lt;br /&gt;
&lt;br /&gt;
       sha1.update($(&amp;quot;#field2&amp;quot;).val());&lt;br /&gt;
&lt;br /&gt;
       // sha1.update($(&amp;quot;#otherfield&amp;quot;).val());&lt;br /&gt;
&lt;br /&gt;
       var hash = sha1.finalize();&lt;br /&gt;
&lt;br /&gt;
       $(&amp;quot;#answer{SGQ}&amp;quot;).val(hash);&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Check validity of international phone number in subquestion=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.91+, Firefox 8, Chrome 15&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;As of version 1.92, you can use the core Validation querstion option to validate multiple short text and array text questions. Any question that fails that validation check will have its background color changed to red.&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;Note, the below workaround will fail in version 1.92 because it contains a regular expression with curly braces.  However, as described above, support for this feature is now built-in to version 1.92&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround uses javascript to check the validity of an international phone number in a subquestion of multiple short text.&lt;br /&gt;
&lt;br /&gt;
Add the following code to the source of your question.&lt;br /&gt;
&lt;br /&gt;
Replace &amp;quot;QQ&amp;quot; with the question ID and &amp;quot;NN&amp;quot; with the row number that you want to validate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Call the phone function with the question ID and the row number&lt;br /&gt;
&lt;br /&gt;
       phoneTest(QQ, NN);&lt;br /&gt;
&lt;br /&gt;
       function phoneTest(qID, inputNum) {&lt;br /&gt;
&lt;br /&gt;
           // Interrupt next/submit function&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#movenextbtn, #movesubmitbtn&#039;).click(function(){&lt;br /&gt;
&lt;br /&gt;
               // Some vars - modify as required&lt;br /&gt;
&lt;br /&gt;
               var phoneMatch = /^[0-9,+,(), ,]{1,}(,[0-9]+){0,}$/;&lt;br /&gt;
&lt;br /&gt;
               var msg1 = &#039;Please enter a valid phone number.&#039;;&lt;br /&gt;
&lt;br /&gt;
               // Test the input&lt;br /&gt;
&lt;br /&gt;
               var phoneInput = $(&#039;#question&#039;+qID+&#039; li:eq(&#039;+(inputNum-1)+&#039;) input.text&#039;).val();&lt;br /&gt;
&lt;br /&gt;
               if(phoneInput != &#039;&#039; &amp;amp;&amp;amp; !phoneMatch.test(phoneInput)) {&lt;br /&gt;
&lt;br /&gt;
                   alert(msg1);&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;#question&#039;+qID+&#039; li:eq(&#039;+(inputNum-1)+&#039;) input.text&#039;).css({ &#039;background&#039;:&#039;pink&#039; });&lt;br /&gt;
&lt;br /&gt;
                   return false;&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               else {&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;#question&#039;+qID+&#039; li:eq(&#039;+(inputNum-1)+&#039;) input.text&#039;).css({ &#039;background&#039;:&#039;&#039; });&lt;br /&gt;
&lt;br /&gt;
                   return true;&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The regex is from: [http://www.regexlib.com/REDetails.aspx?regexp_id=1136 regexlib.com blank]&lt;br /&gt;
&lt;br /&gt;
=Check validity of email address in subquestion=&lt;br /&gt;
&lt;br /&gt;
&#039;Tested with: 1.91+, Firefox 8, Chrome 15&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;As of version 1.92, you can use the core Validation querstion option to validate multiple short text and array text questions. Any question that fails that validation check will have its background color changed to red.&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;Note, the below workaround will fail in version 1.92 because it contains a regular expression with curly braces.  However, as described above, support for this feature is now built-in to version 1.92&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround uses javascript to check the validity of an email address in a subquestion of multiple short text.&lt;br /&gt;
&lt;br /&gt;
Add the following code to the source of your question.&lt;br /&gt;
&lt;br /&gt;
Replace &amp;quot;QQ&amp;quot; with the question ID and &amp;quot;NN&amp;quot; with the row number that you want to validate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Call the email function with the question ID and the row number&lt;br /&gt;
&lt;br /&gt;
       emailTest(QQ, NN);&lt;br /&gt;
&lt;br /&gt;
       function emailTest(qID, inputNum) {&lt;br /&gt;
&lt;br /&gt;
           // Interrupt next/submit function&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#movenextbtn, #movesubmitbtn&#039;).click(function(){&lt;br /&gt;
&lt;br /&gt;
               // Some vars - modify as required&lt;br /&gt;
&lt;br /&gt;
               var emailMatch = /^[a-zA-Z0-9\_\-]+[a-zA-Z0-9\.\_\-]*@([a-zA-Z0-9\_\-]+\.)+([a-zA-Z]{2,4}|travel|museum)$/;&lt;br /&gt;
&lt;br /&gt;
               var msg1 = &#039;Please enter a valid email address.&#039;;&lt;br /&gt;
&lt;br /&gt;
               // Test the input&lt;br /&gt;
&lt;br /&gt;
               var emailInput = $(&#039;#question&#039;+qID+&#039; li:eq(&#039;+(inputNum-1)+&#039;) input.text&#039;).val();&lt;br /&gt;
&lt;br /&gt;
               if(emailInput != &#039;&#039; &amp;amp;&amp;amp; !emailMatch.test(emailInput)) {&lt;br /&gt;
&lt;br /&gt;
                   alert(msg1);&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;#question&#039;+qID+&#039; li:eq(&#039;+(inputNum-1)+&#039;) input.text&#039;).css({ &#039;background&#039;:&#039;pink&#039; });&lt;br /&gt;
&lt;br /&gt;
                   return false;&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               else {&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;#question&#039;+qID+&#039; li:eq(&#039;+(inputNum-1)+&#039;) input.text&#039;).css({ &#039;background&#039;:&#039;&#039; });&lt;br /&gt;
&lt;br /&gt;
                   return true;&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The regex is from: [http://www.regexlib.com/REDetails.aspx?regexp_id=1653 regexlib.com blank]&lt;br /&gt;
&lt;br /&gt;
=Hiding the help-text when it&#039;s empty=&lt;br /&gt;
&lt;br /&gt;
Tested with: 1.91+&lt;br /&gt;
&lt;br /&gt;
I had made a style in my template putting a border around my help-text. To avoid empty help-text to show up (and have lines instead of just &#039;nothing&#039; when there was no help text, I used this piece of code in question.pstpl:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
                   var questionhelp=&amp;quot;{QUESTIONHELP}&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
                   if (questionhelp==&amp;quot;&amp;quot;) {&lt;br /&gt;
&lt;br /&gt;
                          document.write(&amp;quot;&amp;quot;);}&lt;br /&gt;
&lt;br /&gt;
                   else {&lt;br /&gt;
&lt;br /&gt;
                   document.write(&#039;&amp;lt;tr&amp;gt;&amp;lt;td class=&amp;quot;survey-question-help&amp;quot;&amp;gt;&#039;+ questionhelp +&#039;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&#039;);}&lt;br /&gt;
&lt;br /&gt;
               &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
it can probably be optimized but it worked for me&lt;br /&gt;
&lt;br /&gt;
=Disable or hide selected fields in a matrix question=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.92+, IE 7/8/9, FireFox 12/13&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
TASK&lt;br /&gt;
&lt;br /&gt;
Hide or disable selected fields in a Matrix, so that users cannot make any input.&lt;br /&gt;
&lt;br /&gt;
(See example, where users should not make input into red framed fields)&lt;br /&gt;
&lt;br /&gt;
[[File:snap035.gif]]&lt;br /&gt;
&lt;br /&gt;
Fig. 1: Prevent users from input into first two fields (as an example)&lt;br /&gt;
&lt;br /&gt;
SOLUTION&lt;br /&gt;
&lt;br /&gt;
First find the name of the fields you want to hide / disable. In my case I used Firebug with firefox to figure that out.&lt;br /&gt;
&lt;br /&gt;
[[File:snap037.gif]]&lt;br /&gt;
&lt;br /&gt;
Fig. 2: Figure out the name(s) of the field(s)&lt;br /&gt;
&lt;br /&gt;
Then put the following script-code into the HTML-source code as described above:&lt;br /&gt;
&lt;br /&gt;
Note: you have to change the code to match the names of your fields!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input[name=&amp;quot;69965X2X10SQ001_SQ001&amp;quot;]&#039;).attr(&#039;disabled&#039;, &#039;disabled&#039;);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input[name=&amp;quot;69965X2X10SQ001_SQ002&amp;quot;]&#039;).attr(&#039;hidden&#039;, &#039;hidden&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:snap039.gif]]&lt;br /&gt;
&lt;br /&gt;
Fig. 3: Result: first field is diabled (&amp;quot;greyed out&amp;quot;), second one is completely hidden&lt;br /&gt;
&lt;br /&gt;
I think this way one can apply many other attributes to a field like color etc. But did not try that myself.&lt;br /&gt;
&lt;br /&gt;
Thanks to roB2009 for the input in the forum!&lt;br /&gt;
&lt;br /&gt;
=Add prefix or suffix to question type &amp;quot;Array (Texts)&amp;quot;=&lt;br /&gt;
&lt;br /&gt;
TASK&lt;br /&gt;
&lt;br /&gt;
Add a prefix or suffix to the text fields in questions of the &amp;quot;Array (Texts)&amp;quot; type.&lt;br /&gt;
&lt;br /&gt;
[[File:suffix.png]]&lt;br /&gt;
&lt;br /&gt;
Fig. 1: Suffix&lt;br /&gt;
&lt;br /&gt;
[[File:prefix.png]]&lt;br /&gt;
&lt;br /&gt;
Fig. 1: Prefix&lt;br /&gt;
&lt;br /&gt;
SOLUTION&lt;br /&gt;
*Set up your survey to use JavaScript.&lt;br /&gt;
*Add the following script to the source of the array. Replace &amp;quot;12345&amp;quot; with the array question ID and modify the suffixes/prefixes as required.&lt;br /&gt;
*The function call must consist of a question ID followed by the suffixes for each column. Suffixes/Prefixes must be enclosed in quotes and comma separated.&lt;br /&gt;
*In this example question ID 12345 will get an &amp;quot;in &amp;amp;euro;&amp;quot; suffix in the first column and an &amp;quot;in %&amp;quot; in the next 3 columns.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Call the function with the question ID followed by a comma-separated list of suffixes&lt;br /&gt;
&lt;br /&gt;
       addSuffix(12345, &#039;in &amp;amp;euro;&#039;, &#039;in %&#039;, &#039;in %&#039;, &#039;in %&#039;);&lt;br /&gt;
&lt;br /&gt;
       function addSuffix() {&lt;br /&gt;
&lt;br /&gt;
           var qID = $(arguments)[0];&lt;br /&gt;
&lt;br /&gt;
           // Assign some column-specific classes&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qID+&#039; table.question tbody tr&#039;).each(function(i){&lt;br /&gt;
&lt;br /&gt;
               $(&#039;td&#039;, this).each(function(i){&lt;br /&gt;
&lt;br /&gt;
                   $(this).addClass(&#039;answerCol-&#039;+(i+1)+&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
               });&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Some styling&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qID+&#039; table.question tbody input[type=&amp;quot;text&amp;quot;]&#039;).css({&lt;br /&gt;
&lt;br /&gt;
               &#039;width&#039;: &#039;50%&#039;&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Insert the suffixes&lt;br /&gt;
&lt;br /&gt;
           $(arguments).each(function(i, val){&lt;br /&gt;
&lt;br /&gt;
               if(i &amp;gt; 0) {&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;#question&#039;+qID+&#039; td.answerCol-&#039;+i+&#039; label&#039;).append(val);&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For adding a prefix you need to substitute the following line in the code&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;$(&#039;#question&#039;+qID+&#039; td.answerCol-&#039;+i+&#039; label&#039;).append(val);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with this&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;$(&#039;#question&#039;+qID+&#039; td.answerCol-&#039;+i+&#039; label&#039;).prepend(val);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Add prefix or suffix to question type &amp;quot;Array (Texts)&amp;quot;=&lt;br /&gt;
&lt;br /&gt;
TASK&lt;br /&gt;
&lt;br /&gt;
Add a prefix or suffix to the text fields in questions of the &amp;quot;Array (Texts)&amp;quot; type.&lt;br /&gt;
&lt;br /&gt;
[[File:suffix.png]]&lt;br /&gt;
&lt;br /&gt;
Fig. 1: Suffix&lt;br /&gt;
&lt;br /&gt;
[[File:prefix.png]]&lt;br /&gt;
&lt;br /&gt;
Fig. 1: Prefix&lt;br /&gt;
&lt;br /&gt;
SOLUTION&lt;br /&gt;
*Set up your survey to use JavaScript.&lt;br /&gt;
*Add the following script to the source of the array. Replace &amp;quot;12345&amp;quot; with the array question ID and modify the suffixes/prefixes as required.&lt;br /&gt;
*The function call must consist of a question ID followed by the suffixes for each column. Suffixes/Prefixes must be enclosed in quotes and comma separated.&lt;br /&gt;
*In this example question ID 12345 will get an &amp;quot;in &amp;amp;euro;&amp;quot; suffix in the first column and an &amp;quot;in %&amp;quot; in the next 3 columns.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Call the function with the question ID followed by a comma-separated list of suffixes&lt;br /&gt;
&lt;br /&gt;
       addSuffix(12345, &#039;in &amp;amp;euro;&#039;, &#039;in %&#039;, &#039;in %&#039;, &#039;in %&#039;);&lt;br /&gt;
&lt;br /&gt;
       function addSuffix() {&lt;br /&gt;
&lt;br /&gt;
           var qID = $(arguments)[0];&lt;br /&gt;
&lt;br /&gt;
           // Assign some column-specific classes&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qID+&#039; table.question tbody tr&#039;).each(function(i){&lt;br /&gt;
&lt;br /&gt;
               $(&#039;td&#039;, this).each(function(i){&lt;br /&gt;
&lt;br /&gt;
                   $(this).addClass(&#039;answerCol-&#039;+(i+1)+&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
               });&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Some styling&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qID+&#039; table.question tbody input[type=&amp;quot;text&amp;quot;]&#039;).css({&lt;br /&gt;
&lt;br /&gt;
               &#039;width&#039;: &#039;50%&#039;&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Insert the suffixes&lt;br /&gt;
&lt;br /&gt;
           $(arguments).each(function(i, val){&lt;br /&gt;
&lt;br /&gt;
               if(i &amp;gt; 0) {&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;#question&#039;+qID+&#039; td.answerCol-&#039;+i+&#039; label&#039;).append(val);&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For adding a prefix you need to substitute the following line in the code&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;$(&#039;#question&#039;+qID+&#039; td.answerCol-&#039;+i+&#039; label&#039;).append(val);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with this&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;$(&#039;#question&#039;+qID+&#039; td.answerCol-&#039;+i+&#039; label&#039;).prepend(val);&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Holch</name></author>
	</entry>
	<entry>
		<id>https://www.limesurvey.org/manual/index.php?title=Workarounds:_Manipulating_a_survey_at_runtime_using_Javascript&amp;diff=3791</id>
		<title>Workarounds: Manipulating a survey at runtime using Javascript</title>
		<link rel="alternate" type="text/html" href="https://www.limesurvey.org/manual/index.php?title=Workarounds:_Manipulating_a_survey_at_runtime_using_Javascript&amp;diff=3791"/>
		<updated>2012-07-06T22:47:29Z</updated>

		<summary type="html">&lt;p&gt;Holch: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
Often you want to manipulate certain elements of a survey at runtime. The only solution without touching the source code is to use Javascript or jQuery which is shipped with Limesurvey. Here are some examples to hide and style elements, validate user input or do calculations at runtime.&lt;br /&gt;
&lt;br /&gt;
Non Javascript workarounds can be found at&lt;br /&gt;
* [http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Survey+behaviour&amp;amp;structure;=English+Instructions+for+LimeSurvey Workarounds - Survey Behavior]&lt;br /&gt;
* [http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Question+design%2C+layout+and+templating Workarounds - Question design, layout and templating]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;&amp;lt;center&amp;gt;&#039;&#039;&#039;Please keep in mind that the workarounds published here are no official Limesurvey extensions but solutions that other users created for themselves.&amp;lt;br/&amp;gt;&amp;lt;span style=&#039;color:#EE0000,#FFFFFF&#039;&amp;gt;Therefore we can&#039;t give support for any solution on this page.&amp;lt;/span&amp;gt;&amp;lt;br/&amp;gt;Please contact the users that, thankfully, shared their solutions with the community if you have any questions.&#039;&#039;&#039;&amp;lt;/center&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;Note:  Version 1.92 implements many new features that make some existing workarounds obsolete.  You can continue to use existing workarounds, but may want to consider switching over to using the new features (since those new features are officially supported, and the workarounds are not).  Please review below for details of which are no longer needed.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;Also Note:  Version 1.92&#039;s Expression Manager (EM) may cause some of these work-arounds to fail.  Any custom javascript included as a .js file will be fine.  However, if you in-line your JavaScript code, you must make sure that you have a space after every opening (left) curly brace, and a space before every closing (right) curly brace.  Otherwise, EM will think that the content between the curly braces is something it should parse and understand.  I have fixed all of the work-arounds below that can be fixed (many did not follow those rules).  However, some will continue to break.  If a work-around contains a regular expression which contains curly braces (to indicate a range of repeats of a sub-expression), EM will try to process those curly braces, and thus break your regular expression.  Strategies to continue to support that work-around functionality are discussed below.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=How to &#039;&#039;add&#039;&#039; a javascript workaround solution to this Wiki page?=&lt;br /&gt;
&lt;br /&gt;
Well, this is pretty easy. Click the edit icon and create your own headline within the javascript section starting with &amp;quot;&#039;&#039;&#039;!&#039;&#039;&#039;&amp;quot;. Then add a short note about the version you have used when creating your workaround, you can copy/paste this code snippet &amp;lt;nowiki&amp;gt;&#039;&#039;Tested with: (enter Limesurvey version and maybe browser)&#039;&#039;&amp;lt;/nowiki&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Finally it&#039;s imported to mark all your code with code tags, other wise you might break this page.&lt;br /&gt;
*Start tag: &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
*End tag: &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=How to &#039;&#039;use&#039;&#039; Script (eg. JavaScript etc.) in LimeSurvey?=&lt;br /&gt;
&lt;br /&gt;
To use JavaScript within Limesurvey, the XSS filter must be turned off and the code inserted in the source of a question or a group description.&lt;br /&gt;
*Go to Global settings --&amp;gt; Security and set &amp;quot;Filter HTML for XSS&amp;quot; to &amp;quot;Off&amp;quot;.&lt;br /&gt;
* [http://docs.limesurvey.org/tiki-index.php?page=Adding+A+Question Add a new question]&lt;br /&gt;
* Edit the question and click the &amp;quot;Source&amp;quot; button in the editor toolbar:&lt;br /&gt;
&lt;br /&gt;
   [[File:editor_1.gif]]&lt;br /&gt;
* Enter your script after the question text:&lt;br /&gt;
&lt;br /&gt;
   [[File:editor_2.gif]]&lt;br /&gt;
* Save the question&lt;br /&gt;
&lt;br /&gt;
A simple test to see if JavaScript is enabled is to echo an alert. Use this code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   alert(&amp;quot;Test!&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is a good practice to use the jQuery $(document).ready function to prevent the code from executing until the page is fully loaded:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       alert(&amp;quot;Test!&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Sum up input values using Javascript=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, this is easier to do using the sum() function in [[Expression Manager|Expression Manager]].  See this [[Expression Manager HowTos|#Calculate assessment values at runtime and store the results in the survey data|HowTo example]].&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is from a survey that is a invitation to a longer party, when the user clicks to the next page, the calculated results will be shown.&lt;br /&gt;
&lt;br /&gt;
If you wonder what the {INSERTANS:1X6X12} stuff is, look at [http://docs.limesurvey.org/tiki-index.php?page=SGQA+Identifier SGQA identifier] and [http://docs.limesurvey.org/tiki-index.php?page=Adding+a+Question#Information_from_previous_answers Using information from previous answers].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;text-align: left&amp;quot;&amp;gt;These are your answers:&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;u&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;u&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;u&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;u&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;script LANGUAGE=&amp;quot;JavaScript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
partyprice = 3;&lt;br /&gt;
&lt;br /&gt;
beadclothprice = 3;&lt;br /&gt;
&lt;br /&gt;
breakfastprice = 7;&lt;br /&gt;
&lt;br /&gt;
lunchprice = 8;&lt;br /&gt;
&lt;br /&gt;
dinnerprice = 10;&lt;br /&gt;
&lt;br /&gt;
foodtotal = 0;&lt;br /&gt;
&lt;br /&gt;
var isreallytrue = &amp;quot;Yes&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
var noanswer = &amp;quot;No answer&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
document.write( &amp;quot;Can you come? = {INSERTANS:45251X1X1}&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
if (&amp;quot;{INSERTANS:45251X1X1}&amp;quot; == isreallytrue )&lt;br /&gt;
&lt;br /&gt;
  {&lt;br /&gt;
&lt;br /&gt;
   if (&amp;quot;{INSERTANS:45251X1X3}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
   else { answer = &amp;quot;{INSERTANS:45251X1X3}&amp;quot;; }&lt;br /&gt;
&lt;br /&gt;
   partypeople = parseInt(answer);&lt;br /&gt;
&lt;br /&gt;
   partytotal = partyprice * partypeople;&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;It&#039;s {INSERTANS:45251X1X3} persons who will come = &amp;quot; + partytotal + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   if (&amp;quot;{INSERTANS:45251X1X4}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
   else { answer = &amp;quot;{INSERTANS:45251X1X4}&amp;quot;;}&lt;br /&gt;
&lt;br /&gt;
   beadcloths = parseInt(answer);&lt;br /&gt;
&lt;br /&gt;
   beadclothtotal = beadclothprice * beadcloths;&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;You want to borrow {INSERTANS:45251X1X4} beadcloths = &amp;quot; + beadclothtotal + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;Will you be there thursday? = {INSERTANS:45251X1X5}&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;On friday you will have these meals: &amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   if (&amp;quot;{INSERTANS:45251X1X71}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
   else { answer = &amp;quot;{INSERTANS:45251X1X71}&amp;quot;;}&lt;br /&gt;
&lt;br /&gt;
   breakfastfriday = parseInt(answer) * breakfastprice;&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; breakfeasts = &amp;quot; + breakfastfriday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   if (&amp;quot;{INSERTANS:45251X1X72}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
   else { answer = &amp;quot;{INSERTANS:45251X1X72}&amp;quot;;}&lt;br /&gt;
&lt;br /&gt;
   lunchfriday = parseInt(answer) * lunchprice ;&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; lunches = &amp;quot; + lunchfriday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   if (&amp;quot;{INSERTANS:45251X1X73}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
   else { answer = &amp;quot;{INSERTANS:45251X1X73}&amp;quot;;}&lt;br /&gt;
&lt;br /&gt;
   dinnerfriday = parseInt(answer)* dinnerprice ;&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; dinners = &amp;quot; + dinnerfriday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   foodtotal = breakfastfriday + lunchfriday + dinnerfriday;&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;Will you be there saturday? = {INSERTANS:45251X1X8}&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   if (&amp;quot;{INSERTANS:45251X1X8}&amp;quot; == isreallytrue )&lt;br /&gt;
&lt;br /&gt;
      {&lt;br /&gt;
&lt;br /&gt;
       document.write( &amp;quot;On saturday you will have these meals: &amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
       if (&amp;quot;{INSERTANS:45251X1X91}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
       else { answer = &amp;quot;{INSERTANS:45251X1X91}&amp;quot;; }&lt;br /&gt;
&lt;br /&gt;
       breakfastsaturday = parseInt(answer) * breakfastprice ;&lt;br /&gt;
&lt;br /&gt;
       document.write(&amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; breakfeasts = &amp;quot; + breakfastsaturday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
       if (&amp;quot;{INSERTANS:45251X1X92}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
       else { answer = &amp;quot;{INSERTANS:45251X1X92}&amp;quot;; }&lt;br /&gt;
&lt;br /&gt;
       lunchsaturday = parseInt(answer) * lunchprice ;&lt;br /&gt;
&lt;br /&gt;
       document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; lunches = &amp;quot; + lunchsaturday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
       if (&amp;quot;{INSERTANS:45251X1X93}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
       else { answer = &amp;quot;{INSERTANS:45251X1X93}&amp;quot;; }&lt;br /&gt;
&lt;br /&gt;
       dinnersaturday = parseInt(answer) * dinnerprice ;&lt;br /&gt;
&lt;br /&gt;
       document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; dinners = &amp;quot; + dinnersaturday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
       foodtotal = foodtotal + breakfastsaturday + lunchsaturday + dinnersaturday;&lt;br /&gt;
&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;Will you be there sunday? = {INSERTANS:45251X1X10}&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   if (&amp;quot;{INSERTANS:45251X1X10}&amp;quot; == isreallytrue )&lt;br /&gt;
&lt;br /&gt;
      {&lt;br /&gt;
&lt;br /&gt;
       document.write( &amp;quot;On sunday you will have these meals: &amp;lt;br&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
       if (&amp;quot;{INSERTANS:45251X1X111}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
       else { answer = &amp;quot;{INSERTANS:45251X1X111}&amp;quot;; }&lt;br /&gt;
&lt;br /&gt;
       breakfastsunday = parseInt(answer) * breakfastprice ;&lt;br /&gt;
&lt;br /&gt;
       document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; breakfeasts = &amp;quot; + breakfastsunday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot;  );&lt;br /&gt;
&lt;br /&gt;
       if (&amp;quot;{INSERTANS:45251X1X112}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
       else { answer = &amp;quot;{INSERTANS:45251X1X112}&amp;quot;; }&lt;br /&gt;
&lt;br /&gt;
       lunchsunday = parseInt(answer) * lunchprice ;&lt;br /&gt;
&lt;br /&gt;
       document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; lunches = &amp;quot; + lunchsunday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
       if (&amp;quot;{INSERTANS:45251X1X113}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
       else { answer = &amp;quot;{INSERTANS:45251X1X113}&amp;quot;; }&lt;br /&gt;
&lt;br /&gt;
       dinnersunday = parseInt(answer) * dinnerprice ;&lt;br /&gt;
&lt;br /&gt;
       document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; dinners = &amp;quot; + dinnersunday + &amp;quot;&amp;amp;euro;&amp;lt;p&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
       foodtotal = foodtotal + breakfastsunday + lunchsunday + dinnersunday;&lt;br /&gt;
&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
   total = partytotal + beadclothtotal + foodtotal;&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;&amp;lt;h3&amp;gt;In total it will cost you &amp;quot; + total + &amp;quot;&amp;amp;euro;&amp;lt;/h3&amp;gt;&amp;lt;BR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   Put that sum in this bank account 1234 5678 9012&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/SCRIPT&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Multiple Question Validation=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, this is easier to do using the min/max/equals_num_value attributes (to validate sums), or the em_validation_q function, which lets you refer to other variables when you validate the current question [[Expression Manager|Expression Manager]].  Such validations also work on the current page, and properly handle array_filter and cascading relevance.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround is in case you need to do some validation involving more than one question, it implies a very little JavaScript programming and the use of SQGA Identifiers; this should work on almost any version of LimeSurvey.&lt;br /&gt;
&lt;br /&gt;
Is easy to explain with an example, we need to do a survey of the percentage of males and females and we want to be sure that the sum is 100, to do this follow this steps (the necessary data that is not indicated in these instructions are not important i.e. question codes, etc.):&lt;br /&gt;
#Create a new survey of type &amp;amp;ldquo;group by group&amp;amp;rdquo;, set the &amp;amp;ldquo;Show |&amp;lt;&amp;lt; Prev| button&amp;amp;rdquo; to yes and note the SID.&lt;br /&gt;
#Add a new group called &amp;amp;ldquo;Group 1&amp;amp;rdquo; and note the GID.&lt;br /&gt;
#Add a new question &amp;amp;ldquo;Percent of males&amp;amp;rdquo; of type &amp;amp;ldquo;numeric&amp;amp;rdquo;, make it mandatory and note the QID (we will refer to this as QID1).&lt;br /&gt;
#Add a new question &amp;amp;ldquo;Percent of females&amp;amp;rdquo; of type &amp;amp;ldquo;numeric&amp;amp;rdquo;, make it mandatory and note the QID (we will refer to this as QID2).&lt;br /&gt;
#Add a new group called &amp;amp;ldquo;Group 2&amp;amp;rdquo;&lt;br /&gt;
#Add a new non mandatory question, here is the trick the question text has to be (be sure to replace the SID, GID, QID1 and QID2&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
function validation()&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   if [[{INSERTANS:SIDXGIDXQID1}+{INSERTANS:SIDXGIDXQID2}) != 100)&lt;br /&gt;
&lt;br /&gt;
   {&lt;br /&gt;
&lt;br /&gt;
     alert(&amp;quot;Your responses don&#039;t sum 100! Check them&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
     document.limesurvey.move.value = &#039;moveprev&#039;;&lt;br /&gt;
&lt;br /&gt;
     document.limesurvey.submit();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   else&lt;br /&gt;
&lt;br /&gt;
   {&lt;br /&gt;
&lt;br /&gt;
     document.limesurvey.move.value = &#039;movelast&#039;;&lt;br /&gt;
&lt;br /&gt;
     document.limesurvey.submit();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 setTimeout(&amp;quot;validation()&amp;quot;,250);&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 But this will show shortly the question and will jump to the end page, a little weird for the survey taker but works.&lt;br /&gt;
&lt;br /&gt;
 This is a proof of concept, and may have some problems, please if you notice something or improve it send me an e-mail to leochaton-limesurvey at yahoo dot com.&lt;br /&gt;
&lt;br /&gt;
 This will work for 2 questions that you want to be the same.  Works well for email and confirm email questions&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  function validation() {&lt;br /&gt;
&lt;br /&gt;
  if (&amp;quot;{INSERTANS:SIDXGIDXQID}&amp;quot; != &amp;quot;{INSERTANS:SIDXGIDXQID}&amp;quot;) {&lt;br /&gt;
&lt;br /&gt;
     alert(&amp;quot;Your responses don&#039;t match Check them&amp;quot;); document.limesurvey.move.value = &#039;moveprev&#039;;&lt;br /&gt;
&lt;br /&gt;
     document.limesurvey.submit();&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  setTimeout(&amp;quot;validation()&amp;quot;,250);&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 =Alternate exit=&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with: &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 Using the same idea of the previous post, you can implement an alternate exit of your survey.&lt;br /&gt;
&lt;br /&gt;
 This script should be in the first question to be displayed in a next page after the question that should trigger the alternate exit. In this example the question that trigger the alternate exit is a Yes/No question, if the user chooses no, he is redirected to another page.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 if (&amp;quot;{INSERTANS:SIDXGIDXQID}&amp;quot; == &amp;quot;No&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
&lt;br /&gt;
   window.location=&amp;quot;http://www.limesurvey.org&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 =Custom onload function=&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with: &#039;All browsers&#039;, LimeSurvey 1.70 and up&lt;br /&gt;
&lt;br /&gt;
 ==General==&lt;br /&gt;
&lt;br /&gt;
 This simple workaround describes how to &#039;&#039;&#039;add a custom Javascript code&#039;&#039;&#039; that is triggered right after the page is loaded. It may have numerous applications, especially when you deal with a custom JS/HTML code. It may be used to hide form elements (&amp;lt;input&amp;gt;  tags), make them read-only, display alert messages, etc.&lt;br /&gt;
&lt;br /&gt;
 To run any Javascript code right after page load use the Query ready() function. It will be executed when the page is being loaded. For example when you add the following code to one of your question definitions...:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 jQuery(document).ready(&lt;br /&gt;
&lt;br /&gt;
    function(){&lt;br /&gt;
&lt;br /&gt;
        alert(&#039;onload alert!&#039;);&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
 );&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ...it will display a pop-up message immediately after the page has been loaded.&lt;br /&gt;
&lt;br /&gt;
 Some of the applications of this trick I&#039;ve explored are:&lt;br /&gt;
&lt;br /&gt;
 a) Hiding the form elements by calling in your Custom_On_Load:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;document.getElementById(&amp;quot;answer73166X16X54&amp;quot;).style.display=&#039;none&#039;;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 Note: As of svn build 9755, you can now dynamically reference the questions input fields by using the {SGQ} keyword. You can rewrite the previous example like this:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;document.getElementById(&amp;quot;answer{SGQ}&amp;quot;).style.display=&#039;none&#039;;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 this makes it a little easier when exporting surveys, so you don&#039;t have to worry about manually entering each questions SurveyGroupQuestion ID.&lt;br /&gt;
&lt;br /&gt;
 b) Making the elements read only:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;document.getElementById(&amp;quot;answer73166X16X54&amp;quot;).readOnly=true;&amp;lt;/syntaxhighlight&amp;gt; where the &amp;quot;answer73166X16X54&amp;quot; structure has been described in one of other workarounds above.&lt;br /&gt;
&lt;br /&gt;
 c) For Hiding by a lot of elements by calling in your Customer_On_Load&lt;br /&gt;
&lt;br /&gt;
 jQuery searchs in html document for input-fields with radio type, if his answer text empty then do the display css set to none.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 jQuery(document).ready(&lt;br /&gt;
&lt;br /&gt;
            function() {&lt;br /&gt;
&lt;br /&gt;
              jQuery(&#039;input:radio&#039;).each(&lt;br /&gt;
&lt;br /&gt;
                function() {&lt;br /&gt;
&lt;br /&gt;
                  var s = jQuery(this);&lt;br /&gt;
&lt;br /&gt;
                  var c = s.parent().children(&#039;.answertext&#039;);&lt;br /&gt;
&lt;br /&gt;
                  for(var i=0; i &amp;lt; c.length; i++) {&lt;br /&gt;
&lt;br /&gt;
                    var a = jQuery(c[i]]);&lt;br /&gt;
&lt;br /&gt;
                    if(this.id &amp;lt;/u&amp;gt; a.attr(&#039;for&#039;) &amp;amp;&amp;amp; a.text() == &#039;&#039;) {&lt;br /&gt;
&lt;br /&gt;
                      s.css({ &#039;display&#039; : &#039;none&#039; });&lt;br /&gt;
&lt;br /&gt;
                      a.css({ &#039;display&#039; : &#039;none&#039; });&lt;br /&gt;
&lt;br /&gt;
                      break;&lt;br /&gt;
&lt;br /&gt;
                    }&lt;br /&gt;
&lt;br /&gt;
                  }&lt;br /&gt;
&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
              )&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
          );&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ==Advanced usage==&lt;br /&gt;
&lt;br /&gt;
 If you want to place global Javascript code using the above jQuery(document).ready function then the best place to do this is the template javascript file template.js. You can edit this file using the template editor. Please be aware that placing it in the template javascript file will make the function available to all surveys using that template. If needed just create a new template copy for your survey.&lt;br /&gt;
&lt;br /&gt;
 Alternatively you can place the jQuery(document).ready function in the group description to make a Javascript function only available to a certain question group.&lt;br /&gt;
&lt;br /&gt;
 ==Language-specific Javascript code==&lt;br /&gt;
&lt;br /&gt;
 There is an easy way to find out the current language and execute according Javascript using jQuery: The &amp;lt;html&amp;gt; tag of any survey pages contains an &#039;lang&#039; attribute which holds the current language code. You can read that language code by using the followin code&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 jQuery(document).ready(&lt;br /&gt;
&lt;br /&gt;
    function(){&lt;br /&gt;
&lt;br /&gt;
        languagecode=$(&#039;html&#039;).attr(&#039;lang&#039;);&lt;br /&gt;
&lt;br /&gt;
        alert(&#039;This is the current language code: &#039;+languagecode);&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
 );&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 For an English survey the above code would show a messagebox with &amp;quot;This is the current language code: en&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 =Custom onload function in multi-language survey=&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with: 1.85+ (7253), IE 6/7, FireFox 3.0, Safari 3.2,&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 To use custom onload functions, as above, in multi-language surveys you must define the functions in the question source for &#039;&#039;&#039;all&#039;&#039;&#039; languages.&lt;br /&gt;
&lt;br /&gt;
 While this initially seems to be a bit tedious, it actually can be useful - you can alter your onload functions depending on the language in use. For example, you can dynamically display alerts or element contents in the current language.&lt;br /&gt;
&lt;br /&gt;
 =Skipping the welcome page=&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with: 1.85 (second code snippet)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;Note: As of version 1.91, there is a survey option letting you skip the welcome page, so this workaround is not needed.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Solution 1:&#039;&#039;&#039; Include this Javascript in your welcome template, in the file welcome.pstpl for all welcome page, or in the source of the welcome text for one survey:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 jQuery(document).ready(function($) {&lt;br /&gt;
&lt;br /&gt;
 document.limesurvey.move.value = &#039;movenext&#039;;&lt;br /&gt;
&lt;br /&gt;
 document.limesurvey.submit(); });&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 It will reproduce the onclick event of the submit button and submit the form.&lt;br /&gt;
&lt;br /&gt;
 Drawback of course is that users will see the page flashing up.&lt;br /&gt;
&lt;br /&gt;
 Therefore, you may want to announce &amp;quot;... loading survey ...&amp;quot; as a description of your welcome page (in the admin interface when creating the survey), to pretend loading something big.&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Solution 2:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 function custom_on_load(){&lt;br /&gt;
&lt;br /&gt;
   document.limesurvey.move.value = &#039;movenext&#039;;&lt;br /&gt;
&lt;br /&gt;
   document.limesurvey.submit();&lt;br /&gt;
&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 window.setTimeout( &#039;custom_on_load()&#039;,1);&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 =Filter answers of a question with the answer of another=&lt;br /&gt;
&lt;br /&gt;
 ===Method 1===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with: 1.70 - 1.72&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, this is easier to do using the the array_filter attribute, or relevance equations in general.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 If you want to filter the answer of a question with another answer, you can use this workaround.&lt;br /&gt;
&lt;br /&gt;
 First, use answer code like that: XX for the first question, and XXYYY for the second one.&lt;br /&gt;
&lt;br /&gt;
 Answer of the second question filter if the 2 first letters are the answer of the first question.&lt;br /&gt;
&lt;br /&gt;
 We use 1000X1X1 and 1000X1X2 for the example, question had to be on separate page (question by question for example).The second question had to be a dropdown list (we can do similar workaround, but droplis is the best). You can do this using JQuery.  It leaves the answer in the select box, but disables it.  You could also replace &amp;quot;disable&amp;quot; with &amp;quot;remove&amp;quot; to get rid of it altogether.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 var previousQuestionAnswer = &amp;quot;{INSERTANS:1000X1X1}&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
 var currentQuestionID = &amp;quot;#answer1000X1X1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
    // See if the answer for the previous question matches an answer in the current question&lt;br /&gt;
&lt;br /&gt;
    // (other than &#039;No Answer&#039;)&lt;br /&gt;
&lt;br /&gt;
    // If so, disable it.&lt;br /&gt;
&lt;br /&gt;
    if (previousQuestionAnswer!=&#039;No Answer&#039;) {&lt;br /&gt;
&lt;br /&gt;
        $(currentQuestionID).children().each(function(index, Element)&lt;br /&gt;
&lt;br /&gt;
        {&lt;br /&gt;
&lt;br /&gt;
            if ($(this).attr(&#039;text&#039;) == previousQuestionAnswer)&lt;br /&gt;
&lt;br /&gt;
                { $(this).attr(&#039;disabled&#039;, true); }&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
        );}&lt;br /&gt;
&lt;br /&gt;
 }); // End of JQuery ready function&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ===Method 2===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with 1.92 + Firefox 9.0&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 If you have a country, state, and city set of questions (or similar), you could code answer options as:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Q1 Country&#039;&#039;&#039; &#039;&#039;Single choice list (ratio, dropdown)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 X country#&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Q2 State&#039;&#039;&#039; &#039;&#039;Single choice list (dropdown)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 XY state#&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Q3 City&#039;&#039;&#039; &#039;&#039;Single choice list (dropdown)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 XYZZ city#&lt;br /&gt;
&lt;br /&gt;
 Now you must put the following Javascript code in the source of question 2 (State):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
        // Get the countryCode (first character of the country)&lt;br /&gt;
&lt;br /&gt;
        var countryCode = &#039;{INSERTANS:1000X1X1}&#039;.substr(0, 1).toUpperCase();&lt;br /&gt;
&lt;br /&gt;
        // Loop through all dropdown options and remove those with codes not starting with the countryCode&lt;br /&gt;
&lt;br /&gt;
        $(&#039;select[id&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&amp;quot;answer&amp;quot;] option&#039;).each(function(i){&lt;br /&gt;
&lt;br /&gt;
            if($(this).attr(&#039;value&#039;)  &amp;amp;&amp;amp; $(this).attr(&#039;value&#039;).substr(0, 1).toUpperCase() != countryCode) {&lt;br /&gt;
&lt;br /&gt;
                $(this).remove();&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
        });&lt;br /&gt;
&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 And the following code in the source of question 3 (City):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
        // Get the stateCode (two first characters of the state)&lt;br /&gt;
&lt;br /&gt;
        var stateCode = &#039;{INSERTANS:1000X1X2}&#039;.substr(0, 2).toUpperCase();&lt;br /&gt;
&lt;br /&gt;
        // Loop through all dropdown options and remove those with codes not starting with the stateCode&lt;br /&gt;
&lt;br /&gt;
        $(&#039;select[id&amp;lt;/div&amp;gt;=&amp;quot;answer&amp;quot;] option&#039;).each(function(i){&lt;br /&gt;
&lt;br /&gt;
            if($(this).attr(&#039;value&#039;)  &amp;amp;&amp;amp; $(this).attr(&#039;value&#039;).substr(0, 2).toUpperCase() != stateCode) {&lt;br /&gt;
&lt;br /&gt;
                $(this).remove();&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
        });&lt;br /&gt;
&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 Each question must be in different pages of survey to work, i.e. in a question by question survey, or in diferent groups in a group by group survey.&lt;br /&gt;
&lt;br /&gt;
 Note that if you choose a two characters answer option code in the State question, i.e. a XYY answer option code, you must change the &#039;&#039;substr(0, 2)&#039;&#039; part of code in question 3 to &#039;&#039;substr(0, 3)&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 =Filter answers of a multiple numeric type question=&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with: 1.90+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, this is easier to do using the the array_filter attribute, or relevance equations in general.  In 1.92, array_filter works with all questions that have sub-questions (e.g. also works for multiple numeric and multiple short text).&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 If you want to filter a question of type &amp;quot;multiple numeric&amp;quot;, you have to modify the workaround.&lt;br /&gt;
&lt;br /&gt;
 Note that this workaround assumes that the code for each of the subquestions are a numeric sequence 1,2,3...&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $(document).ready(function(){&lt;br /&gt;
&lt;br /&gt;
    // Match elements with labels using htmlFor and a loop&lt;br /&gt;
&lt;br /&gt;
    var labels = document.getElementsByTagName(&#039;LABEL&#039;);&lt;br /&gt;
&lt;br /&gt;
    for (var i = 0; i &amp;lt; labels.length; i++) {&lt;br /&gt;
&lt;br /&gt;
        if (labels[i].htmlFor != &#039;&#039;) {&lt;br /&gt;
&lt;br /&gt;
             var elem = document.getElementById(labels[i].htmlFor);&lt;br /&gt;
&lt;br /&gt;
             if (elem)&lt;br /&gt;
&lt;br /&gt;
                elem.label = labels[i];&lt;br /&gt;
&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    var answerFilter=&amp;quot;{INSERTANS:96553X63X759}&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
    for (i=0; i&amp;lt;30; i++){&lt;br /&gt;
&lt;br /&gt;
      var iLabel = document.getElementById(&#039;answer96553X63X760&#039;+(i+1]].label.innerHTML;&lt;br /&gt;
&lt;br /&gt;
     if (answerFilter.search(iLabel) == -1){&lt;br /&gt;
&lt;br /&gt;
       // Hide element&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question760&#039;).find(&#039;li&#039;).eq(i).hide();&lt;br /&gt;
&lt;br /&gt;
       // Set value of hidden elements to zero&lt;br /&gt;
&lt;br /&gt;
       document.getElementById(&#039;answer96553X63X760&#039;+(i+1)).value = 0;&lt;br /&gt;
&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
 });&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Use an answer to prefill another question (default value)=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.72&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;And tested with: 1.91+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, this is easier to do using the enhanced defaults feature, which lets you pre-fill most question types with default values.  In 1.91, you could set defaults for list and multiple choice questions.  In 1.92, you can set defaults for any text-entry question too.  Moreover, the defaults can be [[Expression Manager|Expression Manager]] compatible equations or tailored text.  Finally, with 1.92, defaults are properly managed even when set on the same page.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround gives you the ablility to use an answer to fill the default value for another question. It&#039;s explained for free text question type but can be adapted for another question type.&lt;br /&gt;
&lt;br /&gt;
We use SGQA identifier. For example, we use SGQA 1000X10X20 and 1000X10X21 to prefill 1000X11X30 and 1000X11X31. For the script to work, the question has to be on a different page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
 $(&#039;#answer1000X11X30&#039;).val(&#039;{INSERTANS:1000X10X20}&#039;);&lt;br /&gt;
&lt;br /&gt;
 $(&#039;#answer1000X11X31&#039;).val(&#039;{INSERTANS:1000X10X21}&#039;);&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want use two times the value of an integer input, you can also use this to prefill a question that you hide via CSS.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
 $(&#039;#answer1000X2X2&#039;).val(parseInt(&#039;{INSERTANS:1000X1X1}&#039;)*2);&lt;br /&gt;
&lt;br /&gt;
 $(&amp;quot;#question2&amp;quot;).hide();&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you can use {INSERTANS:1000X2X2} for giving you twice the value of the user input from question 1.&lt;br /&gt;
&lt;br /&gt;
=Dynamic Sum=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, this is easier to do with [[Expression Manager|Expression Manager]] using the sum() function.  Not only will sums be dynamic, but they wille exclude irrelevant values, so you can array_filter a multiple numeric question and get the sum of just the answers that are visible.  This [[Expression Manager HowTos|#Calculate assessment values at runtime and store the results in the survey data|HowTo example]] demonstrates the dynamic sum feature.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;Also note, as of version 1.92, the following workaround will fail, since it includes a a regular expression containing curly braces.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This script is used with a &amp;quot;Multiple Options&amp;quot; type question calculate a total price based on how which checkboxes are selected. The prices are listed as part of the answer. The answers are set up like this: &amp;quot;USB Mouse ($20)&amp;quot;. The script uses the number between the &amp;quot;($&amp;quot; and the &amp;quot;)&amp;quot; as the price for that item. You can adapt the script to if you need to change the currency or need to sum something other than money.&lt;br /&gt;
&lt;br /&gt;
This script works when used in a question-by-question format.  It does not work when there are more than one question on a page. I think it can be adapted to work, but I haven&#039;t done the coding yet.&lt;br /&gt;
&lt;br /&gt;
Put the following code into body of your question:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script language=Javascript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// General definitions&lt;br /&gt;
&lt;br /&gt;
// Define a regular expression to match the labels containing information about an answer&lt;br /&gt;
&lt;br /&gt;
// In LimeSurvey, these labels start with &amp;quot;answer...&amp;quot;&lt;br /&gt;
&lt;br /&gt;
var answerRegex = /^answer/;&lt;br /&gt;
&lt;br /&gt;
// Find all answer checkboxes in the document and set their&lt;br /&gt;
&lt;br /&gt;
// onchange events to updatePrice&lt;br /&gt;
&lt;br /&gt;
function Custom_On_Load()&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   // Find all input elements&lt;br /&gt;
&lt;br /&gt;
   var inputList=document.getElementsByTagName(&amp;quot;input&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
   // Loop through each, looking for checkboxes&lt;br /&gt;
&lt;br /&gt;
   var i;&lt;br /&gt;
&lt;br /&gt;
   for( i=0; i&amp;lt; inputList.length;i++ )&lt;br /&gt;
&lt;br /&gt;
   {&lt;br /&gt;
&lt;br /&gt;
       // If input item does not have an ID, skip&lt;br /&gt;
&lt;br /&gt;
       if (! (inputList[i].id)) { continue; }&lt;br /&gt;
&lt;br /&gt;
       // Skip to next if ID doesn&#039;t start with &amp;quot;answer&amp;quot;&lt;br /&gt;
&lt;br /&gt;
       if (!answerRegex.test(inputList[i].id)) { continue; }&lt;br /&gt;
&lt;br /&gt;
       // Skip to next if not a checkbox&lt;br /&gt;
&lt;br /&gt;
       if (inputList[i].type.toUpperCase()!=&#039;CHECKBOX&#039;)  { continue; }&lt;br /&gt;
&lt;br /&gt;
       // This is an answer checkbox!&lt;br /&gt;
&lt;br /&gt;
       // Setup onchange event&lt;br /&gt;
&lt;br /&gt;
       inputList[i].onclick = updatePrice;&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
       // Load initial sum&lt;br /&gt;
&lt;br /&gt;
   updatePrice();&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function updatePrice()&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
var labels=document.getElementsByTagName(&amp;quot;LABEL&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
// Define a regular expression to match a price inside parenthesis&lt;br /&gt;
&lt;br /&gt;
// For example: ($29) or ($29.54).&lt;br /&gt;
&lt;br /&gt;
// Set up&lt;br /&gt;
&lt;br /&gt;
priceRegex = /\(\$(\d*\.{0,1}\d+)\)/;&lt;br /&gt;
&lt;br /&gt;
// Loop through all the labels, looking for labels corresponding to&lt;br /&gt;
&lt;br /&gt;
// answers that have a price in them.&lt;br /&gt;
&lt;br /&gt;
var i;&lt;br /&gt;
&lt;br /&gt;
var total = 0;&lt;br /&gt;
&lt;br /&gt;
for( i=0; i&amp;lt;labels.length;i++ )&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   var myArray;    // Define array used for regex matching&lt;br /&gt;
&lt;br /&gt;
   var inputID;    // Define field element&lt;br /&gt;
&lt;br /&gt;
   // Get the ID of the field corresponding to the label using the&lt;br /&gt;
&lt;br /&gt;
   // &amp;quot;htmlFor&amp;quot; attribute&lt;br /&gt;
&lt;br /&gt;
   // (FYI, there are some labels that will have to be screened out&lt;br /&gt;
&lt;br /&gt;
   // because they don&#039;t correspond to an answer)&lt;br /&gt;
&lt;br /&gt;
   // Does the label start with &amp;quot;answer&amp;quot;?&lt;br /&gt;
&lt;br /&gt;
   // If not: exit.&lt;br /&gt;
&lt;br /&gt;
   if (!answerRegex.test(labels[i].htmlFor)) { continue; }&lt;br /&gt;
&lt;br /&gt;
   // First make sure this element exists&lt;br /&gt;
&lt;br /&gt;
   // If it doesn&#039;t, go to the next element&lt;br /&gt;
&lt;br /&gt;
   // If it does, it will be defined in inputID&lt;br /&gt;
&lt;br /&gt;
   if (! (inputID = document.getElementById(labels[i].htmlFor)) ) { continue; }&lt;br /&gt;
&lt;br /&gt;
   // See if the corresponding answer is a checkbox that is checked.&lt;br /&gt;
&lt;br /&gt;
   // If not, go to next label&lt;br /&gt;
&lt;br /&gt;
   if (inputID.type.toUpperCase()!=&#039;CHECKBOX&#039;)  { continue; }&lt;br /&gt;
&lt;br /&gt;
   if (!inputID.checked) { continue; }&lt;br /&gt;
&lt;br /&gt;
   // This is label for an answer.&lt;br /&gt;
&lt;br /&gt;
   // The innerHTML will give us the text of the label&lt;br /&gt;
&lt;br /&gt;
   // The price information will be in the form ($XX.XX)&lt;br /&gt;
&lt;br /&gt;
   // which in contained in the label text.&lt;br /&gt;
&lt;br /&gt;
   // Find a match for a decimal number inside the pattern &amp;quot;($&amp;quot; and &amp;quot;)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   if [[myArray = priceRegex.exec(labels[i].innerHTML]] != null)&lt;br /&gt;
&lt;br /&gt;
   {&lt;br /&gt;
&lt;br /&gt;
       // Keep a running tally&lt;br /&gt;
&lt;br /&gt;
       total += parseFloat(myArray[1]);&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
  // Update total price on form&lt;br /&gt;
&lt;br /&gt;
  document.getElementById(&amp;quot;totalPrice&amp;quot;).value = &amp;quot;$&amp;quot; + formatCurrency(total);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function formatCurrency(num) {&lt;br /&gt;
&lt;br /&gt;
  num = isNaN(num) || num &amp;lt;u&amp;gt; &#039;&#039; || num &amp;lt;/u&amp;gt; null ? 0.00 : num;&lt;br /&gt;
&lt;br /&gt;
  return parseFloat(num).toFixed(2);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Put the following code in the help section (or wherever you want the sum to appear):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;Total Cost for selected accessories: &amp;lt;input type=&amp;quot;readonly&amp;quot; value=&amp;quot;&amp;quot; id=&amp;quot;totalPrice&amp;quot; /&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Focus on the first Input field=&lt;br /&gt;
&lt;br /&gt;
(&#039;&#039;Tested with: Limesurvey 1.80 / IE6/7, Firefox 3, Safari, Opera, chrome&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.91, there is a built-in JavaScript function called  focusFirst() to focus on the first visible element.  It uses jQuery, so is more robust than this example.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again an onload Function is needed for this tasks. I have done it the DOM way with compatibility to IE6/7.&lt;br /&gt;
&lt;br /&gt;
Put the following code into the startpage.pstpl of your template, right before the &amp;lt;/head&amp;gt; closing tag:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   function focusFirst(Event)&lt;br /&gt;
&lt;br /&gt;
   {&lt;br /&gt;
&lt;br /&gt;
       var i=0;&lt;br /&gt;
&lt;br /&gt;
       while(document.forms[0].elements[i].type == &amp;quot;hidden&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
       {&lt;br /&gt;
&lt;br /&gt;
           i++;&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       document.forms[0].elements[i].focus();&lt;br /&gt;
&lt;br /&gt;
       return;&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   if(ie)&lt;br /&gt;
&lt;br /&gt;
   { window.attachEvent(&amp;quot;onload&amp;quot;, focusFirst); }&lt;br /&gt;
&lt;br /&gt;
   else&lt;br /&gt;
&lt;br /&gt;
   { document.addEventListener(&amp;quot;load&amp;quot;, focusFirst, true); }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; I am using this with version 1.80. As changes happened to the templates in the last release, you might need to add the following before the code, if your template is older than 1.80 stable and does not include this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   var ie = false;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will need this for the var ie to be set. Without this var, the function will not work with ie.&lt;br /&gt;
&lt;br /&gt;
=Answer questions by keypress=&lt;br /&gt;
&lt;br /&gt;
(&#039;&#039;Tested with: IE7, Firefox 3&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
This workaround allow to answer the question on key 0-9 (0 is for the 10 answer).&lt;br /&gt;
&lt;br /&gt;
Follow issues are supported at the moment:&lt;br /&gt;
*Yes-No Questions&lt;br /&gt;
*List Questions (radio)&lt;br /&gt;
*other radio questions&lt;br /&gt;
&lt;br /&gt;
In lists the answer limit is ten.&lt;br /&gt;
&lt;br /&gt;
You supply the template &amp;quot;endpage&amp;quot; of your template with the following script.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
jQuery(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
   jQuery(document).bind(&#039;keypress&#039;, function(e){&lt;br /&gt;
&lt;br /&gt;
       if (48 &amp;lt;= e.which &amp;amp;&amp;amp; e.which &amp;lt;= 57) {&lt;br /&gt;
&lt;br /&gt;
           jQuery(&#039;input:radio&#039;).each(function() {&lt;br /&gt;
&lt;br /&gt;
               var v = jQuery(this).val();&lt;br /&gt;
&lt;br /&gt;
               var c = (e.which &amp;lt;u&amp;gt; 48) ? 10 : e.which - 48;&lt;br /&gt;
&lt;br /&gt;
               if(v &amp;lt;/u&amp;gt; &#039;Y&#039; || v &amp;lt;u&amp;gt; &#039;N&#039;) {&lt;br /&gt;
&lt;br /&gt;
                   v = (v &amp;lt;/u&amp;gt; &#039;Y&#039;) ? 1 : 2;&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               if(v == c) {&lt;br /&gt;
&lt;br /&gt;
                   jQuery(this).click();&lt;br /&gt;
&lt;br /&gt;
                   jQuery(&#039;#limesurvey input:submit&#039;).click();&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   })&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Math notation in LimeSurvey=&lt;br /&gt;
#download the js file from [http://mathcs.chapman.edu/~jipsen/mathml/asciimathdownload.html AsciiMath script]&lt;br /&gt;
#copy it in the /scripts/ folder in your installation&lt;br /&gt;
#modify the startpage.psptl of the template you want to use adding the reference to the script (if you use an older version make sure that you copy the template folder first!) for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;ASCIIMathML.js&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the notation where you need it!&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; If you use internet explorer or safari you will need to download the plugin as well, but firefox does the lot for you.&lt;br /&gt;
&lt;br /&gt;
Finally, if you are confident with the limesurvey structure you could add the editor which support math notation and change the reference to the editor you want to use in the configuration file. here is the [http://www.imathas.com/editordemo/demo.html link for a TinyMCE with math support].&lt;br /&gt;
&lt;br /&gt;
=Reverse array_filter (for pre-1.90)=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.85+ (7253), IE 6/7, FireFox 3.0, Safari 3.2, Chrome 2.0&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;Note: Version 1.91 natively supports this functionality via the array_filter_exclude advanced quation option.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This can be used to filter the answers of an array question to be displayed based on the answers of a multi option question that were &#039;&#039;&#039;NOT&#039;&#039;&#039; selected. A possible application would be to have a multi-option question asking which products were purchased, followed by 2 array questions - one asking to rate the purchased products and another asking why the remaining products were not purchased. Another would be to ask about sessions attended at a conference as in [http://www.limesurvey.org/en/support/forums/5-can-i-do-this-with-limesurvey/27970-reverse-of-arrayfilter.html this forum thread] and pictured below. There is a live [http://www.partnersinc.biz/surveys//index.php?sid=43358&amp;amp;newtest;=Y&amp;amp;lang;=en demo here]&lt;br /&gt;
&lt;br /&gt;
[[File:sessions_645x344.gif]]&lt;br /&gt;
&lt;br /&gt;
We&#039;ll use the above example to explain the process as follows:&lt;br /&gt;
#In group 1 - Create a &#039;&#039;SessionsAttended&#039;&#039; multi-options question&lt;br /&gt;
#In group 1 - Create a &#039;&#039;SessionsNotAttended&#039;&#039; multi-options question with identical answers as &#039;&#039;SessionsAttended&#039;&#039; and hide it with styles or conditions&lt;br /&gt;
#In group 2 - Create a &#039;&#039;RateSessionsAttended&#039;&#039; array question with an [http://docs.limesurvey.org/tiki-index.php?page=Question+attributes&amp;amp;structure;=English+Instructions+for+LimeSurvey#array_filter array_filter] based on &#039;&#039;SessionsAttended&#039;&#039;&lt;br /&gt;
#In group 2 - Create a &#039;&#039;ReasonNotAttended&#039;&#039; array question with an [http://docs.limesurvey.org/tiki-index.php?page=Question+attributes&amp;amp;structure;=English+Instructions+for+LimeSurvey#array_filter array_filter] based on &#039;&#039;SessionsNotAttended&#039;&#039;&lt;br /&gt;
#In group 1 - Place JavaScript/jQeury listeners on each of the checkboxes in &#039;&#039;SessionsAttended&#039;&#039; that would toggle the corresponding checkbox in &#039;&#039;SessionsNotAttended&#039;&#039; to the opposite state&lt;br /&gt;
&lt;br /&gt;
The JavaScript/jQuery code used would be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
       // The toggle function&lt;br /&gt;
&lt;br /&gt;
   function toggle(q1, q2) {&lt;br /&gt;
&lt;br /&gt;
       if ($(q1).attr(&#039;checked&#039;) == false ) {&lt;br /&gt;
&lt;br /&gt;
           $(q2).attr(&#039;checked&#039;, true);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       else {&lt;br /&gt;
&lt;br /&gt;
           $(q2).attr(&#039;checked&#039;, false);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   // Initialize the SessionNotAttended checkboxes to &amp;quot;checked&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   toggle (&#039;#answer11111X22X331&#039;, &#039;#answer11111X22X441&#039;);&lt;br /&gt;
&lt;br /&gt;
   toggle (&#039;#answer11111X22X332&#039;, &#039;#answer11111X22X442&#039;);&lt;br /&gt;
&lt;br /&gt;
   toggle (&#039;#answer11111X22X333&#039;, &#039;#answer11111X22X443&#039;);&lt;br /&gt;
&lt;br /&gt;
   toggle (&#039;#answer11111X22X334&#039;, &#039;#answer11111X22X444&#039;);&lt;br /&gt;
&lt;br /&gt;
   // The jQuery listeners on the SessionAttended checkboxes&lt;br /&gt;
&lt;br /&gt;
   // that toggle the SessionNotAttended checkboxes&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#answer11111X22X331&#039;).change(function() {&lt;br /&gt;
&lt;br /&gt;
       toggle (&#039;#answer11111X22X331&#039;, &#039;#answer11111X22X441&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#answer11111X22X332&#039;).change(function() {&lt;br /&gt;
&lt;br /&gt;
       toggle (&#039;#answer11111X22X332&#039;, &#039;#answer11111X22X442&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#answer11111X22X333&#039;).change(function() {&lt;br /&gt;
&lt;br /&gt;
       toggle (&#039;#answer11111X22X333&#039;, &#039;#answer11111X22X443&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#answer11111X22X334&#039;).change(function() {&lt;br /&gt;
&lt;br /&gt;
       toggle (&#039;#answer11111X22X334&#039;, &#039;#answer11111X22X444&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some notes about the code:&lt;br /&gt;
*The code is in an onload function defined in the first question of group 1 - see [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#Custom_onload_function workarounds here]&lt;br /&gt;
*Both &#039;&#039;SessionsAttended&#039;&#039; and &#039;&#039;SessionsNotAttended&#039;&#039; must be in the same group for the toggling to work&lt;br /&gt;
*This case only uses 4 checkboxes but could be expanded as required&lt;br /&gt;
*In this case the survey ID is 11111, the group ID is 22, &#039;&#039;SessionsAttended&#039;&#039; ID is 33 and SessionsNotAttended ID is 44 - these would need to be modified for your survey&lt;br /&gt;
*The toggle function looks for the state of a checkbox in &#039;&#039;SessionsAttended&#039;&#039; and sets the corresponding checkbox in &#039;&#039;SessionsNotAttended&#039;&#039; to the opposite state&lt;br /&gt;
*The &amp;quot;Initialize&amp;quot; section sets the state of &#039;&#039;SessionsNotAttended&#039;&#039; checkboxes whenever we navigate to the group&lt;br /&gt;
*The &amp;quot;Listener&amp;quot; section uses jQuery listeners to detect any change in the &#039;&#039;SessionsAttended&#039;&#039; checkboxes and then toggle the corresponding &#039;&#039;SessionsNotAttended&#039;&#039; checkbox&lt;br /&gt;
&lt;br /&gt;
Some general notes about the questions:&lt;br /&gt;
*CSS can be used to hide &#039;&#039;SessionsNotAttended&#039;&#039; (div#question44 { display: none; }) if you don&#039;t want to use conditions (because maybe you&#039;ve got [http://docs.limesurvey.org/tiki-index.php?page=Optional+settings&amp;amp;structure;=English+Instructions+for+LimeSurvey#Survey_Behavior $deletenonvalues set to 1])&lt;br /&gt;
*&#039;&#039;RateSessionsAttended&#039;&#039; and &#039;&#039;ReasonNotAttended&#039;&#039; are another group to avoid things popping in and out of existence as &#039;&#039;SessionsAttended&#039;&#039; is answered&lt;br /&gt;
*[http://docs.limesurvey.org/tiki-index.php?page=Setting+conditions&amp;amp;structure;=English+Instructions+for+LimeSurvey Conditions] are used to ensure that &#039;&#039;RateSessionsAttended&#039;&#039; only appears if some sessions are selected and &#039;&#039;ReasonNotAttended&#039;&#039; only appears if no sessions are selected&lt;br /&gt;
&lt;br /&gt;
=Filter Ranking Question With Multiple-Options=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90, IE 7/8, FireFox 3/4, Safari 5.0, Chrome 10.0&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, most of this is easier to do using the the array_filter attribute, or relevance equations in general.  They all work on the same page, and fully support cascading relevance.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround applies a filter to a ranking question based on the checked boxes of a previous multiple-options question. There are two methods - one for filter and ranking questions being on the same page and a slightly different one for the filter question being on a page before the ranking question.&lt;br /&gt;
&lt;br /&gt;
There is a [http://www.partnersinc.biz/surveys//index.php?sid=96314&amp;amp;newtest;=Y&amp;amp;lang;=en demo of both methods here].&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FOR BOTH METHODS:&#039;&#039;&#039;&lt;br /&gt;
*[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_ Set up your survey to use JavaScript].&lt;br /&gt;
*Place the following script in your template.js file. This function will be accessed by either method.&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// A function to filter choices in a ranking question&lt;br /&gt;
&lt;br /&gt;
function rankFilter(q1ID, q2ID, prevPage) {&lt;br /&gt;
&lt;br /&gt;
   // If filter question is on a previous page, hide Q1 and check all &amp;quot;visible&amp;quot; boxes&lt;br /&gt;
&lt;br /&gt;
   if(prevPage == 1) {&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q1ID+&#039; li[id&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&amp;quot;javatbd&amp;quot;]:visible input.checkbox&#039;).attr(&#039;checked&#039;, true);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q1ID+&#039;&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   handleChecked(q1ID, q2ID);&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#question&#039;+q1ID+&#039; input.checkbox&#039;).click(function() {&lt;br /&gt;
&lt;br /&gt;
       handleChecked(q1ID, q2ID);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   function handleChecked(q1ID, q2ID) {&lt;br /&gt;
&lt;br /&gt;
       // Find the survey and group IDs&lt;br /&gt;
&lt;br /&gt;
       if($( &#039;input#fieldnames&#039; ).length != 0) {&lt;br /&gt;
&lt;br /&gt;
           var fieldNames = $( &#039;input#fieldnames&#039; ).attr(&#039;value&#039;);&lt;br /&gt;
&lt;br /&gt;
           var tmp = fieldNames.split(&#039;X&#039;);&lt;br /&gt;
&lt;br /&gt;
           var sID = tmp[0];&lt;br /&gt;
&lt;br /&gt;
           var gID = tmp[1];&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       // Loop through all Q1 options&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q1ID+&#039; input.checkbox&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
           // Find the answer code and value&lt;br /&gt;
&lt;br /&gt;
           var tmp2 = $(this).attr(&#039;id&#039;).split(&#039;X&#039;+gID+&#039;X&#039;+q1ID+&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
           var ansCode = tmp2[1];&lt;br /&gt;
&lt;br /&gt;
           var ansTxt = $(this).next(&#039;label&#039;).text();&lt;br /&gt;
&lt;br /&gt;
           // If option is checked and not in rank choices or output, add it to the rank choices&lt;br /&gt;
&lt;br /&gt;
           if($(this).attr(&#039;checked&#039;) == true&lt;br /&gt;
&lt;br /&gt;
                          &amp;amp;&amp;amp; $(&#039;#question&#039;+q2ID+&#039; select.select option[value=&amp;quot;&#039;+ansCode+&#039;&amp;quot;]&#039;).length == 0&lt;br /&gt;
&lt;br /&gt;
                          &amp;amp;&amp;amp; $(&#039;#question&#039;+q2ID+&#039; .output input[id&amp;lt;/div&amp;gt;=&amp;quot;fvalue_&amp;quot;][value=&amp;quot;&#039;+ansCode+&#039;&amp;quot;]&#039;).length == 0) {&lt;br /&gt;
&lt;br /&gt;
               $(&#039;&amp;lt;option value=&amp;quot;&#039;+ansCode+&#039;&amp;quot;&amp;gt;&#039;+ansTxt+&#039;&amp;lt;/option&amp;gt;&#039;).appendTo(&#039;#question&#039;+q2ID+&#039; select.select&#039;);&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
           // If option is unchecked...&lt;br /&gt;
&lt;br /&gt;
           else if($(this).attr(&#039;checked&#039;) == false) {&lt;br /&gt;
&lt;br /&gt;
               // Remove it from the rank choices&lt;br /&gt;
&lt;br /&gt;
               $(&#039;#question&#039;+q2ID+&#039; select.select option[value=&amp;quot;&#039;+ansCode+&#039;&amp;quot;]&#039;).remove();&lt;br /&gt;
&lt;br /&gt;
               // Remove it from the rank output and reset hidden values&lt;br /&gt;
&lt;br /&gt;
$(&#039;#question&#039;+q2ID+&#039; .output input[id&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&amp;quot;fvalue_&amp;quot;][value=&amp;quot;&#039;+ansCode+&#039;&amp;quot;]&#039;).attr(&#039;value&#039;, &#039;&#039;).siblings(&#039;input.text&#039;).val(&#039;&#039;).siblings(&#039;img&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // Clean up empty inputs in the rank output table&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q2ID+&#039; .output table tr&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
           var nextRow = $(this).next(&#039;tr&#039;);&lt;br /&gt;
&lt;br /&gt;
           if($(&#039;input.text&#039;, this).val() == &#039;&#039; &amp;amp;&amp;amp; $(&#039;input.text&#039;, nextRow).val() != &#039;&#039;) {&lt;br /&gt;
&lt;br /&gt;
               $(&#039;input.text&#039;, this).val($(&#039;input.text&#039;, nextRow).val());&lt;br /&gt;
&lt;br /&gt;
               $(&#039;input.text&#039;, nextRow).val(&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
               $(&#039;input[id&amp;lt;/div&amp;gt;=&amp;quot;fvalue_&amp;quot;]&#039;, this).attr(&#039;value&#039;, $(&#039;input[id&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&amp;quot;fvalue_&amp;quot;]&#039;, nextRow).attr(&#039;value&#039;));&lt;br /&gt;
&lt;br /&gt;
               $(&#039;input[id&amp;lt;/div&amp;gt;=&amp;quot;fvalue_&amp;quot;]&#039;, nextRow).attr(&#039;value&#039;, &#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // Show the scissors for the last populated rank output row&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q2ID+&#039; .output table img[id&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&amp;quot;cut_&amp;quot;]&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q2ID+&#039; .output table input.text[value!=&amp;quot;&amp;quot;]:last&#039;).siblings(&#039;img[id&amp;lt;/div&amp;gt;=&amp;quot;cut_&amp;quot;]&#039;).show();&lt;br /&gt;
&lt;br /&gt;
       // Hide extra rank output rows&lt;br /&gt;
&lt;br /&gt;
       var optNum = $(&#039;#question&#039;+q1ID+&#039; input.checkbox:checked&#039;).length;&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q2ID+&#039; .output table tr&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q2ID+&#039; .output table tr:lt(&#039;+(optNum+1)+&#039;)&#039;).show();&lt;br /&gt;
&lt;br /&gt;
       // Hide and clear the ranking question if there are less than 2 checked options in Q1&lt;br /&gt;
&lt;br /&gt;
       if(optNum &amp;lt; 2) {&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+q2ID+&#039;&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+q2ID+&#039; input.text&#039;).val(&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+q2ID+&#039; input[id&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&amp;quot;fvalue_&amp;quot;]&#039;).attr(&#039;value&#039;, &#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       else {&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+q2ID+&#039;&#039;).show();&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       // A work around for the built in max-answers function&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q2ID+&#039; select.select&#039;).attr(&#039;disabled&#039;, true);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q2ID+&#039; td.output tr:visible&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
           if($(&#039;input.text&#039;, this).val() == &#039;&#039;) {&lt;br /&gt;
&lt;br /&gt;
               $(&#039;#question&#039;+q2ID+&#039; select.select&#039;).attr(&#039;disabled&#039;, false);&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   // A listener to work around the built in max-answers function&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#question&#039;+q2ID+&#039; td.rank&#039;).click(function (event) {&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q2ID+&#039; select.select&#039;).attr(&#039;disabled&#039;, true);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q2ID+&#039; td.item input.text&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
           if ($(this).val() == &#039;&#039;) {&lt;br /&gt;
&lt;br /&gt;
               $(&#039;#question&#039;+q2ID+&#039; select.select&#039;).attr(&#039;disabled&#039;, false);&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FOR BOTH FILTER AND RANKING QUESTIONS ON SAME PAGE:&#039;&#039;&#039;&lt;br /&gt;
*Create a multiple options question and a ranking question on the same page (in the same group).&lt;br /&gt;
*Both questions &#039;&#039;&#039;MUST&#039;&#039;&#039; have identical sub-questions and sub-question codes.&lt;br /&gt;
*Place the following script in the source of one of the questions.&lt;br /&gt;
*Replace &amp;quot;MM&amp;quot; with the ID of the multiple options question and &amp;quot;RR&amp;quot; with the ID of the ranking question.&lt;br /&gt;
*The function will hide the ranking question unless at least two options are selected in the multiple options question, in which case, it will only show the options selected.&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       rankFilter(MM, RR);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FOR FILTER AND RANKING QUESTIONS ON SEPARATE PAGES:&#039;&#039;&#039;&lt;br /&gt;
*Create a multiple options question on page 1.&lt;br /&gt;
*Create a multiple options question and a ranking question on page 2.&lt;br /&gt;
*All three questions &#039;&#039;&#039;MUST&#039;&#039;&#039; have identical sub-questions and sub-question codes.&lt;br /&gt;
*Set the multiple options on page 2 to be filtered by the multiple options on page 1.&lt;br /&gt;
*Place the following script in the source of one of the questions on page 2.&lt;br /&gt;
*Replace &amp;quot;MM&amp;quot; with the ID of the multiple options question and &amp;quot;RR&amp;quot; with the ID of the ranking question. Do not modify the &amp;quot;1&amp;quot;.&lt;br /&gt;
*The function will hide the multiple options question. If at least 2 options were selected in the multiple options on page 1, the corresponding options will be checked in the hidden multiple options question which will then be used to control the display of the ranking question.&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       rankFilter(MM, RR, 1);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Filter &amp;quot;Array by Column&amp;quot; Question With &amp;quot;Multiple-Options&amp;quot;=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.91, IE 7/8, FireFox 3/4, Safari 5.0, Chrome 10.0&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround applies a filter to an &amp;quot;Array by Column&amp;quot; question based on the checked boxes of a previous multiple-options question. There are two methods - one for filter and array questions being on the same page and a slightly different one for the filter question being on a page before the array question.&lt;br /&gt;
&lt;br /&gt;
There is a [http://www.partnersinc.biz/surveys//index.php?sid=74213&amp;amp;newtest;=Y&amp;amp;lang;=en demo of both methods here].&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FOR BOTH METHODS:&#039;&#039;&#039;&lt;br /&gt;
*[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_ Set up your survey to use JavaScript].&lt;br /&gt;
*Place the following scripts in your template.js file. These functions will be accessed by either method.&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
   function filterArrByCol(qMultiOpt, qArray, prevPage) {&lt;br /&gt;
&lt;br /&gt;
       // If filter question is on a previous page, hide Q1 and check all &amp;quot;visible&amp;quot; boxes&lt;br /&gt;
&lt;br /&gt;
       if(prevPage == 1) {&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qMultiOpt+&#039; li[id&amp;lt;/div&amp;gt;=&amp;quot;javatbd&amp;quot;]:visible input.checkbox&#039;).attr(&#039;checked&#039;, true);&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qMultiOpt+&#039;&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       // Assign classes to the answer cells&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+qArray+&#039; table.question tbody td&#039;).each(function(i){&lt;br /&gt;
&lt;br /&gt;
           var classArr = $(this).attr(&#039;class&#039;).split(&#039;answer_cell_00&#039;);&lt;br /&gt;
&lt;br /&gt;
           var ansCode = classArr[1];&lt;br /&gt;
&lt;br /&gt;
           $(this).addClass(&#039;ans-&#039;+ansCode+&#039; filtered&#039;);&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // Assign classes to the answer label cells&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+qArray+&#039; table.question tbody tr:eq(0) td&#039;).each(function(i){&lt;br /&gt;
&lt;br /&gt;
           var classArr2 = $(this).attr(&#039;class&#039;).split(&#039; ans-&#039;);&lt;br /&gt;
&lt;br /&gt;
           var ansCode2 = classArr2[1];&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qArray+&#039; table.question thead tr:eq(0) th:eq(&#039;+i+&#039;)&#039;).addClass(&#039;ans-&#039;+ansCode2+&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // Fire the filter function on page load&lt;br /&gt;
&lt;br /&gt;
       filterArr(qMultiOpt, qArray);&lt;br /&gt;
&lt;br /&gt;
       // Listener on multi-opt checkboxes to fire the filter function&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+qMultiOpt+&#039; input.checkbox&#039;).click(function(){&lt;br /&gt;
&lt;br /&gt;
           filterArr(qMultiOpt, qArray);&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // On submit, clear all hidden radios of array&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#movenextbtn, #movesubmitbtn&#039;).click(function(){&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qArray+&#039; td.filtered:hidden&#039;).each(function(i){&lt;br /&gt;
&lt;br /&gt;
               $(&#039;input.radio&#039;, this).attr(&#039;checked&#039;, false);&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           return true;&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   function filterArr(qMultiOpt, qArray) {&lt;br /&gt;
&lt;br /&gt;
       if($(&#039;#question&#039;+qMultiOpt+&#039; input.checkbox:checked&#039;).length &amp;lt; 1) {&lt;br /&gt;
&lt;br /&gt;
           // Hide the array if no multi-opt options are checked&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qArray+&#039;&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       else {&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qArray+&#039;&#039;).show();&lt;br /&gt;
&lt;br /&gt;
           // Hide all columns of array&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qArray+&#039; table.question tbody td, #question&#039;+qArray+&#039; table.question thead th&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
           // Loop through multi-opt checkboxes and, if checked, show corresponding column of array&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qMultiOpt+&#039; input.checkbox&#039;).each(function(i){&lt;br /&gt;
&lt;br /&gt;
               if($(this).attr(&#039;checked&#039;) == true) {&lt;br /&gt;
&lt;br /&gt;
                   var classArr3 = $(this).attr(&#039;id&#039;).split(&#039;X&#039;+qMultiOpt);&lt;br /&gt;
&lt;br /&gt;
                   var ansCode3 = classArr3[1];&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;#question&#039;+qArray+&#039; .ans-&#039;+ansCode3+&#039;&#039;).show();&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FOR BOTH FILTER AND ARRAY QUESTIONS ON SAME PAGE:&#039;&#039;&#039;&lt;br /&gt;
*Create a multiple options question and an array-by-column question on the same page (in the same group).&lt;br /&gt;
*Both questions &#039;&#039;&#039;MUST&#039;&#039;&#039; have identical sub-questions and sub-question codes.&lt;br /&gt;
*Place the following script in the source of one of the questions.&lt;br /&gt;
*Replace &amp;quot;MM&amp;quot; with the ID of the multiple options question and &amp;quot;AA&amp;quot; with the ID of the ranking question.&lt;br /&gt;
*The function will hide the array question unless at least one option is selected in the multiple-options question, in which case, it will only show the corresponding array column(s).&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       filterArrByCol(MM, AA);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FOR FILTER AND ARRAY QUESTIONS ON SEPARATE PAGES:&#039;&#039;&#039;&lt;br /&gt;
*Create a multiple options question on page 1.&lt;br /&gt;
*Create a multiple options question and an array-by-column question on page 2.&lt;br /&gt;
*All three questions &#039;&#039;&#039;MUST&#039;&#039;&#039; have identical sub-questions and sub-question codes.&lt;br /&gt;
*Set the multiple options on page 2 to be filtered by the multiple options on page 1.&lt;br /&gt;
*Place the following script in the source of one of the questions on page 2.&lt;br /&gt;
*Replace &amp;quot;MM&amp;quot; with the ID of the multiple options question and &amp;quot;AA&amp;quot; with the ID of the array question. Do not modify the &amp;quot;1&amp;quot;.&lt;br /&gt;
*The function will hide the multiple options question. If options were selected in the multiple options on page 1, the corresponding options will be checked in the hidden multiple options question which will then be used to control the display of the array columns.&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       filterArrByCol(MM, AA, 1);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Auto-tabbing between text input fields=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 6/7, FireFox 3.0, Safari 3.2, Chrome 2.0&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This is a workaround to facilitate auto-tabbing between text input questions in a single group using a [http://plugins.jquery.com/project/autotab jQuery plugin by Mathachew] and the Maximum characters attribute of questions.&lt;br /&gt;
&lt;br /&gt;
The behaviour will be: When the maximum number of characters has been entered into an input field, the focus (cursor) will be automatically moved to the next input field. When the backspace key is used to remove all characters from a field, the focus will be moved to the previous field. It&#039;s very useful in surveys having many text input questions to avoid having to manually tab or click between fields.&lt;br /&gt;
&lt;br /&gt;
You can view a small demo survey [http://www.partnersinc.biz/surveys//index.php?sid=11327&amp;amp;newtest;=Y&amp;amp;lang;=en here].&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#Visit [http://plugins.jquery.com/node/4046 http://plugins.jquery.com/node/4046], download the plugin script and save it as &#039;&#039;jquery.autotab-1.1b.js&#039;&#039; in the template folder.&lt;br /&gt;
#Link to the script by placing &#039;&#039;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;{TEMPLATEURL}jquery.autotab-1.1b.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&#039;&#039; within the &#039;&#039;&amp;lt;head&amp;gt;&#039;&#039; tag of startpage.pstpl.&lt;br /&gt;
#[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_ Set up your survey to use JavaScript].&lt;br /&gt;
#Create the text based questions that auto-tabbing is to be applied to. (All must be in the same group if you&#039;re using group by group presentation)&lt;br /&gt;
#Define a Maximum characters attribute for all questions that the autotab is applied to. (See [http://docs.limesurvey.org/tiki-index.php?page=Question+attributes&amp;amp;structure;=English+Instructions+for+LimeSurvey#maximum_chars documentation here])&lt;br /&gt;
#In the source of the first question of the group that contains the auto-tabbed questions, add the following code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#answerSSSSSXGGXAA&#039;).focus(); //initially focus on the first input&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#answerSSSSSXGGXAA&#039;).autotab({ target: &#039;answerSSSSSXGGXBB&#039; });&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#answerSSSSSXGGXBB&#039;).autotab({ previous: &#039;answerSSSSSXGGXAA&#039;, target: &#039;answerSSSSSXGGXCC&#039; });&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#answerSSSSSXGGXCC&#039;).autotab({ previous: &#039;answerSSSSSXGGXBB&#039;, target: &#039;answerSSSSSXGGXDD&#039; });&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#answerSSSSSXGGXDD&#039;).autotab({ previous: &#039;answerSSSSSXGGXCC&#039; });&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example has 4 fields to be auto-tabbed between - all instances of the following must be replaced to be compatible with your survey (See image below):&lt;br /&gt;
*SSSSS -&amp;gt; Survey ID&lt;br /&gt;
*GG -&amp;gt; Group ID&lt;br /&gt;
*AA -&amp;gt; First question&lt;br /&gt;
*BB -&amp;gt; Second question&lt;br /&gt;
*CC -&amp;gt; Third question&lt;br /&gt;
*DD -&amp;gt; Last question&lt;br /&gt;
&lt;br /&gt;
[[File:ids_343x252.gif]]&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;target&#039;&#039; parameter defines where the next input is and the &#039;&#039;previous&#039;&#039; parameter defines (you guessed it) the previous input.&lt;br /&gt;
&lt;br /&gt;
This plugin also has limited capability of formatting the input text - see comments in the plugin script.&lt;br /&gt;
&lt;br /&gt;
=Custom response listeners=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.85+ (7253), IE 6/7, FireFox 3.0, Safari 3.2, Chrome 2.0&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Listeners can be used to perform functions when a change in an input is detected. There are many uses such as the [http://docs.limesurvey.org/tiki-index.php?page=Workarounds#Reverse_array_filter Reverse array_filter] but a simple one would be to warn a respondent if they enter a value that may be too high.&lt;br /&gt;
&lt;br /&gt;
We can use the [http://docs.jquery.com/Events/change jQuery change( ) event] to fire a function whenever there is a change to the input. The function will look for an input value higher than 10 and, if found, will warn the respondent.&lt;br /&gt;
#[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_ Set up your survey to use JavaScript].&lt;br /&gt;
#Place the script below in the source of one of the questions on the page where:&lt;br /&gt;
**11111 is the survey ID&lt;br /&gt;
**22 is the group ID&lt;br /&gt;
**33 is the question ID&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#answer11111X22X33&#039;).change(function() {&lt;br /&gt;
&lt;br /&gt;
           if ( $(&#039;#answer11111X22X33&#039;).val() &amp;gt; 10 ) {&lt;br /&gt;
&lt;br /&gt;
               alert (&amp;quot;That&#039;s an awful lot. Are you sure?&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Text input masks=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 7, FireFox 3.0, Safari 3.2, Chrome 2.0&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;We&#039;re considering adding this as a built-in feature for version 1.92 (e.g. an advanced question attribute).&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There may be instances where you would like to place a mask on a text input - for example only allowing respondents to enter the correct characters for a North American phone number [[Expression Manager|Expression Manager]] rand() function.  This can be part of a relevance equation to randomly control which questions are shown; or you can create an Equation question type to store the random value, and let that question be part of downstream relevance equations.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround allows you to generate a random number and then populate a hidden question with that number. You can then use this question to control the display of subsequent questions with [http://docs.limesurvey.org/tiki-index.php?page=Setting+conditions&amp;amp;structure;=English+Instructions+for+LimeSurvey Conditions]. It&#039;s useful if you have several sets of questions that you would like to randomly present to participants - see this  [http://www.limesurvey.org/en/support/forums/5-can-i-do-this-with-limesurvey/29579-experiment-with-random-questions.html forum post].&lt;br /&gt;
&lt;br /&gt;
There is a small demo [http://www.partnersinc.biz/surveys//index.php?sid=12659&amp;amp;newtest;=Y&amp;amp;lang;=en here].&lt;br /&gt;
&lt;br /&gt;
In the demo, in the first group, we generate a random number between 1 and 4 and populate a hidden question with it. Then in the second group we have 4 questions, each showing conditional on the answer of the first question.&lt;br /&gt;
&lt;br /&gt;
Implementation for this demo is as follows:&lt;br /&gt;
#Turn off &#039;&#039;$filterxsshtml&#039;&#039; to allow insertion of JavaScript in the questions. (See [http://docs.limesurvey.org/tiki-index.php?page=Optional+settings&amp;amp;structure;=English+Instructions+for+LimeSurvey#Filtering_dangerous_HTML_tags_in_survey_objects documentation here])&lt;br /&gt;
#Set up the template to use custom onload functions. (See the [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#Custom_onload_function workaround here])&lt;br /&gt;
#In the first group add a &amp;quot;Short free text&amp;quot; question (We&#039;re going to hide this with JavaScript)&lt;br /&gt;
#In the source of that question add the following onload function. (See [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._ How to use script here])&lt;br /&gt;
#In the following groups add the questions that are conditional on the answer of the first question.&lt;br /&gt;
&lt;br /&gt;
Onload code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
function Custom_On_Load(){&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Find a random number between 1 and 4&lt;br /&gt;
&lt;br /&gt;
       var randNumber = Math.floor(Math.random()*4 + 1);&lt;br /&gt;
&lt;br /&gt;
       // Populate and hide the hidden question&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input#answerSSSSSXGGXQQ&#039;).val(randNumber);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#questionQQ&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
       /***********************************************************/&lt;br /&gt;
&lt;br /&gt;
       // This just tells the user which number has been selected&lt;br /&gt;
&lt;br /&gt;
       // You can remove this from your onload function&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input#setNumber&#039;).val(randNumber);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input#setNumber&#039;).css({&lt;br /&gt;
&lt;br /&gt;
           &#039;margin-left&#039;:&#039;0.5em&#039;,&lt;br /&gt;
&lt;br /&gt;
           &#039;width&#039;:&#039;1.5em&#039;,&lt;br /&gt;
&lt;br /&gt;
           &#039;text-align&#039;:&#039;center&#039;,&lt;br /&gt;
&lt;br /&gt;
           &#039;font-weight&#039;:&#039;bold&#039;&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input#setNumber&#039;).attr(&#039;disabled&#039;, true);&lt;br /&gt;
&lt;br /&gt;
       /***********************************************************/&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &#039;&#039;&#039;SSSSS&#039;&#039;&#039; is the survey ID, &#039;&#039;&#039;GG&#039;&#039;&#039; is the group ID and &#039;&#039;&#039;QQ&#039;&#039;&#039; is the hidden question ID.&lt;br /&gt;
&lt;br /&gt;
Increase or decrease the maximum value of the random number by modifying the first section. For example to get a number between 1 and 10 you would use this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
var randNumber = Math.floor(Math.random()*10 + 1);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The third section of code just populates a placeholder element that I use to tell the participant what&#039;s going on. You can remove it from your code.&lt;br /&gt;
&lt;br /&gt;
=Minimum number of required answers in an array=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 6/7, FireFox 3.0, Safari 3.2,&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92 all array style questions have the min_answers and max_answers options, so this script is obsolete.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround allows you to specify a &#039;&#039;&#039;minimum number&#039;&#039;&#039; of answers required in an array question. It is an alternative to the &amp;quot;Mandatory&amp;quot; parameter which specifies that &#039;&#039;&#039;all&#039;&#039;&#039; answers are required. It could also be easily modified to specify a maximum number of answers.&lt;br /&gt;
&lt;br /&gt;
We accomplish this by placing an onload function in the source of the array question. This function hides the Next/Submit button and displays a warning element until it detects a minimum number of responses. It then hides the warning and shows the Next/Submit button.&lt;br /&gt;
&lt;br /&gt;
There is a demo [http://www.partnersinc.biz/surveys//index.php?sid=97166&amp;amp;newtest;=Y&amp;amp;lang;=en here].&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#Turn off &#039;&#039;$filterxsshtml&#039;&#039; to allow insertion of JavaScript in the questions. (See [http://docs.limesurvey.org/tiki-index.php?page=Optional+settings&amp;amp;structure;=English+Instructions+for+LimeSurvey#Filtering_dangerous_HTML_tags_in_survey_objects documentation here])&lt;br /&gt;
#Set up the template to use custom onload functions. (See the [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#Custom_onload_function workaround here])&lt;br /&gt;
#In the source of the array question add the following onload function. (See [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._ How to use script here])&lt;br /&gt;
#Modify the &#039;&#039;SETTINGS&#039;&#039; section of the code as required.&lt;br /&gt;
&lt;br /&gt;
Onload code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Wait until the document is fully loaded&lt;br /&gt;
&lt;br /&gt;
$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
   /********************** SETTINGS **********************/&lt;br /&gt;
&lt;br /&gt;
   // The text to appear in the warning element&lt;br /&gt;
&lt;br /&gt;
   var warningText = &#039;Please answer at least 4 to continue&#039;;&lt;br /&gt;
&lt;br /&gt;
   // The question ID&lt;br /&gt;
&lt;br /&gt;
   var questionId = 137;&lt;br /&gt;
&lt;br /&gt;
   // The minimum number of answers required&lt;br /&gt;
&lt;br /&gt;
   var minNumber = 4;&lt;br /&gt;
&lt;br /&gt;
   /******************************************************/&lt;br /&gt;
&lt;br /&gt;
   // Create the warning element and place it after the submit button&lt;br /&gt;
&lt;br /&gt;
   var el = document.createElement(&#039;div&#039;);&lt;br /&gt;
&lt;br /&gt;
   el.setAttribute(&#039;id&#039;,&#039;warning&#039;);&lt;br /&gt;
&lt;br /&gt;
   document.body.appendChild(el);&lt;br /&gt;
&lt;br /&gt;
   $( &#039;#warning&#039; ).css({&lt;br /&gt;
&lt;br /&gt;
       &#039;border&#039;:&#039;1px solid #333333&#039;,&lt;br /&gt;
&lt;br /&gt;
       &#039;width&#039;:&#039;200px&#039;,&lt;br /&gt;
&lt;br /&gt;
       &#039;padding&#039;:&#039;3px&#039;,&lt;br /&gt;
&lt;br /&gt;
       &#039;color&#039;:&#039;red&#039;&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#warning&#039;).html(warningText);&lt;br /&gt;
&lt;br /&gt;
   $(&#039;input[type=&amp;quot;submit&amp;quot;]&#039;).after($(&#039;#warning&#039;));&lt;br /&gt;
&lt;br /&gt;
   // Detect the initial number of checked answers &amp;amp; display Next/Submit button accordingly&lt;br /&gt;
&lt;br /&gt;
   var inputInitCount = 0;&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#question&#039; + questionId + &#039; input&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
       if ($( this ).attr(&#039;checked&#039;) == true ) {&lt;br /&gt;
&lt;br /&gt;
           inputInitCount++;&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   if (inputInitCount &amp;gt; (minNumber - 1)) {&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input[type=&amp;quot;submit&amp;quot;]&#039;).show();&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#warning&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   else {&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#warning&#039;).show();&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input[type=&amp;quot;submit&amp;quot;]&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   // Listener to detect number of checked answers &amp;amp; display Next/Submit button accordingly&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#question&#039; + questionId + &#039; input.radio, #question&#039;+questionId+&#039; tbody[id&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&amp;quot;javatbd&amp;quot;] td&#039;).click(function() {&lt;br /&gt;
&lt;br /&gt;
       var inputCount = 0;&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039; + questionId + &#039; input.radio&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
           if ($( this ).attr(&#039;checked&#039;) == true ) {&lt;br /&gt;
&lt;br /&gt;
               inputCount++;&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       if (inputCount &amp;gt; (minNumber - 1)) {&lt;br /&gt;
&lt;br /&gt;
           $(&#039;input[type=&amp;quot;submit&amp;quot;]&#039;).show();&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#warning&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       else {&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#warning&#039;).show();&lt;br /&gt;
&lt;br /&gt;
           $(&#039;input[type=&amp;quot;submit&amp;quot;]&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       // The original functions of the click event&lt;br /&gt;
&lt;br /&gt;
       checkconditions(this.value, this.name, this.type);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Minimum elapsed time before moving forward in survey=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.91, IE 7/8, Firefox 7.0, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround interrupts the Next/Submit function and checks the amount of time elapsed since the page loaded. If the time is less than the minimum dictated, the respondent is alerted and not allowed to proceed. It is useful if you want to enforce a minimum amount of time spent viewing a page.&lt;br /&gt;
#[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_ Set up your survey to use JavaScript].&lt;br /&gt;
#Place the script below in the source of one of the questions on the page, replacing &amp;quot;TT&amp;quot; with the minimum number of seconds required before advancing is allowed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       minTime(TT);&lt;br /&gt;
&lt;br /&gt;
       function minTime(minTime) {&lt;br /&gt;
&lt;br /&gt;
           var startTime = new Date();&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#movenextbtn, #movesubmitbtn&#039;).click(function(){&lt;br /&gt;
&lt;br /&gt;
               var endTime = new Date();&lt;br /&gt;
&lt;br /&gt;
               if[[endTime - startTime)/1000 &amp;lt;= minTime) {&lt;br /&gt;
&lt;br /&gt;
                    alert (&#039;You must spend at least &#039;+minTime+&#039; seconds on the question.&#039;);&lt;br /&gt;
&lt;br /&gt;
                    return false;&lt;br /&gt;
&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
                else {&lt;br /&gt;
&lt;br /&gt;
                    return true;&lt;br /&gt;
&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
            });&lt;br /&gt;
&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 =Minimum number of characters in Long free text or Huge free text questions=&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with: 1.91, IE 7/8, Firefox 7.0, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/div&amp;gt;As of version 1.91, you can use regular expression masks (validation) to specify the minimum number of required characters.  However, even if the question is mandatory, it can still be blank.&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/div&amp;gt;As of version  1.92, if you make the question mandatory and use a validation mask to specify the minimum number of characters, then the user will be forced to answer the question.  Note that unlike 1.91, they can submit their current answers, even if partially invalid (so they are stored in the database), but they will not ber able to proceed to the next page until they have passed all mandatory and validity checks.&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 This workaround interrupts the Next/Submit function and checks the number of characters entered in a Long free text or Huge free text question. If the number is less than the minimum dictated, the respondent is alerted and not allowed to proceed.&lt;br /&gt;
&lt;br /&gt;
 #[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_|Set up your survey to use JavaScript].&lt;br /&gt;
&lt;br /&gt;
 #Place the script below in the source of one of the questions on the page, replace &amp;quot;QQ&amp;quot; with the question ID and &amp;quot;CC&amp;quot; with the minimum number of characters required before advancing is allowed.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
        minChar(QQ, CC);&lt;br /&gt;
&lt;br /&gt;
        function minChar(qID, minChars) {&lt;br /&gt;
&lt;br /&gt;
            $(&#039;#movenextbtn, #movesubmitbtn&#039;).click(function(){&lt;br /&gt;
&lt;br /&gt;
                if($(&#039;#question&#039;+qID+&#039; textarea&#039;).val().replace(/ /g,&#039;&#039;).length &amp;lt; minChars) {&lt;br /&gt;
&lt;br /&gt;
                    alert (&#039;You must enter at least &#039;+minChars+&#039; characters.&#039;);&lt;br /&gt;
&lt;br /&gt;
                    return false;&lt;br /&gt;
&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
                else {&lt;br /&gt;
&lt;br /&gt;
                    return true;&lt;br /&gt;
&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
            });&lt;br /&gt;
&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 =Variable Length Array (Multi Flexible Text) question=&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with: 1.90+, IE 6/7/8, FireFox 3.0, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 This workaround allows a respondent to add or remove rows of an Array (Multi Flexible Text) question. It&#039;s useful to avoid the page being cluttered with unnecessary array rows.&lt;br /&gt;
&lt;br /&gt;
 A function is placed in the template.js file of your template (use template editor). This function hides all of the array rows except the first and inserts two elements that when clicked show or hide rows accordingly.&lt;br /&gt;
&lt;br /&gt;
 There is a demo [http://www.partnersinc.biz/surveys//index.php?sid=53132&amp;amp;newtest;=Y&amp;amp;lang;=en|here].&lt;br /&gt;
&lt;br /&gt;
 It must be noted that you can not make this question Mandatory as the respondent will have no way to complete hidden fields. If you want the displayed fields to be mandatory you will need to validate them in another function or modify this function to only allow the addition of rows if all fields in the last row are completed and then disable those fields - that, however, is a little over the top for this example.&lt;br /&gt;
&lt;br /&gt;
 Implementation is as follows:&lt;br /&gt;
&lt;br /&gt;
 #Set up your survey to use JavaScript (See instructions [http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_|here])&lt;br /&gt;
&lt;br /&gt;
 #Add the following script to your &#039;&#039;template.js&#039;&#039; file.&lt;br /&gt;
&lt;br /&gt;
 #Replace &amp;quot;QQ&amp;quot; in the function call at the end with the question ID.&lt;br /&gt;
&lt;br /&gt;
 #Create one or more Array (Multi Flexible Text) questions&lt;br /&gt;
&lt;br /&gt;
 #If you want to apply it to more arrays on the same page simply add more calls with the appropriate question IDs. (eg. varLengthArray(1); varLengthArray(2);...)&lt;br /&gt;
&lt;br /&gt;
 Onload code:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
        // A function to add or remove rows of an Array (Multi Flexible)(Text) question&lt;br /&gt;
&lt;br /&gt;
        function varLengthArray(qID) {&lt;br /&gt;
&lt;br /&gt;
            if ($(&#039;#question&#039;+qID+&#039;&#039;).length &amp;gt; 0) {&lt;br /&gt;
&lt;br /&gt;
                // The HTML content of the Add/Remove elements - modify as you wish&lt;br /&gt;
&lt;br /&gt;
                var addContent = &#039;[+]&#039;;&lt;br /&gt;
&lt;br /&gt;
                var removeContent = &#039;[-]&#039;;&lt;br /&gt;
&lt;br /&gt;
                // Create the Add and Remove elements &amp;amp; insert them&lt;br /&gt;
&lt;br /&gt;
                var el1 = document.createElement(&#039;div&#039;);&lt;br /&gt;
&lt;br /&gt;
                el1.setAttribute(&#039;id&#039;,&#039;addButton&#039;+qID);&lt;br /&gt;
&lt;br /&gt;
                document.body.appendChild(el1);&lt;br /&gt;
&lt;br /&gt;
                var el2 = document.createElement(&#039;div&#039;);&lt;br /&gt;
&lt;br /&gt;
                el2.setAttribute(&#039;id&#039;,&#039;removeButton&#039;+qID);&lt;br /&gt;
&lt;br /&gt;
                document.body.appendChild(el2);&lt;br /&gt;
&lt;br /&gt;
                // Move them to after the array&lt;br /&gt;
&lt;br /&gt;
                $( &#039;div#addButton&#039;+qID ).appendTo($( &#039;#question&#039; + qID + &#039; table.question&#039; ).parent(]];&lt;br /&gt;
&lt;br /&gt;
               $( &#039;div#removeButton&#039;+qID ).appendTo($( &#039;#question&#039; + qID + &#039; table.question&#039; ).parent());&lt;br /&gt;
&lt;br /&gt;
               // Insert their HTML&lt;br /&gt;
&lt;br /&gt;
               $( &#039;div#addButton&#039;+qID ).html( addContent );&lt;br /&gt;
&lt;br /&gt;
               $( &#039;div#removeButton&#039;+qID ).html( removeContent );&lt;br /&gt;
&lt;br /&gt;
               // Style the elements - you can modify here if you wish&lt;br /&gt;
&lt;br /&gt;
               $( &#039;div#addButton&#039;+qID ).css({&lt;br /&gt;
&lt;br /&gt;
                   &#039;margin&#039;:&#039;10px 0 0 10px&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;padding&#039;:&#039;1px&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;text-align&#039;:&#039;center&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;font-weight&#039;:&#039;bold&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;width&#039;:&#039;auto&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;cursor&#039;:&#039;pointer&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;float&#039;:&#039;left&#039;&lt;br /&gt;
&lt;br /&gt;
               });&lt;br /&gt;
&lt;br /&gt;
               $( &#039;div#removeButton&#039;+qID ).css({&lt;br /&gt;
&lt;br /&gt;
                   &#039;margin&#039;:&#039;10px 0 0 10px&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;padding&#039;:&#039;1px&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;text-align&#039;:&#039;center&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;font-weight&#039;:&#039;bold&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;width&#039;:&#039;auto&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;cursor&#039;:&#039;pointer&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;float&#039;:&#039;left&#039;&lt;br /&gt;
&lt;br /&gt;
               });&lt;br /&gt;
&lt;br /&gt;
               // Initially hide the Remove element&lt;br /&gt;
&lt;br /&gt;
               $( &#039;div#removeButton&#039;+qID ).hide();&lt;br /&gt;
&lt;br /&gt;
               // Call the functions below when clicked&lt;br /&gt;
&lt;br /&gt;
               $( &#039;div#addButton&#039;+qID ).click(function (event) {&lt;br /&gt;
&lt;br /&gt;
                   addRow(qID);&lt;br /&gt;
&lt;br /&gt;
               });&lt;br /&gt;
&lt;br /&gt;
               $( &#039;div#removeButton&#039;+qID ).click(function (event) {&lt;br /&gt;
&lt;br /&gt;
                   removeRow(qID);&lt;br /&gt;
&lt;br /&gt;
               });&lt;br /&gt;
&lt;br /&gt;
               // Function to add a row, also shows the Remove element and hides the&lt;br /&gt;
&lt;br /&gt;
               //Add element if all rows are shown&lt;br /&gt;
&lt;br /&gt;
               function addRow(qID) {&lt;br /&gt;
&lt;br /&gt;
                   var arrayRow = &#039;#question&#039; + qID + &#039; table.question tbody&#039;;&lt;br /&gt;
&lt;br /&gt;
                   var rowCount = $( arrayRow ).size() - 1;&lt;br /&gt;
&lt;br /&gt;
                   $( arrayRow + &#039;[name=&amp;quot;hidden&amp;quot;]:first&#039; ).attr(&#039;name&#039;, &#039;visible&#039;).show();&lt;br /&gt;
&lt;br /&gt;
                   $( &#039;div#removeButton&#039;+qID ).show();&lt;br /&gt;
&lt;br /&gt;
                   if ( $( arrayRow + &#039;:eq(&#039; + rowCount + &#039;)&#039; ).attr(&#039;name&#039;) == &#039;visible&#039; )  {&lt;br /&gt;
&lt;br /&gt;
                       $( &#039;div#addButton&#039;+qID ).hide();&lt;br /&gt;
&lt;br /&gt;
                   }&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               // Function to remove a row, also clears the contents of the removed row,&lt;br /&gt;
&lt;br /&gt;
               // shows the Add element if the last row is hidden and hides the Remove&lt;br /&gt;
&lt;br /&gt;
               // element if only the first row is shown&lt;br /&gt;
&lt;br /&gt;
               function removeRow(qID) {&lt;br /&gt;
&lt;br /&gt;
                   var arrayRow = &#039;#question&#039; + qID + &#039; table.question tbody&#039;;&lt;br /&gt;
&lt;br /&gt;
                   var rowCount = $( arrayRow ).size() - 1;&lt;br /&gt;
&lt;br /&gt;
                   $( arrayRow + &#039;[name=&amp;quot;visible&amp;quot;]:last input[type=&amp;quot;text&amp;quot;]&#039; ).val(&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
                   $( arrayRow + &#039;[name=&amp;quot;visible&amp;quot;]:last&#039; ).attr(&#039;name&#039;, &#039;hidden&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
                   $( &#039;div#addButton&#039;+qID ).show();&lt;br /&gt;
&lt;br /&gt;
                   if ( $( arrayRow + &#039;:eq(1)&#039; ).attr(&#039;name&#039;) == &#039;hidden&#039; )  {&lt;br /&gt;
&lt;br /&gt;
                       $( &#039;div#removeButton&#039;+qID ).hide();&lt;br /&gt;
&lt;br /&gt;
                   }&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               // Just some initialization stuff&lt;br /&gt;
&lt;br /&gt;
               var arrayRow = &#039;#question&#039; + qID + &#039; table.question tbody&#039;;&lt;br /&gt;
&lt;br /&gt;
               var rowCount = &#039;&#039;;&lt;br /&gt;
&lt;br /&gt;
               // Initially hide all except first row or any rows with populated inputs&lt;br /&gt;
&lt;br /&gt;
               $( arrayRow ).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
                   if ( i &amp;gt; 0 ) {&lt;br /&gt;
&lt;br /&gt;
                       // We also need to give the hidden rows a name cause IE doesn&#039;t&lt;br /&gt;
&lt;br /&gt;
                       // recognize jQuery :visible selector consistently&lt;br /&gt;
&lt;br /&gt;
                       $( this ).attr(&#039;name&#039;, &#039;hidden&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
                       $(&#039;input[type=text]&#039;, this).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
                           if ($(this).attr(&#039;value&#039;) != &#039;&#039;) {&lt;br /&gt;
&lt;br /&gt;
                               $(this).parents(&#039;tbody:eq(0)&#039;).attr(&#039;name&#039;, &#039;visible&#039;).show();&lt;br /&gt;
&lt;br /&gt;
                               $( &#039;div#removeButton&#039;+qID ).show();&lt;br /&gt;
&lt;br /&gt;
                           }&lt;br /&gt;
&lt;br /&gt;
                       });&lt;br /&gt;
&lt;br /&gt;
                       rowCount = i;&lt;br /&gt;
&lt;br /&gt;
                   }&lt;br /&gt;
&lt;br /&gt;
               });&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       // Call the function with a question ID&lt;br /&gt;
&lt;br /&gt;
       varLengthArray(QQ);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Expandable Array=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 6/7, FireFox 3.5, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround allows you to present an array question incrementally. That is to say that initially only the first option (row) in the array is shown. When that option is answered the next is shown and so-on.&lt;br /&gt;
&lt;br /&gt;
A JavaScript function is placed in the source of the array question. This function hides all of the array rows except the first and then displays them as options are answered.&lt;br /&gt;
&lt;br /&gt;
There is a demo [http://www.partnersinc.biz/surveys//index.php?sid=94958&amp;amp;newtest;=Y&amp;amp;lang;=en here].&lt;br /&gt;
&lt;br /&gt;
The workaround supports following question types:&lt;br /&gt;
*Array (flexible labels)&lt;br /&gt;
*Array (flexible labels) by column&lt;br /&gt;
*Array (Yes/No/Uncertain)&lt;br /&gt;
*Array (Increase, Same, Decrease)&lt;br /&gt;
*Array (Flexible Labels) dual scale&lt;br /&gt;
*Array (10 point choice)&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#Set up your survey to use JavaScript. (See [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._ documentation here])&lt;br /&gt;
#Create one or more Array questions&lt;br /&gt;
#In the source of the first array question add the following script.&lt;br /&gt;
#Replace &amp;quot;QQ&amp;quot; in the function call at the end of the script with the question ID of the array you would like to manipulate.&lt;br /&gt;
#If you want to apply it to more arrays on the same page, simply add more calls with the appropriate question IDs. (eg. expandingArray(1); expandingArray(2);...)&lt;br /&gt;
&lt;br /&gt;
Onload code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // A function to show subsequent rows of an array as options are checked&lt;br /&gt;
&lt;br /&gt;
       function expandingArray(qID) {&lt;br /&gt;
&lt;br /&gt;
           // Build an array of the question rows&lt;br /&gt;
&lt;br /&gt;
           var arrayRow = &#039;#question&#039; + qID + &#039; table.question tbody tr&#039;;&lt;br /&gt;
&lt;br /&gt;
           // Initially hide all rows unless an input was previously checked&lt;br /&gt;
&lt;br /&gt;
           $( arrayRow ).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
               if ( $( arrayRow  + &#039;:eq(&#039; + i + &#039;) input.radio:checked&#039; ).length != 0 ) {&lt;br /&gt;
&lt;br /&gt;
                   $( this ).attr(&#039;name&#039;, &#039;clickedRow&#039;);&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               else {&lt;br /&gt;
&lt;br /&gt;
                   $( this ).attr(&#039;name&#039;, &#039;hidden&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Now show the first hidden row&lt;br /&gt;
&lt;br /&gt;
           addRow();&lt;br /&gt;
&lt;br /&gt;
           // Add another row when an option is checked for the first time&lt;br /&gt;
&lt;br /&gt;
           $( &#039;#question&#039; + qID + &#039; td.answer input.radio&#039; ).click(function (event) {&lt;br /&gt;
&lt;br /&gt;
               if ($( this ).parents(&#039;tr:eq(0)&#039;).attr(&#039;name&#039;) != &#039;clickedRow&#039;) {&lt;br /&gt;
&lt;br /&gt;
                   addRow();&lt;br /&gt;
&lt;br /&gt;
                   $( this ).parents(&#039;tr:eq(0)&#039;).attr(&#039;name&#039;, &#039;clickedRow&#039;);&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               // The original function of the click event&lt;br /&gt;
&lt;br /&gt;
               checkconditions(this.value, this.name, this.type);&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Add another row when an table cell is clicked for the first time&lt;br /&gt;
&lt;br /&gt;
           $( &#039;#question&#039; + qID + &#039; table.question tbody td&#039; ).click(function (event) {&lt;br /&gt;
&lt;br /&gt;
               if ($( this ).parents(&#039;tr:eq(0)&#039;).attr(&#039;name&#039;) != &#039;clickedRow&#039;) {&lt;br /&gt;
&lt;br /&gt;
                   addRow();&lt;br /&gt;
&lt;br /&gt;
                   $( this ).parents(&#039;tr:eq(0)&#039;).attr(&#039;name&#039;, &#039;clickedRow&#039;);&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Function to add a row&lt;br /&gt;
&lt;br /&gt;
           function addRow() {&lt;br /&gt;
&lt;br /&gt;
               $( arrayRow + &#039;[name=&amp;quot;hidden&amp;quot;]:first&#039; ).attr(&#039;name&#039;, &#039;visible&#039;).show();&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       // Call the function with a question ID&lt;br /&gt;
&lt;br /&gt;
       expandingArray(QQ);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Partially Randomized Answers - Multiple Options &amp;amp; List (radio) questions=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 6/7, FireFox 3.0, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround allows the answers of Multiple Options &amp;amp; List (radio) questions to be randomized while always keeping one answer at the end of the list. It&#039;s useful if you want to randomize, say, the first 4 of your answers but always have the fifth displayed last as in the image below:&lt;br /&gt;
&lt;br /&gt;
[[File:random_336x179gif.gif]]&lt;br /&gt;
&lt;br /&gt;
An onload function is placed in the source of a question. After the randomizing has occurred this function moves the answer with the highest answer code to the end of the list.&lt;br /&gt;
&lt;br /&gt;
There is a demo [http://www.partnersinc.biz/surveys//index.php?sid=89344&amp;amp;newtest;=Y&amp;amp;lang;=en here].&lt;br /&gt;
&lt;br /&gt;
Some conditions on the use of this are:&lt;br /&gt;
*For Select/radio type questions it will only work if the [http://docs.limesurvey.org/tiki-index.php?page=Optional+settings&amp;amp;structure;=English+Instructions+for+LimeSurvey#Survey_Behavior $shownoanswer option] is set to 0 in config.php. (&amp;quot;No answer&amp;quot; is removed from the end of questions)&lt;br /&gt;
*You must use sequential numbers, starting at 1 as response codes. (See image below)&lt;br /&gt;
&lt;br /&gt;
[[File:random_700x154.png]]&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#Turn off &#039;&#039;$filterxsshtml&#039;&#039; to allow insertion of JavaScript in the questions. (See [http://docs.limesurvey.org/tiki-index.php?page=Optional+settings&amp;amp;structure;=English+Instructions+for+LimeSurvey#Filtering_dangerous_HTML_tags_in_survey_objects documentation here])&lt;br /&gt;
#Create one or more Multiple Options or List (radio) questions with sequential response codes. Set the [http://docs.limesurvey.org/tiki-index.php?page=Question+attributes&amp;amp;structure;=English+Instructions+for+LimeSurvey#random_order random_order question attribute] to 1.&lt;br /&gt;
#In the source of the first question add the following onload function. (See [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._ How to use script here])&lt;br /&gt;
#Replace &amp;quot;SSSSS&amp;quot;, &amp;quot;GG&amp;quot;, &amp;quot;QQ&amp;quot; in the function call at the end with the survey ID, group ID and question ID respectively.&lt;br /&gt;
#If you want to apply it to more questions on the same page simply add more calls with the appropriate IDs. (eg. partRand(11111, 22, 1); partRand(11111, 22, 2); ...)&lt;br /&gt;
&lt;br /&gt;
Onload code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Function to allow randomization of all answers except the last one in Multiple options and List/radio questions&lt;br /&gt;
&lt;br /&gt;
       function partRand(sID, gID, qID) {&lt;br /&gt;
&lt;br /&gt;
           // Find the number of answers&lt;br /&gt;
&lt;br /&gt;
           var ansCount = &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
           $( &#039;div#question&#039; + qID + &#039; td.answer li&#039; ).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
               ansCount = (i + 1);&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Place the last answer created at the end of the list&lt;br /&gt;
&lt;br /&gt;
           $( &#039;input#answer&#039; + sID + &#039;X&#039; + gID + &#039;X&#039; + qID + ansCount + &#039;&#039; ).parent().appendTo($( &#039;#question&#039; + qID + &#039; td.answer ul&#039; ));&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       // Call the function with the SID, GID and QID&lt;br /&gt;
&lt;br /&gt;
       partRand(SSSSS, GG, QQ);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Partially Randomized Answers - List (dropdown) questions=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 6/7, FireFox 3.0, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround, similar to the one above, allows the answers of List (dropdown) questions to be randomized while always keeping one answer at the end of the list. It&#039;s useful if you want to randomize, say, the first 4 of your answers but always have the fifth displayed last.&lt;br /&gt;
&lt;br /&gt;
An onload function is placed in the source of a question. After the randomizing has occurred this function moves the answer with the highest answer code to the end of the list.&lt;br /&gt;
&lt;br /&gt;
There is a demo [http://www.partnersinc.biz/surveys//index.php?sid=89344&amp;amp;newtest;=Y&amp;amp;lang;=en here].&lt;br /&gt;
&lt;br /&gt;
A condition is that you must use sequential numbers, starting at 1 as response codes. (See image below)&lt;br /&gt;
&lt;br /&gt;
[[File:random_700x154.png]]&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#Turn off &#039;&#039;$filterxsshtml&#039;&#039; to allow insertion of JavaScript in the questions. (See [http://docs.limesurvey.org/tiki-index.php?page=Optional+settings&amp;amp;structure;=English+Instructions+for+LimeSurvey#Filtering_dangerous_HTML_tags_in_survey_objects documentation here])&lt;br /&gt;
#Create one or more List (dropdown) questions with sequential response codes. Set the [http://docs.limesurvey.org/tiki-index.php?page=Question+attributes&amp;amp;structure;=English+Instructions+for+LimeSurvey#random_order random_order question attribute] to 1.&lt;br /&gt;
#In the source of the first question add the following onload function. (See [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._ How to use script here])&lt;br /&gt;
#Replace &amp;quot;SSSSS&amp;quot;, &amp;quot;GG&amp;quot;, &amp;quot;QQ&amp;quot; in the function call at the end with the survey ID, group ID and question ID respectively.&lt;br /&gt;
#If you want to apply it to more questions on the same page simply add more calls with the appropriate IDs. (eg. partRandDD(11111, 22, 1); partRandDD(11111, 22, 2); ...)&lt;br /&gt;
&lt;br /&gt;
Onload code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
   // Function to allow randomization of all answers&lt;br /&gt;
&lt;br /&gt;
   //except the last one in List/dropdown questions&lt;br /&gt;
&lt;br /&gt;
   function partRandDD(sID, gID, qID) {&lt;br /&gt;
&lt;br /&gt;
       // Find the number of answers&lt;br /&gt;
&lt;br /&gt;
       var ansCount = &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
       $( &#039;div#question&#039; + qID + &#039; select option&#039; ).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
           ansCount = i;&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // Place the last answer created at the end of the list&lt;br /&gt;
&lt;br /&gt;
$( &#039;option[value=&amp;quot;&#039; + ansCount + &#039;&amp;quot;]&#039; ).appendTo($( &#039;div#question&#039; + qID + &#039; select&#039; ));&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   // Call the function with the SID, GID and QID&lt;br /&gt;
&lt;br /&gt;
   partRandDD(89344, 72, 244);&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Partially Randomized Answers - Multiple numerical input=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, Safari 5.1&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround, similar to the ones above, allows the answers of Multiple numerical input questions to be randomized while always keeping one answer at the end of the list. It&#039;s useful if you want to randomize, say, the first 4 of your answers but always have the fifth displayed last.&lt;br /&gt;
&lt;br /&gt;
An onload function is placed in the source of a question. After the randomizing has occurred this function moves the answer with the highest answer code to the end of the list.&lt;br /&gt;
&lt;br /&gt;
A condition is that you must use sequential numbers, starting at 1 as response codes. (See image below)&lt;br /&gt;
&lt;br /&gt;
[[File:random_700x154.png]]&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#Turn off &#039;&#039;$filterxsshtml&#039;&#039; to allow insertion of JavaScript in the questions. (See [http://docs.limesurvey.org/tiki-index.php?page=Optional+settings&amp;amp;structure;=English+Instructions+for+LimeSurvey#Filtering_dangerous_HTML_tags_in_survey_objects documentation here])&lt;br /&gt;
#Create one or more Multiple numerical input question with sequential response codes. Set the [http://docs.limesurvey.org/tiki-index.php?page=Question+attributes&amp;amp;structure;=English+Instructions+for+LimeSurvey#random_order random_order question attribute] to 1.&lt;br /&gt;
#In the source of the first question add the following onload function. (See [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._ How to use script here])&lt;br /&gt;
#Replace &amp;quot;SSSSS&amp;quot;, &amp;quot;GG&amp;quot;, &amp;quot;QQ&amp;quot; in the function call at the end with the survey ID, group ID and question ID respectively.&lt;br /&gt;
#If you want to apply it to more questions on the same page simply add more calls with the appropriate IDs. (eg. partRandDD(11111, 22, 1); partRandDD(11111, 22, 2); ...)&lt;br /&gt;
&lt;br /&gt;
Onload code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Function to allow randomization of all answers except the last one in multiple numeric input questions&lt;br /&gt;
&lt;br /&gt;
       function partRand(sID, gID, qID) {&lt;br /&gt;
&lt;br /&gt;
           // Find the number of answers&lt;br /&gt;
&lt;br /&gt;
           var ansCount = &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
           $( &#039;div#question&#039; + qID + &#039; div.answers li&#039; ).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
               ansCount = (i - 1);&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Place the last answer created at the end of the list - but before the first helping sum&lt;br /&gt;
&lt;br /&gt;
           $( &#039;li#javatbd&#039; + sID + &#039;X&#039; + gID + &#039;X&#039; + qID + ansCount + &#039;&#039; ).insertBefore($( &#039;div#question&#039; + qID + &#039; div.answers li.multiplenumerichelp&#039; ).first());&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       // Call the function with the SID, GID and QID&lt;br /&gt;
&lt;br /&gt;
       partRand(SID, GID, QID);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using this solution for Multiple numerical input questions might be a bit more complicated than for other question types. All answers are organized in an unordered list (&amp;lt;ul&amp;gt;) structure. However, if advanced question settings like &#039;&#039;Equals sum value&#039;&#039; are used, LimeSurvey adds helping information (e.g. sum of all entries and remainder) to the same unordered list using the class &#039;&#039;multiplenumerichelp&#039;&#039; for these additional list items. The above example  assumes that at least one of these list items is present and moves the last answer to the position right above the first helper item. Without such advanced settings, the code will most certainly need adaptation.&lt;br /&gt;
&lt;br /&gt;
=Making one (or more) rows of an array mandatory=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 6/7, Firefox 3.0, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround allows you to define one or more rows of an array question as mandatory (instead of all of them which the &amp;quot;Mandatory&amp;quot; question setting does). It is [http://www.partnersinc.biz/surveys//index.php?sid=26842&amp;amp;newtest;=Y&amp;amp;lang;=en demonstrated here].&lt;br /&gt;
&lt;br /&gt;
A JavaScript function interrupts the submit function and checks if the inputs in the mandatory row(s) are populated. If not, an alert is popped up, the offending inputs are turned pink and the submit is aborted. Otherwise the submit goes ahead.&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#Turn off &#039;&#039;$filterxsshtml&#039;&#039; to allow insertion of JavaScript in the questions (see [http://docs.limesurvey.org/tiki-index.php?page=Optional+settings&amp;amp;structure;=English+Instructions+for+LimeSurvey#Filtering_dangerous_HTML_tags_in_survey_objects documentation here]).&lt;br /&gt;
#Create the array question.&lt;br /&gt;
#In the source of the array question add the following script (see [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._ How to use script here]).&lt;br /&gt;
#Modify the warningText (line10)as required.&lt;br /&gt;
#Replace &amp;quot;QQ&amp;quot; (lines 13 and 14)  with the question ID and add calls as necessary for more rows - the example code renders rows 1 and 3 mandatory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$(document).ready(function () {&lt;br /&gt;
&lt;br /&gt;
 // Interrupt the submit function&lt;br /&gt;
&lt;br /&gt;
 $(&#039;form#limesurvey&#039;).submit(function () {&lt;br /&gt;
&lt;br /&gt;
   // Override the built-in &amp;quot;disable navigation buttons&amp;quot; feature&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#moveprevbtn, #movenextbtn, #movesubmitbtn&#039;).attr(&#039;disabled&#039;, &#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
   var empty = 0;&lt;br /&gt;
&lt;br /&gt;
   var warningText = &#039;Please complete the highlighted inputs.&#039;;&lt;br /&gt;
&lt;br /&gt;
   // Call the mandatory row function with question IDs and row numbers&lt;br /&gt;
&lt;br /&gt;
   mandatoryRow(QQ, 1);&lt;br /&gt;
&lt;br /&gt;
   mandatoryRow(QQ, 3);&lt;br /&gt;
&lt;br /&gt;
   // A function to render rows of an array mandatory&lt;br /&gt;
&lt;br /&gt;
   function mandatoryRow(qID, rowNum) {&lt;br /&gt;
&lt;br /&gt;
     $(&#039;div#question&#039; + qID + &#039; table.question tbody[id&amp;lt;/div&amp;gt;=&amp;quot;javatbd&amp;quot;]:eq(&#039; + Number(rowNum - 1) + &#039;) input[type=&amp;quot;text&amp;quot;]&#039;).each(function (i) {&lt;br /&gt;
&lt;br /&gt;
       if ($(this).val() == &#039;&#039;) {&lt;br /&gt;
&lt;br /&gt;
         $(this).css(&#039;background-color&#039;, &#039;pink&#039;);&lt;br /&gt;
&lt;br /&gt;
         empty = 1;&lt;br /&gt;
&lt;br /&gt;
       } else {&lt;br /&gt;
&lt;br /&gt;
         $(this).css(&#039;background-color&#039;, &#039;#FFFFFF&#039;);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
     });&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   if (empty == 1) {&lt;br /&gt;
&lt;br /&gt;
     alert(warningText);&lt;br /&gt;
&lt;br /&gt;
     return false;&lt;br /&gt;
&lt;br /&gt;
   } else {&lt;br /&gt;
&lt;br /&gt;
     return true;&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Randomly displaying one of a few YouTube videos, and recording which was displayed=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested in 1.85+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Jason Cleeland has created and documented a method to randomly display one of a number of youtube videos in a single question, and save which one was displayed.&lt;br /&gt;
&lt;br /&gt;
http://www.aptigence.com.au/home/archives/23-Random-display-of-videos-in-a-question-2-YouTube.html&lt;br /&gt;
&lt;br /&gt;
=Randomly displaying one of a few pictures, and recording which was displayed=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested in 1.91+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The following steps allow you to randomly display one of a few pictures and record in the dataset which picture was displayed. We use four pictures in this example, but you can easily adapt these scripts according to your needs.&lt;br /&gt;
&lt;br /&gt;
1. Create a new sub-directory &#039;&#039;&#039;pic&#039;&#039;&#039; in your LimeSurvey folder.&lt;br /&gt;
&lt;br /&gt;
2. Copy four pictures (named &#039;&#039;1.jpg&#039;&#039;, &#039;&#039;2.jpg&#039;&#039;, &#039;&#039;3.jpg&#039;&#039;, and &#039;&#039;4.jpg&#039;&#039;) in this pic sub-directory.&lt;br /&gt;
&lt;br /&gt;
3. Deactivate the &#039;&#039;Filter HTML for XSS&#039;&#039; function in LimeSurvey&#039;s &#039;&#039;Global Settings&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
4. Create a &#039;&#039;&#039;Short free text&#039;&#039;&#039; question where you want these pictures to be displayed.&lt;br /&gt;
&lt;br /&gt;
5. Figure out the [http://docs.limesurvey.org/SGQA+identifier SGQA Identifier] of this question (e.g., 12345X67X89).&lt;br /&gt;
&lt;br /&gt;
6. Paste the following code as question text after activating the editor&#039;s &#039;&#039;Source&#039;&#039; view and replace both SSSSSXGGXQQ strings with your SGQA identifier:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please have a look at this picture:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$(document).ready(&lt;br /&gt;
&lt;br /&gt;
function(){&lt;br /&gt;
&lt;br /&gt;
// Find a random number (here between 1 and 4)&lt;br /&gt;
&lt;br /&gt;
var randNumber = Math.floor(Math.random()*4 + 1);&lt;br /&gt;
&lt;br /&gt;
// Save the number as answer of this question&lt;br /&gt;
&lt;br /&gt;
$(&#039;input#answerSSSSSXGGXQQ&#039;).val(randNumber);&lt;br /&gt;
&lt;br /&gt;
// Hide this answer field&lt;br /&gt;
&lt;br /&gt;
document.getElementById(&amp;quot;answerSSSSSXGGXQQ&amp;quot;).style.display=&#039;none&#039;;&lt;br /&gt;
&lt;br /&gt;
// Show the picture&lt;br /&gt;
&lt;br /&gt;
picString = &#039;&amp;lt;img src=&amp;quot;pic/&#039; + String(randNumber) + &#039;.jpg&amp;quot;&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
document.getElementById(&#039;pic&#039;).innerHTML = picString;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;pic&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to display the number of this picture in a later question, use the following code as question text (don&#039;t forget to replace the SSSSSXGGXQQ string acordingly):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You saw picture number {INSERTANS:SSSSSXGGXQQ}.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Perhaps you want to display the same picture again in a later question, but a little bit smaller (100px width, 100px height)? Just paste the following code as question text after activating the editor&#039;s &#039;&#039;Source&#039;&#039; view, and replace the SSSSSXGGXQQ string acordingly:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here you see the picture again: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$(document).ready(&lt;br /&gt;
&lt;br /&gt;
function(){&lt;br /&gt;
&lt;br /&gt;
// Get the picture number from previous question&lt;br /&gt;
&lt;br /&gt;
var randNumber = &amp;quot;{INSERTANS:SSSSSXGGXQQ}&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
// Show picture&lt;br /&gt;
&lt;br /&gt;
picString = &#039;&amp;lt;img width=&amp;quot;100&amp;quot; height=&amp;quot;100&amp;quot; src=&amp;quot;pic/&#039; + String(randNumber) + &#039;.jpg&amp;quot;&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
document.getElementById(&#039;pic&#039;).innerHTML = picString;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;pic&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Multiple numerical input with max_num_value defined in token (personalized limit)=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested in 1.85+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, max_num_value can be an experession, so you can simply enter the {TOKEN} or other variable in that question attribute.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To make personalized survey with multiple numerical input when max_num_value (Maximum sum value) is different for each user and is loaded from the token use following tricks:&lt;br /&gt;
*Create 1st group with numerical input field (1000X10X11). &amp;quot;Limit&amp;quot;&lt;br /&gt;
*Add java script into this question:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
function Custom_On_Load(){&lt;br /&gt;
&lt;br /&gt;
  document.getElementById(&#039;answer1000X10X11&#039;).value=&#039;{TOKEN:ATTRIBUTE_1}&#039;;&lt;br /&gt;
&lt;br /&gt;
  document.getElementById(&#039;answer1000X10X11&#039;).readOnly=1;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where:&lt;br /&gt;
&lt;br /&gt;
TOKEN:ATTRIBUTE_1 is individual limit defined in token.&lt;br /&gt;
&lt;br /&gt;
readOnly=1 // user shouldn&#039;t change it.&lt;br /&gt;
*Create 2nd group with multiple numerical input and add &amp;quot;Max value from SGQA&amp;quot; with 1000X10X11 as argument.&lt;br /&gt;
&lt;br /&gt;
Note: If you don&#039;t want to show first field with numerical input (and show definied limit in different way) you can add 2 lines to above script to hide whole question:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
document.getElementById(&#039;question85&#039;).style.display=&#039;none&#039;;&lt;br /&gt;
&lt;br /&gt;
document.getElementById(&#039;display85&#039;).value=&#039;&#039;;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where:&lt;br /&gt;
&lt;br /&gt;
question85 and display85 are field names.&lt;br /&gt;
&lt;br /&gt;
Note: It&#039;s no possible to create it into one group, because all SGQA references can only refer to data on a previous page because when clicking next the answer is stored at the DB and the SGQA is replaced by querying the database.&lt;br /&gt;
&lt;br /&gt;
=Default values in array questions=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.87+ (7557), IE 6/7, Firefox 3.5, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of Version 1.92, many more question types support default values.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround uses JavaScript to allow you to pre-check default answers in all sub-questions of an array type question. You can select a column of the array to be checked as the page loads. The script first checks to see if a sub-question has already been answered and, if not, checks the default answer.&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#[http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._ Set up your survey to use JavaScript].&lt;br /&gt;
#Create the array question.&lt;br /&gt;
#In the source of the array question add the following script.&lt;br /&gt;
#Replace&amp;quot;QQ&amp;quot; with the question ID and &amp;quot;CC&amp;quot; with the column number to be checked.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // A function to pre-check a column of an array&lt;br /&gt;
&lt;br /&gt;
       function checkedDefault(qID, column) {&lt;br /&gt;
&lt;br /&gt;
           var checkedCol = column - 1;&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039; + qID + &#039; table.question tbody tr&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
               if ($(&#039;input.radio[checked=true]&#039;, this).length == 0) {&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;input.radio:eq(&#039; + checkedCol + &#039;)&#039;, this).attr(&#039;checked&#039;, true);&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       // Call the function with a question ID and column number&lt;br /&gt;
&lt;br /&gt;
       checkedDefault(QQ, CC);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Record group view time=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.87+ (8518), IE 6/7, Firefox 3.5, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, group view time is accurately recorded in the timings table if you choose the Record Timings survey option.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround uses JavaScript to populate a hidden question with the total time that a respondent views a group. If used in a group with only one question, it could be used to track the amount of time required to answer the question.&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#[http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._ Set up your survey to use JavaScript].&lt;br /&gt;
#In the group, create a short-text question. We will hide this later with JavaScript and populate it with the elapsed time.&lt;br /&gt;
#Place the following script in the source of the short-text question.&lt;br /&gt;
#Replace &amp;quot;QQ&amp;quot; in line 6 with the ID of the short-text question.&lt;br /&gt;
&lt;br /&gt;
The script populates the hidden question with the elapsed time since the group was opened. If a respondent leaves the group and then returns, the timer continues up from the elapsed time of the last visit.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function(){&lt;br /&gt;
&lt;br /&gt;
       // call the functions with the hidden timer question ID&lt;br /&gt;
&lt;br /&gt;
       runTimer(QQ);&lt;br /&gt;
&lt;br /&gt;
       function runTimer(timeQID) {&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+timeQID).hide();&lt;br /&gt;
&lt;br /&gt;
           var initSec = &#039;0&#039;;&lt;br /&gt;
&lt;br /&gt;
           // Check for elapsed time from previous visits&lt;br /&gt;
&lt;br /&gt;
           if ($(&#039;#question&#039;+timeQID+&#039; input.text&#039;).val()) {&lt;br /&gt;
&lt;br /&gt;
               var initTime = $(&#039;#question&#039;+timeQID+&#039; input.text&#039;).val();&lt;br /&gt;
&lt;br /&gt;
               initTimeArr = initTime.split(&#039;:&#039;);&lt;br /&gt;
&lt;br /&gt;
               initSec = Number[[initTimeArr[0]*3600]]+Number[[initTimeArr[1]*60]]+Number(initTimeArr[2]);&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
           // Run the timer update function&lt;br /&gt;
&lt;br /&gt;
           recordTime(initSec, timeQID);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   // Timer update function&lt;br /&gt;
&lt;br /&gt;
   function recordTime(elapsedSec, timeQID){&lt;br /&gt;
&lt;br /&gt;
       elapsedSec++;&lt;br /&gt;
&lt;br /&gt;
       var h = Math.floor(elapsedSec / 3600);&lt;br /&gt;
&lt;br /&gt;
       var m = Math.floor(elapsedSec % 3600 / 60);&lt;br /&gt;
&lt;br /&gt;
       var s = Math.floor(elapsedSec % 3600 % 60);&lt;br /&gt;
&lt;br /&gt;
       var elapsedTime = [[h &amp;gt; 0 ? h + &amp;quot;:&amp;quot; : &amp;quot;00:&amp;quot;) + (m &amp;gt; 0 ? (m &amp;lt; 10 ? &amp;quot;0&amp;quot; : &amp;quot;&amp;quot;) + m + &amp;quot;:&amp;quot; : &amp;quot;00:&amp;quot;) + (s &amp;lt; 10 ? &amp;quot;0&amp;quot; : &amp;quot;&amp;quot;) + s);&lt;br /&gt;
&lt;br /&gt;
        $(&#039;#question&#039;+timeQID+&#039; input.text&#039;).val(elapsedTime);&lt;br /&gt;
&lt;br /&gt;
        // Run the timer update function every second&lt;br /&gt;
&lt;br /&gt;
        setTimeout(&#039;recordTime(&#039;+elapsedSec+&#039;, &#039;+timeQID+&#039;)&#039;,1000);&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 =Toggle visibility of groups=&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with: 1.90+, IE 6/7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;Version 1.92 supports group-level relevance, making this workaround obsolete.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 This workaround uses JavaScript to toggle the visibility of groups in an &amp;quot;all in one&amp;quot; survey. Initially the groups are hidden and there are links inserted to display the groups. It&#039;s useful to avoid the page being cluttered with many groups and lets the respondent focus on one at a time.&lt;br /&gt;
&lt;br /&gt;
 It&#039;s [http://www.partnersinc.biz/surveys//index.php?sid=33613&amp;amp;newtest;=Y&amp;amp;lang;=en|demonstrated here].&lt;br /&gt;
&lt;br /&gt;
 Implementation is as follows:&lt;br /&gt;
&lt;br /&gt;
 #[http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._|Set up your survey to use JavaScript].&lt;br /&gt;
&lt;br /&gt;
 #Set the survey to run in &amp;quot;all in one&amp;quot; mode.&lt;br /&gt;
&lt;br /&gt;
 #Add your groups and questions.&lt;br /&gt;
&lt;br /&gt;
 #Place the following script in the source of one of the questions in the first group.&lt;br /&gt;
&lt;br /&gt;
 The comments in the script are pretty self-explanatory but it does the following:&lt;br /&gt;
&lt;br /&gt;
 #initially hides all of the groups&lt;br /&gt;
&lt;br /&gt;
 #inserts a link above each one to toggle its display&lt;br /&gt;
&lt;br /&gt;
 #some styles are added to the clickable links but these could be done in template.css instead&lt;br /&gt;
&lt;br /&gt;
 #shows any groups that have an unanswered mandatory after a submit attempt&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    $(document).ready(function(){&lt;br /&gt;
&lt;br /&gt;
       // Insert show/hide elements before all group wrapper divs&lt;br /&gt;
&lt;br /&gt;
        $(&#039;&amp;lt;div class=&amp;quot;groupToggler&amp;quot;&amp;gt;&amp;lt;span&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;/div&amp;gt;&#039;).insertBefore(&#039;div[id&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&amp;quot;group-&amp;quot;]&#039;);&lt;br /&gt;
&lt;br /&gt;
        // Add some text to the show/hide elements&lt;br /&gt;
&lt;br /&gt;
        $(&#039;.groupToggler span&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
            ($( this ).text(&#039;Show/Hide Group &#039;+(i+1)+&#039;&#039;]];&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // Add some styles to the show/hide elements&lt;br /&gt;
&lt;br /&gt;
       $(&#039;.groupToggler&#039;).css({&lt;br /&gt;
&lt;br /&gt;
           &#039;padding&#039;:&#039;5px 0 10px 0&#039;,&lt;br /&gt;
&lt;br /&gt;
           &#039;text-align&#039;:&#039;center&#039;&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       $(&#039;.groupToggler span&#039;).css({&lt;br /&gt;
&lt;br /&gt;
           &#039;text-decoration&#039;:&#039;underline&#039;,&lt;br /&gt;
&lt;br /&gt;
           &#039;cursor&#039;:&#039;pointer&#039;&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // Add some hover effects to the show/hide elements&lt;br /&gt;
&lt;br /&gt;
       $(&amp;quot;.groupToggler span&amp;quot;).hover(&lt;br /&gt;
&lt;br /&gt;
           function () {&lt;br /&gt;
&lt;br /&gt;
               $(this).css({&lt;br /&gt;
&lt;br /&gt;
                   &#039;text-decoration&#039;:&#039;none&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;font-weight&#039;:&#039;bold&#039;&lt;br /&gt;
&lt;br /&gt;
               });&lt;br /&gt;
&lt;br /&gt;
           },&lt;br /&gt;
&lt;br /&gt;
           function () {&lt;br /&gt;
&lt;br /&gt;
               $(this).css({&lt;br /&gt;
&lt;br /&gt;
                   &#039;text-decoration&#039;:&#039;underline&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;font-weight&#039;:&#039;normal&#039;&lt;br /&gt;
&lt;br /&gt;
               });&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       );&lt;br /&gt;
&lt;br /&gt;
       // Initially hide all of the groups&lt;br /&gt;
&lt;br /&gt;
       // Toggle their visibility when the show/hide element is clicked&lt;br /&gt;
&lt;br /&gt;
       $(&#039;.groupToggler span&#039;).click(function() {&lt;br /&gt;
&lt;br /&gt;
           $(this).parent().next().toggle();&lt;br /&gt;
&lt;br /&gt;
           return false;&lt;br /&gt;
&lt;br /&gt;
       }).parent().next().hide();&lt;br /&gt;
&lt;br /&gt;
       // Display any groups that have unanswered mandatories&lt;br /&gt;
&lt;br /&gt;
       $(&#039;.errormandatory&#039;).parents(&#039;div[id&amp;lt;/div&amp;gt;=&amp;quot;group-&amp;quot;]&#039;).show();&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Use jQuery Autocomplete plugin to suggest answers for text inputs=&lt;br /&gt;
&lt;br /&gt;
== 1.90 and previous versions==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 6/7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround uses the [http://docs.jquery.com/Plugins/Autocomplete jQuery Autocomplete] plugin to provide a respondent a list of suggested answers that the they can select from as they type in a text input.&lt;br /&gt;
&lt;br /&gt;
Although the plugin allows for much more complex applications, the two that I use most frequently are outlined below. The first method uses a relatively small list of suggestions that is stored in an array locally. The second is a little more complex - it uses a remote CSV file of suggestions that is accessed through AJAX an PHP.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve put together a small demonstration [http://www.partnersinc.biz/surveys//index.php?sid=78611&amp;amp;newtest;=Y&amp;amp;lang;=en here] and implementation is as follows.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Both methods:&#039;&#039;&#039;&lt;br /&gt;
*[http://docs.jquery.com/Plugins/Autocomplete Download the plugin]&lt;br /&gt;
*Place the files &#039;&#039;jquery.autocomplete.css&#039;&#039; and &#039;&#039;jquery.autocomplete.js&#039;&#039; in your template directory&lt;br /&gt;
*Add the following code inside the &amp;lt;head&amp;gt; element of startpage.pstpl&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;{TEMPLATEURL}jquery.autocomplete.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;link rel=&amp;quot;stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot; href=&amp;quot;{TEMPLATEURL}jquery.autocomplete.css&amp;quot; /&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Method 1 (&amp;quot;States&amp;quot; question in the demo):&#039;&#039;&#039;&lt;br /&gt;
*Create a text input question&lt;br /&gt;
*Add the following script to the source of the text question&lt;br /&gt;
*Replace &amp;quot;QQ&amp;quot; with the ID of the text input question&lt;br /&gt;
*Replace the states with your list of suggestions (comma separated)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       var q1ID = QQ;&lt;br /&gt;
&lt;br /&gt;
       var states = &amp;quot;Alabama,Alaska,Arizona,Arkansas,California,Colorado,Connecticut,Delaware,&lt;br /&gt;
&lt;br /&gt;
       District of Columbia,Florida,Georgia,Hawaii,Idaho,Illinois,Indiana,Iowa,Kansas,Kentucky,&lt;br /&gt;
&lt;br /&gt;
       Louisiana,Maine,Montana,Nebraska,Nevada,New Hampshire,New Jersey,New Mexico,New York,&lt;br /&gt;
&lt;br /&gt;
       North Carolina,North Dakota,Ohio,Oklahoma,Oregon,Maryland,Massachusetts,Michigan,&lt;br /&gt;
&lt;br /&gt;
       Minnesota,Mississippi,Missouri,Pennsylvania,Rhode Island,South Carolina,South Dakota,&lt;br /&gt;
&lt;br /&gt;
       Tennessee,Texas,Utah,Vermont,Virginia,Washington,West Virginia,Wisconsin,Wyoming&amp;quot;.split(&#039;,&#039;);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q1ID+&#039; input.text&#039;).autocomplete(states, {&lt;br /&gt;
&lt;br /&gt;
           matchContains: true,&lt;br /&gt;
&lt;br /&gt;
           minChars: 0&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Method 2 (&amp;quot;Countries&amp;quot; question in the demo):&#039;&#039;&#039;&lt;br /&gt;
*Place the CSV file of suggestions in your template directory (you can download my demo CSV [http://www.partnersinc.biz/surveys/templates/default_autocompleting_input/countries2.csv here])&lt;br /&gt;
*Place a PHP file containing the code below in your template directory&lt;br /&gt;
*Replace &amp;quot;countries2.csv&amp;quot; with your CSV filename (you could make this more universal by passing the filename in the URL)&lt;br /&gt;
*This file will grab the contents of the CSV and encode them in JSON format that the JavaScript can use&lt;br /&gt;
*Place the JavaScript code below in ths source of the text question&lt;br /&gt;
*Replace &amp;quot;QQ&amp;quot; with the ID of the text input question&lt;br /&gt;
*Replace &amp;quot;templates/yourTemplate/countries.php&amp;quot; with the path to the PHP file (from LimeSurvey root)&lt;br /&gt;
*This script will grab the jsonized data from the PHP file and load it into an array that the plugin can use&lt;br /&gt;
&lt;br /&gt;
PHP code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
   $countriesArr = array();&lt;br /&gt;
&lt;br /&gt;
   $file_handle = fopen(&amp;quot;countries2.csv&amp;quot;, &amp;quot;r&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
   while (!feof($file_handle) ) {&lt;br /&gt;
&lt;br /&gt;
       $line_of_text = fgetcsv($file_handle);&lt;br /&gt;
&lt;br /&gt;
       array_push($countriesArr, $line_of_text[0]);&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   fclose($file_handle);&lt;br /&gt;
&lt;br /&gt;
   echo json_encode($countriesArr);&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
JavaScript code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       var qID = QQ;&lt;br /&gt;
&lt;br /&gt;
       var url = &amp;quot;templates/yourTemplate/countries.php&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
       var countriesArr = new Array();&lt;br /&gt;
&lt;br /&gt;
       $.getJSON(url,function(data){&lt;br /&gt;
&lt;br /&gt;
           $(data).each(function(i, item){&lt;br /&gt;
&lt;br /&gt;
               countriesArr.push(item);&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qID+&#039; input.text&#039;).autocomplete(countriesArr, {&lt;br /&gt;
&lt;br /&gt;
               matchContains: true,&lt;br /&gt;
&lt;br /&gt;
               minChars: 0&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 1.91 and later versions==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.91+, IE 6/7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround uses the [http://jqueryui.com/demos/autocomplete/ Autocomplete widget] included with jQuery UI to provide a respondent a list of suggested answers that the they can select from as they type in a text input.&lt;br /&gt;
&lt;br /&gt;
Although the plugin allows for much more complex applications, the two that I use most frequently are outlined below. The first method uses a relatively small list of suggestions that is stored in an array locally. The second is a little more complex - it uses a remote CSV file of suggestions that is accessed through AJAX an PHP.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Both methods:&#039;&#039;&#039;&lt;br /&gt;
*Add the following styles to the end of your &#039;template.css&#039; file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;/* Autocomplete styles */&lt;br /&gt;
&lt;br /&gt;
ul.ui-autocomplete {&lt;br /&gt;
&lt;br /&gt;
   width: 250px !important;&lt;br /&gt;
&lt;br /&gt;
   padding: 5px 10px;&lt;br /&gt;
&lt;br /&gt;
   list-style: none;&lt;br /&gt;
&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Method 1 (use local JavaScript array for data):&#039;&#039;&#039;&lt;br /&gt;
*Create a text input question&lt;br /&gt;
*Add the following script to the source of the text question&lt;br /&gt;
*Replace &amp;quot;QQ&amp;quot; with the ID of the text input question&lt;br /&gt;
*Replace the states with your list of suggestions (comma separated)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       var q1ID = QQ;&lt;br /&gt;
&lt;br /&gt;
       var states = &amp;quot;Alabama,Alaska,Arizona,Arkansas,California,Colorado,Connecticut,Delaware,&lt;br /&gt;
&lt;br /&gt;
       District of Columbia,Florida,Georgia,Hawaii,Idaho,Illinois,Indiana,Iowa,Kansas,Kentucky,&lt;br /&gt;
&lt;br /&gt;
       Louisiana,Maine,Montana,Nebraska,Nevada,New Hampshire,New Jersey,New Mexico,New York,&lt;br /&gt;
&lt;br /&gt;
       North Carolina,North Dakota,Ohio,Oklahoma,Oregon,Maryland,Massachusetts,Michigan,&lt;br /&gt;
&lt;br /&gt;
       Minnesota,Mississippi,Missouri,Pennsylvania,Rhode Island,South Carolina,South Dakota,&lt;br /&gt;
&lt;br /&gt;
       Tennessee,Texas,Utah,Vermont,Virginia,Washington,West Virginia,Wisconsin,Wyoming&amp;quot;.split(&#039;,&#039;);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q1ID+&#039; input.text&#039;).autocomplete({&lt;br /&gt;
&lt;br /&gt;
           source: states&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Method 2 (use remote CSV file for data):&#039;&#039;&#039;&lt;br /&gt;
*Place the CSV file of suggestions in your template directory (you can download my demo CSV [http://www.partnersinc.biz/surveys/templates/default_autocompleting_input/countries2.csv here])&lt;br /&gt;
*Place a PHP file containing the code below in your template directory&lt;br /&gt;
*Replace &amp;quot;countries2.csv&amp;quot; with your CSV filename (you could make this more universal by passing the filename in the URL)&lt;br /&gt;
*This file will grab the contents of the CSV and encode them in JSON format that the JavaScript can use&lt;br /&gt;
*Place the JavaScript code below in ths source of the text question&lt;br /&gt;
*Replace &amp;quot;QQ&amp;quot; with the ID of the text input question&lt;br /&gt;
*Replace &amp;quot;templates/yourTemplate/countries.php&amp;quot; with the path to the PHP file (from LimeSurvey root)&lt;br /&gt;
*This script will grab the jsonized data from the PHP file and load it into an array that the plugin can use&lt;br /&gt;
&lt;br /&gt;
PHP code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
   $countriesArr = array();&lt;br /&gt;
&lt;br /&gt;
   $file_handle = fopen(&amp;quot;countries2.csv&amp;quot;, &amp;quot;r&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
   while (!feof($file_handle) ) {&lt;br /&gt;
&lt;br /&gt;
       $line_of_text = fgetcsv($file_handle);&lt;br /&gt;
&lt;br /&gt;
       array_push($countriesArr, $line_of_text[0]);&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   fclose($file_handle);&lt;br /&gt;
&lt;br /&gt;
   echo json_encode($countriesArr);&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
JavaScript code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
       $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       var qID = QQ;&lt;br /&gt;
&lt;br /&gt;
       var url = &amp;quot;templates/yourTemplate/countries.php&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
       var dataArr = [];&lt;br /&gt;
&lt;br /&gt;
       $.getJSON(url,function(data){&lt;br /&gt;
&lt;br /&gt;
           $.each(data,function(i, item){&lt;br /&gt;
&lt;br /&gt;
               dataArr.push(item);&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
          $(&#039;#question&#039;+qID+&#039; input.text&#039;).autocomplete({&lt;br /&gt;
&lt;br /&gt;
               source: dataArr&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Use autocomplete to populate several fields==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.91+, IE 7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround uses the [http://jqueryui.com/demos/autocomplete/ Autocomplete widget] included with jQuery UI and the [http://plugins.jquery.com/project/csv jquery.csv.js] plugin to provide a respondent with a list of suggested answers as they type in a text input and then to automatically populate other fields depending on the selection.&lt;br /&gt;
&lt;br /&gt;
For example, if you have 3 questions - &amp;quot;Name&amp;quot;, &amp;quot;ID&amp;quot; and &amp;quot;Email&amp;quot; - you can use this workaround to autocomplete the &amp;quot;Name&amp;quot; question and then the &amp;quot;ID&amp;quot; and &amp;quot;Email&amp;quot; questions can be automatically populated with values associated with the selected name.&lt;br /&gt;
*Download the [http://plugins.jquery.com/project/csv jquery.csv.js] plugin and place it in your template folder&lt;br /&gt;
*Add the following line to your startpage.pstpl BEFORE the tag for template.js&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;{TEMPLATEURL}jquery.csv.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
*Create your CSV file with 3 columns (name, ID, email) as in this example and place it in your template folder&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;Bob,    Bob&#039;s ID,    Bob&#039;s email&lt;br /&gt;
&lt;br /&gt;
Andy,    Andy&#039;s ID,    Andy&#039;s email&lt;br /&gt;
&lt;br /&gt;
Sam,    Sam&#039;s ID,    Sam&#039;s email&lt;br /&gt;
&lt;br /&gt;
Tony,    Tony&#039;s ID,    Tony&#039;s email&lt;br /&gt;
&lt;br /&gt;
Fred,    Fred&#039;s ID,    Fred&#039;s email&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
*Create your 3 questions - &amp;quot;Name&amp;quot;, &amp;quot;ID&amp;quot; and &amp;quot;Email&amp;quot;. They must be in the same group/page.&lt;br /&gt;
*Add the following styles to the end of your &#039;template.css&#039; file&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;/* Autocomplete styles */&lt;br /&gt;
&lt;br /&gt;
ul.ui-autocomplete {&lt;br /&gt;
&lt;br /&gt;
   width: 250px !important;&lt;br /&gt;
&lt;br /&gt;
   padding: 5px 10px;&lt;br /&gt;
&lt;br /&gt;
   list-style: none;&lt;br /&gt;
&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
*Add the following script to the source of one of the questions&lt;br /&gt;
*Replace:&lt;br /&gt;
**&amp;quot;NN&amp;quot; with the &amp;quot;Name&amp;quot; question ID&lt;br /&gt;
**&amp;quot;II&amp;quot; with the &amp;quot;ID&amp;quot; question ID&lt;br /&gt;
**&amp;quot;EE&amp;quot; with the &amp;quot;Email&amp;quot; question ID&lt;br /&gt;
*Modify the path to your CSV file&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       var qNameID = NN;&lt;br /&gt;
&lt;br /&gt;
       var qIDID = II;&lt;br /&gt;
&lt;br /&gt;
       var qEmailID = EE;&lt;br /&gt;
&lt;br /&gt;
       var url = &amp;quot;upload/templates/yourTemplate/yourCsvFile.csv&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
       // Create an array to hold the names&lt;br /&gt;
&lt;br /&gt;
       var namesArr = new Array();&lt;br /&gt;
&lt;br /&gt;
       // Grab the CSV contents&lt;br /&gt;
&lt;br /&gt;
       $.get(url,function(data){&lt;br /&gt;
&lt;br /&gt;
           // Convert CSV contents to an array of arrays&lt;br /&gt;
&lt;br /&gt;
           fullArray = jQuery.csv()(data);&lt;br /&gt;
&lt;br /&gt;
           // Load the names array&lt;br /&gt;
&lt;br /&gt;
           $(fullArray).each(function(i, item){&lt;br /&gt;
&lt;br /&gt;
               namesArr.push(item[0]);&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Initialise the autocomplete plugin&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qNameID+&#039; input.text&#039;).autocomplete({&lt;br /&gt;
&lt;br /&gt;
               source: namesArr,&lt;br /&gt;
&lt;br /&gt;
               // Event fired when a selection is made (ui.item.value refers to the selected item)&lt;br /&gt;
&lt;br /&gt;
               select: function(event, ui) {&lt;br /&gt;
&lt;br /&gt;
                   // Find the &amp;quot;ID&amp;quot; and &amp;quot;Email&amp;quot; values associated with the selected name value and load those questions&lt;br /&gt;
&lt;br /&gt;
                   $(fullArray).each(function(i, item){&lt;br /&gt;
&lt;br /&gt;
                       if(item[0] == ui.item.value) {&lt;br /&gt;
&lt;br /&gt;
                           // The value from column 2 of the CSV&lt;br /&gt;
&lt;br /&gt;
                           $(&#039;#question&#039;+qIDID+&#039; input.text&#039;).val(item[1]);&lt;br /&gt;
&lt;br /&gt;
                           // The value from column 3 of the CSV&lt;br /&gt;
&lt;br /&gt;
                           $(&#039;#question&#039;+qEmailID+&#039; input.text&#039;).val(item[2]);&lt;br /&gt;
&lt;br /&gt;
                       }&lt;br /&gt;
&lt;br /&gt;
                   });&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Drag and Drop Rankings=&lt;br /&gt;
&lt;br /&gt;
==Drag and Drop Ranking - Version 1.90 and newer==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+ &amp;amp; 1.91RC4, IE 6/7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround is a modification of the workaround below and also uses [http://jqueryui.com/demos/sortable/#connect-lists JQuery connected sortables]. Thanks to the author of that workaround.&lt;br /&gt;
&lt;br /&gt;
[[File:Untitled-12.png]]&lt;br /&gt;
&lt;br /&gt;
Modifications include:&lt;br /&gt;
*Allow for multiple drag-n-drop ranking questions on a page&lt;br /&gt;
*Handle minimum and maximum answers settings&lt;br /&gt;
*Allow double clicking of items to add or remove them from the ranking list&lt;br /&gt;
*Work with the new shipped jQuery UI&lt;br /&gt;
&lt;br /&gt;
There is a &#039;&#039;&#039;[http://www.partnersinc.biz/surveys//index.php?sid=36981&amp;amp;newtest;=Y&amp;amp;lang;=en demonstrated here]&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_ Set up your survey to use JavaScript].&lt;br /&gt;
#Place the large script below in your template.js file.&lt;br /&gt;
#Place the small script below in the source a ranking question, (this applies the &amp;quot;dragDropRank&amp;quot; function to the question). Replace &amp;quot;QQ&amp;quot; with the ranking [http://docs.limesurvey.org/SGQA+identifier&amp;amp;structure;=English+Instructions+for+LimeSurvey#General_Description question ID].&lt;br /&gt;
**Note: the LimeSurvey translations will be automatically used for the &amp;quot;Choices&amp;quot; and &amp;quot;Rankings&amp;quot; header labels but can be overridden with custom labels - see the example calls below.&lt;br /&gt;
#Insert the CSS below at the end of template.css (these styles are for the default template).&lt;br /&gt;
&lt;br /&gt;
NOTE: I have not tested this workaround with conditions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Code for template.js:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
function dragDropRank(qID, choiceText, rankText) {&lt;br /&gt;
&lt;br /&gt;
   if(!choiceText) {&lt;br /&gt;
&lt;br /&gt;
       choiceText = $(&#039;#question&#039;+qID+&#039; td.label label&#039;).text();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   if(!rankText) {&lt;br /&gt;
&lt;br /&gt;
       rankText = $(&#039;#question&#039;+qID+&#039; td.output tr:first td:eq(1)&#039;).text();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   //Add a class to the question&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#question&#039;+qID+&#039;&#039;).addClass(&#039;dragDropRanking&#039;);&lt;br /&gt;
&lt;br /&gt;
   // Hide the original question in LimeSurvey (so that we can replace with drag and drop)&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#question&#039;+qID+&#039; .rank, #question&#039;+qID+&#039; .questionhelp&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
   // Turn off display of question (to override error checking built into LimeSurvey ranking question)&lt;br /&gt;
&lt;br /&gt;
   //$(&#039;#display&#039;+qID).val(&#039;off&#039;);&lt;br /&gt;
&lt;br /&gt;
   // Add connected sortables elements to the question&lt;br /&gt;
&lt;br /&gt;
   var htmlCode = &#039;&amp;lt;table class=&amp;quot;dragDropTable&amp;quot;&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
       &amp;lt;tbody&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
           &amp;lt;tr&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
               &amp;lt;td&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                   &amp;lt;span class=&amp;quot;dragDropHeader choicesLabel&amp;quot;&amp;gt;&#039;+choiceText+&#039;&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                   &amp;lt;div class=&amp;quot;ui-state-highlight dragDropChoices&amp;quot;&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                       &amp;lt;ul id=&amp;quot;sortable1&#039;+qID+&#039;&amp;quot; class=&amp;quot;connectedSortable&#039;+qID+&#039; dragDropChoiceList&amp;quot;&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                           &amp;lt;li&amp;gt;Choices&amp;lt;/li&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                       &amp;lt;/ul&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                   &amp;lt;/div&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
               &amp;lt;/td&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
               &amp;lt;td&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                   &amp;lt;span class=&amp;quot;dragDropHeader rankingLabel&amp;quot;&amp;gt;&#039;+rankText+&#039;&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                   &amp;lt;div class=&amp;quot;ui-state-highlight dragDropRanks&amp;quot;&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                       &amp;lt;ol id=&amp;quot;sortable2&#039;+qID+&#039;&amp;quot; class=&amp;quot;connectedSortable&#039;+qID+&#039; dragDropRankList&amp;quot;&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                           &amp;lt;li&amp;gt;Ranks&amp;lt;/li&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                       &amp;lt;/ol&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                   &amp;lt;/div&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
               &amp;lt;/td&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
           &amp;lt;/tr&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
       &amp;lt;/tbody&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                   &amp;lt;/table&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
   $(htmlCode).insertAfter(&#039;#question&#039;+qID+&#039; table.rank&#039;);&lt;br /&gt;
&lt;br /&gt;
   // Remove placeholder list items (have to have one item so that LimeSurvey doesn&amp;quot;t remove the &amp;lt;ul&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#sortable1&#039;+qID+&#039; li, #sortable2&#039;+qID+&#039; li&#039;).remove();&lt;br /&gt;
&lt;br /&gt;
   // Load any previously-set values&lt;br /&gt;
&lt;br /&gt;
   loadDragDropRank(qID);&lt;br /&gt;
&lt;br /&gt;
   // Find the number of LimeSurvey ranking inputs (&amp;quot;Maximum answers&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
   var maxAnswer = $(&#039;#question&#039;+qID+&#039; td.output input.text&#039;).length;&lt;br /&gt;
&lt;br /&gt;
   // Set up the connected sortable&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#sortable1&#039;+qID+&#039;, #sortable2&#039;+qID+&#039;&#039;).sortable({&lt;br /&gt;
&lt;br /&gt;
       connectWith: &#039;.connectedSortable&#039;+qID+&#039;&#039;,&lt;br /&gt;
&lt;br /&gt;
       placeholder: &#039;ui-sortable-placeholder&#039;,&lt;br /&gt;
&lt;br /&gt;
       helper: &#039;clone&#039;,&lt;br /&gt;
&lt;br /&gt;
       revert: 50,&lt;br /&gt;
&lt;br /&gt;
       receive: function(event, ui) {&lt;br /&gt;
&lt;br /&gt;
           if($(&#039;#sortable2&#039;+qID+&#039; li&#039;).length &amp;gt; maxAnswer) {&lt;br /&gt;
&lt;br /&gt;
               alert (&#039;You can only rank a maximum of &#039;+maxAnswer+&#039; choices.&#039;);&lt;br /&gt;
&lt;br /&gt;
               $(ui.sender).sortable(&#039;cancel&#039;);&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       },&lt;br /&gt;
&lt;br /&gt;
       stop: function(event, ui) {&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#sortable1&#039;+qID+&#039;&#039;).sortable(&#039;refresh&#039;);&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#sortable2&#039;+qID+&#039;&#039;).sortable(&#039;refresh&#039;);&lt;br /&gt;
&lt;br /&gt;
           updateDragDropRank(qID);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   }).disableSelection();&lt;br /&gt;
&lt;br /&gt;
   // Get the list of choices from the LimeSurvey question and copy them as items into the sortable choices list&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#CHOICES_&#039; + qID).children().each(function(index, Element) {&lt;br /&gt;
&lt;br /&gt;
       var liCode = &#039;&amp;lt;li class=&amp;quot;ui-state-default&amp;quot; id=&amp;quot;choice_&#039; + $(this).attr(&amp;quot;value&amp;quot;) + &#039;&amp;quot;&amp;gt;&#039; + this.text + &#039;&amp;lt;/li&amp;gt;&#039;&lt;br /&gt;
&lt;br /&gt;
       $(liCode).appendTo(&#039;#sortable1&#039;+qID+&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   // Allow users to double click to move to selections from list to list&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#sortable1&#039;+qID+&#039; li&#039;).live(&#039;dblclick&#039;, function() {&lt;br /&gt;
&lt;br /&gt;
       if($(&#039;#sortable2&#039;+qID+&#039; li&#039;).length == maxAnswer) {&lt;br /&gt;
&lt;br /&gt;
           alert (&#039;You can only rank a maximum of &#039;+maxAnswer+&#039; choices.&#039;);&lt;br /&gt;
&lt;br /&gt;
           return false;&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       else {&lt;br /&gt;
&lt;br /&gt;
           $(this).appendTo(&#039;#sortable2&#039;+qID+&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#sortable1&#039;+qID+&#039;&#039;).sortable(&#039;refresh&#039;);&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#sortable2&#039;+qID+&#039;&#039;).sortable(&#039;refresh&#039;);&lt;br /&gt;
&lt;br /&gt;
           updateDragDropRank(qID);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#sortable2&#039;+qID+&#039; li&#039;).live(&#039;dblclick&#039;, function() {&lt;br /&gt;
&lt;br /&gt;
       $(this).appendTo(&#039;#sortable1&#039;+qID+&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#sortable2&#039;+qID+&#039;&#039;).sortable(&#039;refresh&#039;);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#sortable1&#039;+qID+&#039;&#039;).sortable(&#039;refresh&#039;);&lt;br /&gt;
&lt;br /&gt;
       updateDragDropRank(qID);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// This function copies the drag and drop sortable data into the LimeSurvey ranking list.&lt;br /&gt;
&lt;br /&gt;
function updateDragDropRank(qID)&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   // Reload the LimeSurvey choices select element&lt;br /&gt;
&lt;br /&gt;
   var rankees = [];&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#sortable2&#039;+qID+&#039; li&#039;).each(function(index) {&lt;br /&gt;
&lt;br /&gt;
       $(this).attr(&#039;value&#039;, index+1);&lt;br /&gt;
&lt;br /&gt;
       // Get value of ranked item&lt;br /&gt;
&lt;br /&gt;
       var liID = $(this).attr(&amp;quot;id&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
       liIDArray = liID.split(&#039;_&#039;);&lt;br /&gt;
&lt;br /&gt;
       // Save to an array&lt;br /&gt;
&lt;br /&gt;
       rankees[rankees.length] = { &amp;quot;r_name&amp;quot;:$(this).text(),&amp;quot;r_value&amp;quot;:liIDArray[1] };&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#question&#039;+qID+&#039; input[name&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&amp;quot;RANK_&amp;quot;]&#039;).each(function(index) {&lt;br /&gt;
&lt;br /&gt;
       if (rankees.length &amp;gt; index) {&lt;br /&gt;
&lt;br /&gt;
           $(this).val(rankees[index].r_name);&lt;br /&gt;
&lt;br /&gt;
           //alert (rankees[index].r_value);&lt;br /&gt;
&lt;br /&gt;
           $(this).next(&#039;input&#039;).attr(&#039;value&#039;, rankees[index].r_value);&lt;br /&gt;
&lt;br /&gt;
       } else {&lt;br /&gt;
&lt;br /&gt;
           $(this).val(&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
           $(this).next().val(&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
     });&lt;br /&gt;
&lt;br /&gt;
   // Reload the LimeSurvey choices select element (we need this for &amp;quot;Minimum answers&amp;quot; code)&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#question&#039;+qID+&#039; td.label select option&#039;).remove();&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#sortable1&#039;+qID+&#039; li&#039;).each(function(index) {&lt;br /&gt;
&lt;br /&gt;
       var liText = $(this).text();&lt;br /&gt;
&lt;br /&gt;
       var liID = $(this).attr(&#039;id&#039;);&lt;br /&gt;
&lt;br /&gt;
       liIDArray = liID.split(&#039;_&#039;);&lt;br /&gt;
&lt;br /&gt;
       var optionCode = &#039;&amp;lt;option value=&amp;quot;&#039;+liIDArray[1]+&#039;&amp;quot;&amp;gt;&#039;+liText+&#039;&amp;lt;/option&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
       $(optionCode).appendTo(&#039;#question&#039;+qID+&#039; td.label select&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   // Hack for IE6&lt;br /&gt;
&lt;br /&gt;
   if ($.browser.msie &amp;amp;&amp;amp; $.browser.version.substr(0,1)&amp;lt;7) {&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+qID+&#039; select&#039;).show();&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+qID+&#039; select&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// This function is called on page load to see if there are any items already ranked (from a previous visit&lt;br /&gt;
&lt;br /&gt;
// or cached due to a page change.  If so, the already-ranked items are loaded into the sortable list&lt;br /&gt;
&lt;br /&gt;
function loadDragDropRank(qID)&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   var rankees = [];&lt;br /&gt;
&lt;br /&gt;
   // Loop through each item in the built-in LimeSurvey ranking list looking for non-empty values&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#question&#039;+qID+&#039; input[name&amp;lt;/div&amp;gt;=&amp;quot;RANK_&amp;quot;]&#039;).each(function(index) {&lt;br /&gt;
&lt;br /&gt;
       // Check to see if the current item has a value&lt;br /&gt;
&lt;br /&gt;
       if ($(this).val()) {&lt;br /&gt;
&lt;br /&gt;
           // Item has a value - save to the array&lt;br /&gt;
&lt;br /&gt;
           // Use this element to contain the name and the next for the value (numeric)&lt;br /&gt;
&lt;br /&gt;
           rankees[rankees.length] = { &amp;quot;r_name&amp;quot;:$(this).val(),&amp;quot;r_value&amp;quot;:$(this).next().val() };&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   // Now that we have a list of all the pre-ranked items, populate the sortable list&lt;br /&gt;
&lt;br /&gt;
   // Note that the items *won&amp;quot;t* appear in the main list because LimeSurvey has removed them.&lt;br /&gt;
&lt;br /&gt;
   $.each(rankees, function(index, value) {&lt;br /&gt;
&lt;br /&gt;
       // Create the items in the sortable&lt;br /&gt;
&lt;br /&gt;
       var liCode = &#039;&amp;lt;li class=&amp;quot;ui-state-default&amp;quot; id=&amp;quot;choice_&#039; + value.r_value + &#039;&amp;quot;&amp;gt;&#039; + value.r_name + &#039;&amp;lt;/li&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
       $(liCode).appendTo(&#039;#sortable2&#039;+qID+&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Code in the source of the question(s) using the LimeSurvey translations for the &amp;quot;Choices&amp;quot; and &amp;quot;Rankings&amp;quot; element header labels&#039;&#039;&#039; (replace &amp;quot;QQ&amp;quot; with the ranking [http://docs.limesurvey.org/SGQA+identifier&amp;amp;structure;=English+Instructions+for+LimeSurvey#General_Description question ID]):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       dragDropRank(QQ);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Code in the source of the question(s) using custom text for the &amp;quot;Choices&amp;quot; and &amp;quot;Rankings&amp;quot; element header labels&#039;&#039;&#039; (replace &amp;quot;QQ&amp;quot; with the ranking [http://docs.limesurvey.org/SGQA+identifier&amp;amp;structure;=English+Instructions+for+LimeSurvey#General_Description question ID]):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       dragDropRank(QQ, &#039;Custom Choices Label&#039;, &#039;Custom Rankings Label&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Styles for template.css:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* Drag-n-drop ranking styles */&lt;br /&gt;
&lt;br /&gt;
.dragDropTable {&lt;br /&gt;
&lt;br /&gt;
   border: 0 none;&lt;br /&gt;
&lt;br /&gt;
   border-collapse: collapse;&lt;br /&gt;
&lt;br /&gt;
   width: 100%;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.dragDropTable td {&lt;br /&gt;
&lt;br /&gt;
   vertical-align: top;&lt;br /&gt;
&lt;br /&gt;
   width: 50%;&lt;br /&gt;
&lt;br /&gt;
   padding-right: 20px;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.dragDropTable .dragDropHeader {&lt;br /&gt;
&lt;br /&gt;
   font-weight: bold;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.dragDropTable .dragDropChoices,&lt;br /&gt;
&lt;br /&gt;
.dragDropTable .dragDropRanks {&lt;br /&gt;
&lt;br /&gt;
   margin: 5px 0 0 0;&lt;br /&gt;
&lt;br /&gt;
   background: transparent none;&lt;br /&gt;
&lt;br /&gt;
   border: 0 none;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.dragDropTable .dragDropChoiceList,&lt;br /&gt;
&lt;br /&gt;
.dragDropTable .dragDropRankList {&lt;br /&gt;
&lt;br /&gt;
   float: left;&lt;br /&gt;
&lt;br /&gt;
   width: 100%;&lt;br /&gt;
&lt;br /&gt;
   min-height: 2.4em;&lt;br /&gt;
&lt;br /&gt;
   _height: 2.4em; /* IE6 and below hack */&lt;br /&gt;
&lt;br /&gt;
   margin: 0;&lt;br /&gt;
&lt;br /&gt;
   padding: 0;&lt;br /&gt;
&lt;br /&gt;
   list-style-type: none;&lt;br /&gt;
&lt;br /&gt;
   background: #FBFBFB none;&lt;br /&gt;
&lt;br /&gt;
   border: 1px solid #CCCCCC;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.dragDropTable .dragDropChoiceList li,&lt;br /&gt;
&lt;br /&gt;
.dragDropTable .dragDropRankList li {&lt;br /&gt;
&lt;br /&gt;
   margin: 3px;&lt;br /&gt;
&lt;br /&gt;
   *margin-left: -13px; /* IE7 and below */&lt;br /&gt;
&lt;br /&gt;
   padding: 3px;&lt;br /&gt;
&lt;br /&gt;
   min-height: 1.3em;&lt;br /&gt;
&lt;br /&gt;
   _height: 1.3em; /* IE6 and below hack */&lt;br /&gt;
&lt;br /&gt;
   font-weight: normal;&lt;br /&gt;
&lt;br /&gt;
   cursor: move;&lt;br /&gt;
&lt;br /&gt;
   display: block; /* Force the li to full width */&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Drag and Drop Ranking using Images - Version 1.90 and newer==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+ &amp;amp; 1.91RC4, IE 6/7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround works in conjunction with the above workaround to allow ranking of images.&lt;br /&gt;
&lt;br /&gt;
[[File:Untitled-11.png]]&lt;br /&gt;
&lt;br /&gt;
There is a &#039;&#039;&#039;[http://www.partnersinc.biz/surveys//index.php?sid=36981&amp;amp;newtest;=Y&amp;amp;lang;=en demonstrated here]&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
&lt;br /&gt;
1) Follow the above workaround to get basic drag-n-drop functionality in your ranking question.&lt;br /&gt;
&lt;br /&gt;
2) Insert your images in the ranking question text or help section after any text that you wish to have there (we&#039;ll move them later with JavaScript).&lt;br /&gt;
&lt;br /&gt;
3) Give the images &#039;&#039;&#039;EXACTLY&#039;&#039;&#039; the same IDs as the answer code you would like them to be associated with:[[File:Untitled-8.png]]&lt;br /&gt;
&lt;br /&gt;
4) Place the first script below in your template.js file.&lt;br /&gt;
&lt;br /&gt;
5) Place the second script below in the source the ranking question &#039;&#039;&#039;AFTER&#039;&#039;&#039; the initial call for the dragDropRank function from the workaround above. Replace &amp;quot;QQ&amp;quot; with the ID of the ranking question (this applies the &amp;quot;dragDropRankImages&amp;quot; function to the question).&lt;br /&gt;
&lt;br /&gt;
6) Insert the CSS below at the end of template.css. Replace &amp;quot;11&amp;quot; with your question ID. These styles are for the default template using 50x50px images (as in the demo) and may need to be modified for other templates or image sizes.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Code for template.js:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
function dragDropRankImages(qID) {&lt;br /&gt;
&lt;br /&gt;
   $(&#039;.connectedSortable&#039;+qID+&#039; li&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
       // Remove any text in the sortable choice or rank items&lt;br /&gt;
&lt;br /&gt;
       $(this).text(&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
       // Move the images into the appropriate sortable list item&lt;br /&gt;
&lt;br /&gt;
       var liID = $(this).attr(&#039;id&#039;);&lt;br /&gt;
&lt;br /&gt;
       liIDArray = liID.split(&#039;_&#039;);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+qID+&#039; img#&#039;+liIDArray[1]+&#039;&#039;).appendTo(this);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Code in the source of the question(s):&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       dragDropRankImages(QQ);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Styles for template.css:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* Drag-n-drop for ranking images */&lt;br /&gt;
#question11 .dragDropTable {&lt;br /&gt;
&lt;br /&gt;
   width: auto;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
#question11 .dragDropTable .dragDropChoiceList,&lt;br /&gt;
#question11 .dragDropTable .dragDropRankList {&lt;br /&gt;
&lt;br /&gt;
   min-height: 60px;&lt;br /&gt;
&lt;br /&gt;
   _height: 60px; /* IE6 and below hack */&lt;br /&gt;
&lt;br /&gt;
   width: auto;&lt;br /&gt;
&lt;br /&gt;
   min-width: 60px;&lt;br /&gt;
&lt;br /&gt;
   _width: 60px; /* IE6 and below hack */&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
#question11 .dragDropTable li {&lt;br /&gt;
&lt;br /&gt;
   background: 0 none;&lt;br /&gt;
&lt;br /&gt;
   border: 0 none;&lt;br /&gt;
&lt;br /&gt;
   height: 50px;&lt;br /&gt;
&lt;br /&gt;
   width: 50px;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
#question11 .dragDropTable li img {&lt;br /&gt;
&lt;br /&gt;
   margin: 0;&lt;br /&gt;
&lt;br /&gt;
   padding: 0;&lt;br /&gt;
&lt;br /&gt;
   border: 0 none;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Drag and Drop Ranking for iPad - Version 1.91 and newer==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: LimeSurvey 1.91, iPad 2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround extends the above workarounds to work with the touch interface on iPads.&lt;br /&gt;
&lt;br /&gt;
1) Follow the &amp;quot;[http://docs.limesurvey.org/Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#Drag_and_Drop_Ranking_-_Version_1.90_and_newer Drag and Drop Ranking - Version 1.90 and newer]&amp;quot; workaround above to get basic drag-n-drop functionality in your ranking question.&lt;br /&gt;
&lt;br /&gt;
2) Download the [https://github.com/furf/jquery-ui-touch-punch jQuery.ui.touch-punch.js plugin] and save it in your template directory.&lt;br /&gt;
&lt;br /&gt;
3) Replace this line in your startpage.pstpl:&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;{TEMPLATEURL}template.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;With this:&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;{TEMPLATEURL}jquery.ui.touch-punch.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;{TEMPLATEURL}template.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Drag and Drop Ranking - Version 1.86==&lt;br /&gt;
&lt;br /&gt;
Tested with 1.86 on IE 7,8, FireFox 3, Chrome, and Safari 4&lt;br /&gt;
&lt;br /&gt;
This workaround uses [http://jqueryui.com/demos/sortable/#connect-lists JQuery connected sortables] to modify a ranking question and allow the survey taker to drag and drop choices instead of clicking.  The nice thing is that the choices can be easily re-arranged or removed from the ranking, all by drag and drop.&lt;br /&gt;
&lt;br /&gt;
I used it for a voting application and some of the element names reflect that use.&lt;br /&gt;
&lt;br /&gt;
It looks best when some CSS is added to control the appearance of the boxers around each choice.&lt;br /&gt;
&lt;br /&gt;
[[File:drag-n-drop.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   // Question ID global variable&lt;br /&gt;
&lt;br /&gt;
    var questionID;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Grab the question ID[[File:drag-n-drop.png]]&lt;br /&gt;
&lt;br /&gt;
       // This is something with a class of &amp;quot;ranking&amp;quot; and an ID that starts with &amp;quot;questionXXXXX&amp;quot;.  The X&#039;s represent the question ID&lt;br /&gt;
&lt;br /&gt;
       var entire_questionID = $(&amp;quot;.ranking[id&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&#039;question&#039;]&amp;quot;).attr(&#039;id&#039;);&lt;br /&gt;
&lt;br /&gt;
       // Get just the question number (ID)&lt;br /&gt;
&lt;br /&gt;
       var patt=/\d+$/;&lt;br /&gt;
&lt;br /&gt;
       questionID=patt.exec(entire_questionID);&lt;br /&gt;
&lt;br /&gt;
       // Hide the original quetion in LimeSurvey (so that we can replace with drag and drop)&lt;br /&gt;
&lt;br /&gt;
       $(&amp;quot;.rank, .questionhelp&amp;quot;).hide();&lt;br /&gt;
&lt;br /&gt;
       // Turn off display of question (to override error checking built into LimeSurvey ranking question)&lt;br /&gt;
&lt;br /&gt;
       $(&amp;quot;#display&amp;quot;+questionID).val(&amp;quot;off&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
       // Add connected sortables to the question&lt;br /&gt;
&lt;br /&gt;
       var html_code = &amp;quot;&amp;lt;table style=&#039;border: medium none ; width: 770px; margin-left: auto; \&lt;br /&gt;
&lt;br /&gt;
                                margin-right: auto;&#039;&amp;gt;&amp;lt;tbody&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td style=&#039;width: 590px; vertical-align: top;&#039;&amp;gt;&amp;lt;h3&amp;gt;List of Candidates:&amp;lt;/h3&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
               &amp;lt;div class=&#039;ui-state-highlight&#039; style=&#039;margin: 5px; float: left;&#039; id=&#039;ballot_list&#039;&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                               &amp;lt;ul id=&#039;sortable1&#039; class=&#039;connectedSortable&#039;&amp;gt;&amp;lt;li&amp;gt;Candidates&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/td&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
               &amp;lt;td style=&#039;vertical-align: top;&#039;&amp;gt;&amp;lt;h3&amp;gt;Your selections:&amp;lt;/h3&amp;gt;&amp;lt;div class=&#039;ui-state-highlight&#039; \&lt;br /&gt;
&lt;br /&gt;
                               style=&#039;margin: 5px; float: left;&#039; id=&#039;voting_selections&#039;&amp;gt;&amp;lt;ol id=&#039;sortable2&#039; class=&#039;connectedSortable&#039;&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
               &amp;lt;li&amp;gt;Voting Area&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/tbody&amp;gt;&amp;lt;/table&amp;gt;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
       $(html_code).appendTo(&amp;quot;#question&amp;quot; + questionID);&lt;br /&gt;
&lt;br /&gt;
       // Remove list items (have to have one item so that LimeSurvey doesn&#039;t remove the &amp;lt;ul&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
       $(&amp;quot;#sortable1 li, #sortable2 li&amp;quot;).remove();&lt;br /&gt;
&lt;br /&gt;
       // Load any previously-set values&lt;br /&gt;
&lt;br /&gt;
       loadRanking();&lt;br /&gt;
&lt;br /&gt;
       // Load jQuery UI&lt;br /&gt;
&lt;br /&gt;
       $.getScript(&amp;quot;/scripts/jquery/jquery-ui.js&amp;quot;, function() {&lt;br /&gt;
&lt;br /&gt;
           // After JQuery UI finishes loading, set up the connected sortable.&lt;br /&gt;
&lt;br /&gt;
           $(&amp;quot;#sortable1, #sortable2&amp;quot;).sortable({&lt;br /&gt;
&lt;br /&gt;
               connectWith: &#039;.connectedSortable&#039;,&lt;br /&gt;
&lt;br /&gt;
               placeholder: &#039;ui-sortable-placeholder&#039;,&lt;br /&gt;
&lt;br /&gt;
               stop: function(event, ui) {&lt;br /&gt;
&lt;br /&gt;
                   $(&amp;quot;#sortable1&amp;quot;).sortable(&amp;quot;refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                   $(&amp;quot;#sortable2&amp;quot;).sortable(&amp;quot;refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                   updateRanking();&lt;br /&gt;
&lt;br /&gt;
                   }&lt;br /&gt;
&lt;br /&gt;
           }).disableSelection();&lt;br /&gt;
&lt;br /&gt;
           // Get the list of candidates from the built-in LimeSurvey question and copy them as items in sortable1&lt;br /&gt;
&lt;br /&gt;
           $(&amp;quot;#CHOICES_&amp;quot; + questionID).children().each(function(index, Element) {&lt;br /&gt;
&lt;br /&gt;
               li_tag = &amp;quot;&amp;lt;li class=&#039;ui-state-default&#039; id=&#039;choice_&amp;quot; + $(this).attr(&#039;value&#039;) + &amp;quot;&#039;&amp;gt;&amp;quot; + this.text + &amp;quot;&amp;lt;/li&amp;gt;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
               $(li_tag).appendTo(&amp;quot;#sortable1&amp;quot;); }    );&lt;br /&gt;
&lt;br /&gt;
           // Make sure the submit button is showing&lt;br /&gt;
&lt;br /&gt;
           $(&amp;quot;:submit[value|=&#039; Submit&#039;]&amp;quot;).show();&lt;br /&gt;
&lt;br /&gt;
           // Show a confirmation alert upon submit&lt;br /&gt;
&lt;br /&gt;
           $(&amp;quot;form&amp;quot;).submit(function() {&lt;br /&gt;
&lt;br /&gt;
               // Override the built-in &amp;quot;disable navigation buttons&amp;quot; feature&lt;br /&gt;
&lt;br /&gt;
               $(&#039;#moveprevbtn, #movenextbtn, #movesubmitbtn&#039;).attr(&#039;disabled&#039;, &#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
               var validated = confirm(&amp;quot;Cast your ballot now?&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
               if (validated) { return true; } else { return false; }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Allow users to double click to move to selection list&lt;br /&gt;
&lt;br /&gt;
           $(&amp;quot;#sortable1 li&amp;quot;).assignDblClick();&lt;br /&gt;
&lt;br /&gt;
       });  // End of JQuery UI loading&lt;br /&gt;
&lt;br /&gt;
   }); // End of JQuery ready function&lt;br /&gt;
&lt;br /&gt;
// Define the actions when an item is double clicked&lt;br /&gt;
&lt;br /&gt;
$.fn.assignDblClick = function()&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   $(this).dblclick(function(){&lt;br /&gt;
&lt;br /&gt;
       $(this).appendTo(&#039;#sortable2&#039;);&lt;br /&gt;
&lt;br /&gt;
       $(&amp;quot;#sortable1&amp;quot;).sortable(&amp;quot;refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
       $(&amp;quot;#sortable2&amp;quot;).sortable(&amp;quot;refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
       updateRanking();&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// This function copies the drag and drop sortable data into the standard LimeSurvey ranking structure.&lt;br /&gt;
&lt;br /&gt;
function updateRanking()&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   var rankees = [];&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#sortable2 li&#039;).each(function(index) {&lt;br /&gt;
&lt;br /&gt;
   $(this).attr(&amp;quot;value&amp;quot;, index+1);&lt;br /&gt;
&lt;br /&gt;
       // Get value of person&lt;br /&gt;
&lt;br /&gt;
       li_tag = $(this).attr(&#039;id&#039;);&lt;br /&gt;
&lt;br /&gt;
       li_tag_array = li_tag.split(&amp;quot;_&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
       // Save to an array&lt;br /&gt;
&lt;br /&gt;
       rankees[rankees.length] = { &#039;r_name&#039;:$(this).text(),&#039;r_value&#039;:li_tag_array[1] };&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   $(&amp;quot;input[name&amp;lt;/div&amp;gt;=&#039;RANK_&#039;]&amp;quot;).each(function(index) {&lt;br /&gt;
&lt;br /&gt;
       if (rankees.length &amp;gt; index) {&lt;br /&gt;
&lt;br /&gt;
           $(this).val(rankees[index].r_name);&lt;br /&gt;
&lt;br /&gt;
           $(this).next().val(rankees[index].r_value);&lt;br /&gt;
&lt;br /&gt;
       } else {&lt;br /&gt;
&lt;br /&gt;
           $(this).val(&amp;quot;&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
           $(this).next().val(&amp;quot;&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
     });&lt;br /&gt;
&lt;br /&gt;
   // Re-assign double click action to first list items and remove&lt;br /&gt;
&lt;br /&gt;
   // double click action from section list items&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#sortable1 li&#039;).unbind(&#039;dblclick&#039;).assignDblClick();&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#sortable2 li&#039;).unbind(&#039;dblclick&#039;);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// This function is called on page load to see if there are any items already ranked (from a previous visit&lt;br /&gt;
&lt;br /&gt;
// or cached due to a page change.  If so, the already-ranked items are loaded into the sortable list&lt;br /&gt;
&lt;br /&gt;
function loadRanking()&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   var rankees = [];&lt;br /&gt;
&lt;br /&gt;
   // Loop through each item in the built-in LimeSurvey ranking list looking for non-empty values&lt;br /&gt;
&lt;br /&gt;
   $(&amp;quot;input[name&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&#039;RANK_&#039;]&amp;quot;).each(function(index) {&lt;br /&gt;
&lt;br /&gt;
       // Check to see if the current item has a value&lt;br /&gt;
&lt;br /&gt;
       if ($(this).val()) {&lt;br /&gt;
&lt;br /&gt;
           // Item has a value - save to the array&lt;br /&gt;
&lt;br /&gt;
           // Use this element to contain the name and the next for the value (numeric)&lt;br /&gt;
&lt;br /&gt;
           rankees[rankees.length] = { &#039;r_name&#039;:$(this).val(),&#039;r_value&#039;:$(this).next().val() };&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   // Now that we have a list of all the pre-ranked items, populate the sortable list&lt;br /&gt;
&lt;br /&gt;
   // Note that the items *won&#039;t* appear in the main list because LimeSurvey has removed them.&lt;br /&gt;
&lt;br /&gt;
   $.each(rankees, function(index, value) {&lt;br /&gt;
&lt;br /&gt;
       // Create the items in the sortable&lt;br /&gt;
&lt;br /&gt;
       li_tag = &amp;quot;&amp;lt;li class=&#039;ui-state-default&#039; id=&#039;choice_&amp;quot; + value.r_value + &amp;quot;&#039;&amp;gt;&amp;quot; + value.r_name + &amp;quot;&amp;lt;/li&amp;gt;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
       $(li_tag).appendTo(&amp;quot;#sortable2&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Create MaxDiff question type=&lt;br /&gt;
&lt;br /&gt;
See the &amp;quot;[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Question+design%2C+layout+and+templating&amp;amp;structure;=English+Instructions+for+LimeSurvey Question design, layout and templating]&amp;quot; section for a workaround that uses JavaScript to convert an &#039;&#039;&#039;&#039;&#039;Array (flexible labels) by column&#039;&#039;&#039;&#039;&#039; question into a [http://en.wikipedia.org/wiki/MaxDiff MaxDiff] question type.&lt;br /&gt;
&lt;br /&gt;
[[File:max_diff_596x253.gif]]&lt;br /&gt;
&lt;br /&gt;
=In a checkbox matrix, have the &#039;none&#039; option in a row disable all other columns in that row=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: Limesurvey 1.90+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The questionId parameter is the base ID of the question matrix (multiflexible).&lt;br /&gt;
&lt;br /&gt;
numColumns and numRows speak for themselves&lt;br /&gt;
&lt;br /&gt;
specialColumns is an array of the columns that have the special ability that when one of them&lt;br /&gt;
&lt;br /&gt;
is checked, none of the others can be checked. E.g., a &#039;none of these&#039; and/or a &#039;do now know&#039; option.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
numColumns=13;&lt;br /&gt;
&lt;br /&gt;
numRows=18;&lt;br /&gt;
&lt;br /&gt;
questionId=&#039;28417X2X24&#039;;&lt;br /&gt;
&lt;br /&gt;
specialColumns=[1,12,13];&lt;br /&gt;
&lt;br /&gt;
function action(obj){&lt;br /&gt;
&lt;br /&gt;
   locator=obj.id.replace(&#039;cbox_&#039;+questionId, &#039;&#039;).split(&#039;_&#039;);&lt;br /&gt;
&lt;br /&gt;
   row=locator[0];&lt;br /&gt;
&lt;br /&gt;
   column=locator[1];&lt;br /&gt;
&lt;br /&gt;
   //alert(&#039;Action for row,column=&#039;+row+&#039;,&#039;+column);&lt;br /&gt;
&lt;br /&gt;
   my_id=&#039;#cbox_&#039;+questionId+row+&#039;_&#039;+column+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
   if($(my_id).attr(&#039;checked&#039;) == false) {&lt;br /&gt;
&lt;br /&gt;
       for( var i=1; i&amp;lt;=numColumns; i++ ) {&lt;br /&gt;
&lt;br /&gt;
           if(i==column) continue;&lt;br /&gt;
&lt;br /&gt;
           id=&#039;#cbox_&#039;+questionId+row+&#039;_&#039;+i&lt;br /&gt;
&lt;br /&gt;
           $(id).attr(&#039;disabled&#039;,false);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   } else {&lt;br /&gt;
&lt;br /&gt;
       for( var i=1; i&amp;lt;=numColumns; i++ ) {&lt;br /&gt;
&lt;br /&gt;
           if(i==column) continue;&lt;br /&gt;
&lt;br /&gt;
           id=&#039;#cbox_&#039;+questionId+row+&#039;_&#039;+i&lt;br /&gt;
&lt;br /&gt;
           aid=&#039;#answer&#039;+questionId+row+&#039;_&#039;+i&lt;br /&gt;
&lt;br /&gt;
           $(aid).val(0);&lt;br /&gt;
&lt;br /&gt;
           $(id).attr(&#039;checked&#039;,false);&lt;br /&gt;
&lt;br /&gt;
           $(id).attr(&#039;disabled&#039;,true);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function customOnLoad(){&lt;br /&gt;
&lt;br /&gt;
   for( var row=1; row&amp;lt;=numRows; row++ ) {&lt;br /&gt;
&lt;br /&gt;
       for( var k=0; k&amp;lt;specialColumns.length; k++ )&lt;br /&gt;
&lt;br /&gt;
       {&lt;br /&gt;
&lt;br /&gt;
           column=specialColumns[k];&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#cbox_&#039;+questionId+row+&#039;_&#039;+column).change(function() {&lt;br /&gt;
&lt;br /&gt;
               action(this);&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
jQuery(document).ready(&lt;br /&gt;
&lt;br /&gt;
   function(){&lt;br /&gt;
&lt;br /&gt;
   customOnLoad();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Last Option In Array (Numbers) (Checkboxes) Row Excludes All Others=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround uses JavaScript/jQuery to make the last option of each Array (Numbers) (Checkboxes) row exclude all other options in the same row.&lt;br /&gt;
&lt;br /&gt;
The script will uncheck all options in a row if the last option is checked and uncheck the last option in a row if any other options are checked.&lt;br /&gt;
&lt;br /&gt;
It&#039;s [http://www.partnersinc.biz/surveys//index.php?sid=22532&amp;amp;newtest;=Y&amp;amp;lang;=en demonstrated here].&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_ Set up your survey to use JavaScript].&lt;br /&gt;
#Place the following script in the source of the array question or the group description.&lt;br /&gt;
#Call the script by replacing &amp;quot;QQ&amp;quot; in line 6 with your array question ID (you can call the script for more array questions by copying this line with new IDs).&lt;br /&gt;
&lt;br /&gt;
NOTE: Care should be taken when using this script and conditional questions on the same page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Call the exclude function using question ID(s)&lt;br /&gt;
&lt;br /&gt;
       excludeOpt (QQ);&lt;br /&gt;
&lt;br /&gt;
       // A function to make the last option in each array row exclusive&lt;br /&gt;
&lt;br /&gt;
       function excludeOpt (qID) {&lt;br /&gt;
&lt;br /&gt;
           // Add some classes to the checkboxes so we can manipulate them&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qID+&#039; table.question tbody td&#039;).addClass(&#039;normalOpt&#039;);&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qID+&#039; table.question tbody&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
               $(&#039;td:last&#039;, this).removeClass(&#039;normalOpt&#039;).addClass(&#039;exlusiveOpt&#039;)&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // A listener on the checkbox cells&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qID+&#039; table.question tbody td&#039;).click(function (event) {&lt;br /&gt;
&lt;br /&gt;
               // Set some vars&lt;br /&gt;
&lt;br /&gt;
               var el = $(this).parent();&lt;br /&gt;
&lt;br /&gt;
               var optLength = $(&#039;td&#039;, el).length&lt;br /&gt;
&lt;br /&gt;
               // Uncheck the appropriate boxes in a row&lt;br /&gt;
&lt;br /&gt;
               if ($(this).hasClass(&#039;normalOpt&#039;)) {&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;td:last input[type=checkbox]&#039;, el).attr(&#039;checked&#039;, false);&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               else {&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;td&#039;, el).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
                       if (i &amp;lt; (optLength - 1)) {&lt;br /&gt;
&lt;br /&gt;
                           $(&#039;input[type=checkbox]&#039;, this).attr(&#039;checked&#039;, false);&lt;br /&gt;
&lt;br /&gt;
                       }&lt;br /&gt;
&lt;br /&gt;
                   });&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // A listener on the checkboxes&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qID+&#039; table.question tbody td input[type=checkbox]&#039;).click(function (event) {&lt;br /&gt;
&lt;br /&gt;
               // Set some vars&lt;br /&gt;
&lt;br /&gt;
               var el2 = $(this).parent().parent();&lt;br /&gt;
&lt;br /&gt;
               var optLength = $(&#039;td&#039;, el2).length&lt;br /&gt;
&lt;br /&gt;
               // Uncheck the appropriate boxes in a row&lt;br /&gt;
&lt;br /&gt;
               if ($(this).parent().hasClass(&#039;normalOpt&#039;)) {&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;td:last input[type=checkbox]&#039;, el2).attr(&#039;checked&#039;, false);&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               else {&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;td&#039;, el2).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
                       if (i &amp;lt; (optLength - 1)) {&lt;br /&gt;
&lt;br /&gt;
                           $(&#039;input[type=checkbox]&#039;, this).attr(&#039;checked&#039;, false);&lt;br /&gt;
&lt;br /&gt;
                       }&lt;br /&gt;
&lt;br /&gt;
                   });&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Load SVG Code From Drawing Tool=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround uses JavaScript/jQuery to load a drawing tool and store the results in a huge-text question.&lt;br /&gt;
&lt;br /&gt;
The drawing tool is supplied by [http://www.mainada.net/inputdraw/ mainada.net].&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#Go to [www.mainada.net/inputdraw/downloads|www.mainada.net/inputdraw/downloads], download the latest package and install all files in the root of your LS installation (you only really need &#039;&#039;&#039;inputdraw.js&#039;&#039;&#039;, &#039;&#039;&#039;inputdraw.non-commercial.v1.5.swf&#039;&#039;&#039; and &#039;&#039;&#039;swfobject.js&#039;&#039;&#039; but the others are cool to play with).&lt;br /&gt;
#Add the following to the &amp;lt;head&amp;gt; element of your template startpage.pstpl file to pull in the scripts:&lt;br /&gt;
&lt;br /&gt;
+~hs&amp;lt;span style=&amp;quot;color:hs&amp;lt;/span&amp;gt;hs&amp;lt;span style=&amp;quot;color:hs~&amp;lt;script src=&amp;quot;swfobject.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
+~hs&amp;lt;/span&amp;gt;hs&amp;lt;span style=&amp;quot;color:hs&amp;lt;/span&amp;gt;hs~&amp;lt;script src=&amp;quot;inputdraw.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
#Create a huge-text question and add the following script to the source of that question.&lt;br /&gt;
&lt;br /&gt;
The script will&amp;quot;&amp;gt;&lt;br /&gt;
*Automatically find the ID of the first huge-text question on the page&lt;br /&gt;
*Insert the drawing element into the huge-text question&lt;br /&gt;
*Hide the textarea of that question&lt;br /&gt;
*Populate it with the SVG code generated by the drawing element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Find the survey, group and question IDs&lt;br /&gt;
&lt;br /&gt;
       if($( &#039;input#fieldnames&#039; ).length != 0) {&lt;br /&gt;
&lt;br /&gt;
           var fieldNames = $(&#039;input#fieldnames&#039;).attr(&#039;value&#039;);&lt;br /&gt;
&lt;br /&gt;
           var tmp = fieldNames.split(&#039;X&#039;);&lt;br /&gt;
&lt;br /&gt;
           var sID = tmp[0];&lt;br /&gt;
&lt;br /&gt;
           var gID = tmp[1];&lt;br /&gt;
&lt;br /&gt;
           var qIDStr = $(&#039;div.text-huge:eq(0)&#039;).attr(&#039;id&#039;);&lt;br /&gt;
&lt;br /&gt;
           var tmp2 = qIDStr.split(&#039;question&#039;);&lt;br /&gt;
&lt;br /&gt;
           var qID = tmp2[1];&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       var textAreaID = &#039;answer&#039;+sID+&#039;X&#039;+gID+&#039;X&#039;+qID;&lt;br /&gt;
&lt;br /&gt;
       // Hide the textarea&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#&#039;+textAreaID+&#039;&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
       // Insert an element for the drawing tool&lt;br /&gt;
&lt;br /&gt;
   $(&#039;&amp;lt;div id=&amp;quot;place&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&#039;).insertBefore($(&#039;#&#039;+textAreaID+&#039;&#039;));&lt;br /&gt;
&lt;br /&gt;
       // Load the drawing tool&lt;br /&gt;
&lt;br /&gt;
   var draw = new InputDraw(&#039;inputdraw.non-commercial.v1.5.swf&#039;, &#039;place&#039;, {&lt;br /&gt;
&lt;br /&gt;
           id:textAreaID,&lt;br /&gt;
&lt;br /&gt;
           width:&#039;350&#039;,&lt;br /&gt;
&lt;br /&gt;
           height:&#039;100&#039;,&lt;br /&gt;
&lt;br /&gt;
           stroke_style:&#039;2 1 rgb(255,0,0)&#039;,&lt;br /&gt;
&lt;br /&gt;
           animation:60,&lt;br /&gt;
&lt;br /&gt;
           color:&#039;#CCCCCC&#039; ,&lt;br /&gt;
&lt;br /&gt;
           tools_color:&#039;0xd6c004&#039;,&lt;br /&gt;
&lt;br /&gt;
           clean:&#039;clear.png&#039;,&lt;br /&gt;
&lt;br /&gt;
           undo:&#039;undo.png&#039;,&lt;br /&gt;
&lt;br /&gt;
           disable:&#039;size opacity color&#039; // Get rid of most of the tools&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Add Navigation Buttons (Next and Previous) To Top Of Page=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Add the following to the end of template.js. It will insert a new div after the progress bar and then insert clones of the nav buttons in the new div.&lt;br /&gt;
&lt;br /&gt;
This example is for the default template in 1.90 or 1.91. The placement of the new div may need to be modified for other templates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Insert a new div after the progress bar&lt;br /&gt;
&lt;br /&gt;
       $(&#039;&amp;lt;div id=&amp;quot;navigator2&amp;quot; /&amp;gt;&#039;).insertAfter(&#039;#progress-wrapper&#039;);&lt;br /&gt;
&lt;br /&gt;
       // Style the new div&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#navigator2&#039;).css({&lt;br /&gt;
&lt;br /&gt;
           &#039;text-align&#039;:&#039;center&#039;&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // Insert clones of the nav buttons in the new div&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input.submit:eq(0)&#039;).clone().appendTo(&#039;#navigator2&#039;);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input.submit:eq(2)&#039;).clone().appendTo(&#039;#navigator2&#039;);&lt;br /&gt;
&lt;br /&gt;
       // Give the new buttons some new IDs&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#navigator2 input.submit&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
           var oldID = $(this).attr(&#039;id&#039;);&lt;br /&gt;
&lt;br /&gt;
           var newID = oldID + &#039;2&#039;;&lt;br /&gt;
&lt;br /&gt;
           $(this).attr(&#039;id&#039;, newID)&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:extra_buttons.png]]&lt;br /&gt;
&lt;br /&gt;
=How to &#039;&#039;add&#039;&#039; an opt out link to your survey using javascript.=&lt;br /&gt;
&lt;br /&gt;
Tested with: 1.91+, Firefox 5.0&lt;br /&gt;
&lt;br /&gt;
This javascript inserts a link to opt out of the survey above the progress bar.&lt;br /&gt;
&lt;br /&gt;
First see the section above entitled: &amp;quot;How to use Script (eg. JavaScript etc.) in LimeSurvey?&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Then insert the following code into to the source of a group description or a question. I used the group description.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt; &amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Find the survey ID&lt;br /&gt;
&lt;br /&gt;
       if($(&#039;input#fieldnames&#039;).length != 0) {&lt;br /&gt;
&lt;br /&gt;
           var fieldNames = $(&#039;input#fieldnames&#039;).attr(&#039;value&#039;);&lt;br /&gt;
&lt;br /&gt;
           var tmp = fieldNames.split(&#039;X&#039;);&lt;br /&gt;
&lt;br /&gt;
           var sID = tmp[0];&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       // Insert a new div after the progress bar&lt;br /&gt;
&lt;br /&gt;
       $(&#039;&amp;lt;div id=&amp;quot;optOutLink&amp;quot; /&amp;gt;&#039;).insertBefore(&#039;#progress-wrapper&#039;);&lt;br /&gt;
&lt;br /&gt;
       // Style the new div&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#optOutLink&#039;).css({&lt;br /&gt;
&lt;br /&gt;
           &#039;text-align&#039;:&#039;center&#039;&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // Insert opt out url in the new div&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#optOutLink&#039;).html(&#039;&amp;lt;P&amp;gt;&amp;lt;a href=&amp;quot;optout.php?lang=en&amp;amp;sid;=&#039;+sID+&#039;&amp;amp;token;={TOKEN}&amp;quot;&amp;gt; /&lt;br /&gt;
&lt;br /&gt;
               Click here to opt out of this survey.&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;&amp;lt;br&amp;gt;&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Anonymously track respondents answers across multiple surveys=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.91+ and 1.92+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround uses JavaScript/jQuery to enable tracking of respondents across multiple surveys ensuring anonymity (it does not use tokens).&lt;br /&gt;
&lt;br /&gt;
To do this you have to use this question in all the surveys you want to link respondents answers.&lt;br /&gt;
&lt;br /&gt;
This workaround create an ID by asking some partial personal information (like initials, birth month ...). The ID will be encrypted using a one-way function (in this case SHA-1) and stored in a brief text answer.&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_ Set up your survey to use JavaScript].&lt;br /&gt;
#Place the following code in the source of a brief text question.&lt;br /&gt;
#Optional: you can also add other select field to avoid collisions (e.g. for large population sample)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;This answers are used to generate your ID. These information will be encrypted, it will not be possible in any case to identify you neither from your answers nor from your ID.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;Initial of your name&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;select id=&amp;quot;field1&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;&amp;quot;&amp;gt;&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;A&amp;quot;&amp;gt;A&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;B&amp;quot;&amp;gt;B&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;C&amp;quot;&amp;gt;C&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;D&amp;quot;&amp;gt;D&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;E&amp;quot;&amp;gt;E&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;F&amp;quot;&amp;gt;F&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;G&amp;quot;&amp;gt;G&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;H&amp;quot;&amp;gt;H&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;I&amp;quot;&amp;gt;I&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;J&amp;quot;&amp;gt;J&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;K&amp;quot;&amp;gt;K&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;L&amp;quot;&amp;gt;L&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;M&amp;quot;&amp;gt;M&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;N&amp;quot;&amp;gt;N&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;O&amp;quot;&amp;gt;O&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;P&amp;quot;&amp;gt;P&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;Q&amp;quot;&amp;gt;Q&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;R&amp;quot;&amp;gt;R&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;S&amp;quot;&amp;gt;S&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;T&amp;quot;&amp;gt;T&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;U&amp;quot;&amp;gt;U&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;V&amp;quot;&amp;gt;V&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;W&amp;quot;&amp;gt;W&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;X&amp;quot;&amp;gt;X&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;Y&amp;quot;&amp;gt;Y&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;Z&amp;quot;&amp;gt;Z&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/select&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;Your birth month&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;select id=&amp;quot;field2&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;&amp;quot;&amp;gt;&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;01&amp;quot;&amp;gt;January&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;02&amp;quot;&amp;gt;February&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;03&amp;quot;&amp;gt;March&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;04&amp;quot;&amp;gt;April&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;05&amp;quot;&amp;gt;May&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;06&amp;quot;&amp;gt;June&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;07&amp;quot;&amp;gt;July&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;08&amp;quot;&amp;gt;August&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;09&amp;quot;&amp;gt;September&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;10&amp;quot;&amp;gt;October&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;11&amp;quot;&amp;gt;November&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;12&amp;quot;&amp;gt;December&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/select&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;http://crypto-js.googlecode.com/svn/tags/3.0.2/build/rollups/sha1.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
   $(&amp;quot;#answer{SGQ}&amp;quot;).attr(&#039;readonly&#039;, &#039;readonly&#039;);&lt;br /&gt;
&lt;br /&gt;
   //$(&amp;quot;#answer{SGQ}&amp;quot;).css(&#039;display&#039;, &#039;none&#039;); //uncomment this line for not displaying the code&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
$(&#039;#field1, #field2&#039;).bind(&#039;change keyup&#039;, function() {&lt;br /&gt;
&lt;br /&gt;
   if ($(&amp;quot;#field1&amp;quot;).val()==&#039;&#039; || $(&amp;quot;#field2&amp;quot;).val()==&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
       $(&amp;quot;#answer{SGQ}&amp;quot;).val(&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
   else {&lt;br /&gt;
&lt;br /&gt;
       var sha1 = CryptoJS.algo.SHA1.create();&lt;br /&gt;
&lt;br /&gt;
       sha1.update($(&amp;quot;#field1&amp;quot;).val());&lt;br /&gt;
&lt;br /&gt;
       sha1.update($(&amp;quot;#field2&amp;quot;).val());&lt;br /&gt;
&lt;br /&gt;
       // sha1.update($(&amp;quot;#otherfield&amp;quot;).val());&lt;br /&gt;
&lt;br /&gt;
       var hash = sha1.finalize();&lt;br /&gt;
&lt;br /&gt;
       $(&amp;quot;#answer{SGQ}&amp;quot;).val(hash);&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Check validity of international phone number in subquestion=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.91+, Firefox 8, Chrome 15&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;As of version 1.92, you can use the core Validation querstion option to validate multiple short text and array text questions. Any question that fails that validation check will have its background color changed to red.&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;Note, the below workaround will fail in version 1.92 because it contains a regular expression with curly braces.  However, as described above, support for this feature is now built-in to version 1.92&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround uses javascript to check the validity of an international phone number in a subquestion of multiple short text.&lt;br /&gt;
&lt;br /&gt;
Add the following code to the source of your question.&lt;br /&gt;
&lt;br /&gt;
Replace &amp;quot;QQ&amp;quot; with the question ID and &amp;quot;NN&amp;quot; with the row number that you want to validate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Call the phone function with the question ID and the row number&lt;br /&gt;
&lt;br /&gt;
       phoneTest(QQ, NN);&lt;br /&gt;
&lt;br /&gt;
       function phoneTest(qID, inputNum) {&lt;br /&gt;
&lt;br /&gt;
           // Interrupt next/submit function&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#movenextbtn, #movesubmitbtn&#039;).click(function(){&lt;br /&gt;
&lt;br /&gt;
               // Some vars - modify as required&lt;br /&gt;
&lt;br /&gt;
               var phoneMatch = /^[0-9,+,(), ,]{1,}(,[0-9]+){0,}$/;&lt;br /&gt;
&lt;br /&gt;
               var msg1 = &#039;Please enter a valid phone number.&#039;;&lt;br /&gt;
&lt;br /&gt;
               // Test the input&lt;br /&gt;
&lt;br /&gt;
               var phoneInput = $(&#039;#question&#039;+qID+&#039; li:eq(&#039;+(inputNum-1)+&#039;) input.text&#039;).val();&lt;br /&gt;
&lt;br /&gt;
               if(phoneInput != &#039;&#039; &amp;amp;&amp;amp; !phoneMatch.test(phoneInput)) {&lt;br /&gt;
&lt;br /&gt;
                   alert(msg1);&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;#question&#039;+qID+&#039; li:eq(&#039;+(inputNum-1)+&#039;) input.text&#039;).css({ &#039;background&#039;:&#039;pink&#039; });&lt;br /&gt;
&lt;br /&gt;
                   return false;&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               else {&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;#question&#039;+qID+&#039; li:eq(&#039;+(inputNum-1)+&#039;) input.text&#039;).css({ &#039;background&#039;:&#039;&#039; });&lt;br /&gt;
&lt;br /&gt;
                   return true;&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The regex is from: [http://www.regexlib.com/REDetails.aspx?regexp_id=1136 regexlib.com blank]&lt;br /&gt;
&lt;br /&gt;
=Check validity of email address in subquestion=&lt;br /&gt;
&lt;br /&gt;
&#039;Tested with: 1.91+, Firefox 8, Chrome 15&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;As of version 1.92, you can use the core Validation querstion option to validate multiple short text and array text questions. Any question that fails that validation check will have its background color changed to red.&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;Note, the below workaround will fail in version 1.92 because it contains a regular expression with curly braces.  However, as described above, support for this feature is now built-in to version 1.92&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround uses javascript to check the validity of an email address in a subquestion of multiple short text.&lt;br /&gt;
&lt;br /&gt;
Add the following code to the source of your question.&lt;br /&gt;
&lt;br /&gt;
Replace &amp;quot;QQ&amp;quot; with the question ID and &amp;quot;NN&amp;quot; with the row number that you want to validate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Call the email function with the question ID and the row number&lt;br /&gt;
&lt;br /&gt;
       emailTest(QQ, NN);&lt;br /&gt;
&lt;br /&gt;
       function emailTest(qID, inputNum) {&lt;br /&gt;
&lt;br /&gt;
           // Interrupt next/submit function&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#movenextbtn, #movesubmitbtn&#039;).click(function(){&lt;br /&gt;
&lt;br /&gt;
               // Some vars - modify as required&lt;br /&gt;
&lt;br /&gt;
               var emailMatch = /^[a-zA-Z0-9\_\-]+[a-zA-Z0-9\.\_\-]*@([a-zA-Z0-9\_\-]+\.)+([a-zA-Z]{2,4}|travel|museum)$/;&lt;br /&gt;
&lt;br /&gt;
               var msg1 = &#039;Please enter a valid email address.&#039;;&lt;br /&gt;
&lt;br /&gt;
               // Test the input&lt;br /&gt;
&lt;br /&gt;
               var emailInput = $(&#039;#question&#039;+qID+&#039; li:eq(&#039;+(inputNum-1)+&#039;) input.text&#039;).val();&lt;br /&gt;
&lt;br /&gt;
               if(emailInput != &#039;&#039; &amp;amp;&amp;amp; !emailMatch.test(emailInput)) {&lt;br /&gt;
&lt;br /&gt;
                   alert(msg1);&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;#question&#039;+qID+&#039; li:eq(&#039;+(inputNum-1)+&#039;) input.text&#039;).css({ &#039;background&#039;:&#039;pink&#039; });&lt;br /&gt;
&lt;br /&gt;
                   return false;&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               else {&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;#question&#039;+qID+&#039; li:eq(&#039;+(inputNum-1)+&#039;) input.text&#039;).css({ &#039;background&#039;:&#039;&#039; });&lt;br /&gt;
&lt;br /&gt;
                   return true;&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The regex is from: [http://www.regexlib.com/REDetails.aspx?regexp_id=1653 regexlib.com blank]&lt;br /&gt;
&lt;br /&gt;
=Hiding the help-text when it&#039;s empty=&lt;br /&gt;
&lt;br /&gt;
Tested with: 1.91+&lt;br /&gt;
&lt;br /&gt;
I had made a style in my template putting a border around my help-text. To avoid empty help-text to show up (and have lines instead of just &#039;nothing&#039; when there was no help text, I used this piece of code in question.pstpl:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
                   var questionhelp=&amp;quot;{QUESTIONHELP}&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
                   if (questionhelp==&amp;quot;&amp;quot;) {&lt;br /&gt;
&lt;br /&gt;
                          document.write(&amp;quot;&amp;quot;);}&lt;br /&gt;
&lt;br /&gt;
                   else {&lt;br /&gt;
&lt;br /&gt;
                   document.write(&#039;&amp;lt;tr&amp;gt;&amp;lt;td class=&amp;quot;survey-question-help&amp;quot;&amp;gt;&#039;+ questionhelp +&#039;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&#039;);}&lt;br /&gt;
&lt;br /&gt;
               &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
it can probably be optimized but it worked for me&lt;br /&gt;
&lt;br /&gt;
=Disable or hide selected fields in a matrix question=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.92+, IE 7/8/9, FireFox 12/13&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
TASK&lt;br /&gt;
&lt;br /&gt;
Hide or disable selected fields in a Matrix, so that users cannot make any input.&lt;br /&gt;
&lt;br /&gt;
(See example, where users should not make input into red framed fields)&lt;br /&gt;
&lt;br /&gt;
[[File:snap035.gif]]&lt;br /&gt;
&lt;br /&gt;
Fig. 1: Prevent users from input into first two fields (as an example)&lt;br /&gt;
&lt;br /&gt;
SOLUTION&lt;br /&gt;
&lt;br /&gt;
First find the name of the fields you want to hide / disable. In my case I used Firebug with firefox to figure that out.&lt;br /&gt;
&lt;br /&gt;
[[File:snap037.gif]]&lt;br /&gt;
&lt;br /&gt;
Fig. 2: Figure out the name(s) of the field(s)&lt;br /&gt;
&lt;br /&gt;
Then put the following script-code into the HTML-source code as described above:&lt;br /&gt;
&lt;br /&gt;
Note: you have to change the code to match the names of your fields!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input[name=&amp;quot;69965X2X10SQ001_SQ001&amp;quot;]&#039;).attr(&#039;disabled&#039;, &#039;disabled&#039;);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input[name=&amp;quot;69965X2X10SQ001_SQ002&amp;quot;]&#039;).attr(&#039;hidden&#039;, &#039;hidden&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:snap039.gif]]&lt;br /&gt;
&lt;br /&gt;
Fig. 3: Result: first field is diabled (&amp;quot;greyed out&amp;quot;), second one is completely hidden&lt;br /&gt;
&lt;br /&gt;
I think this way one can apply many other attributes to a field like color etc. But did not try that myself.&lt;br /&gt;
&lt;br /&gt;
Thanks to roB2009 for the input in the forum!&lt;br /&gt;
&lt;br /&gt;
=Add prefix or suffix to question type &amp;quot;Array (Texts)&amp;quot;=&lt;br /&gt;
&lt;br /&gt;
TASK&lt;br /&gt;
&lt;br /&gt;
Add a prefix or suffix to the text fields in questions of the &amp;quot;Array (Texts)&amp;quot; type.&lt;br /&gt;
&lt;br /&gt;
[[File:suffix.png]]&lt;br /&gt;
&lt;br /&gt;
Fig. 1: Suffix&lt;br /&gt;
&lt;br /&gt;
[[File:prefix.png]]&lt;br /&gt;
&lt;br /&gt;
Fig. 1: Prefix&lt;br /&gt;
&lt;br /&gt;
SOLUTION&lt;br /&gt;
*Set up your survey to use JavaScript.&lt;br /&gt;
*Add the following script to the source of the array. Replace &amp;quot;12345&amp;quot; with the array question ID and modify the suffixes/prefixes as required.&lt;br /&gt;
*The function call must consist of a question ID followed by the suffixes for each column. Suffixes/Prefixes must be enclosed in quotes and comma separated.&lt;br /&gt;
*In this example question ID 12345 will get an &amp;quot;in &amp;amp;euro;&amp;quot; suffix in the first column and an &amp;quot;in %&amp;quot; in the next 3 columns.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Call the function with the question ID followed by a comma-separated list of suffixes&lt;br /&gt;
&lt;br /&gt;
       addSuffix(12345, &#039;in &amp;amp;euro;&#039;, &#039;in %&#039;, &#039;in %&#039;, &#039;in %&#039;);&lt;br /&gt;
&lt;br /&gt;
       function addSuffix() {&lt;br /&gt;
&lt;br /&gt;
           var qID = $(arguments)[0];&lt;br /&gt;
&lt;br /&gt;
           // Assign some column-specific classes&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qID+&#039; table.question tbody tr&#039;).each(function(i){&lt;br /&gt;
&lt;br /&gt;
               $(&#039;td&#039;, this).each(function(i){&lt;br /&gt;
&lt;br /&gt;
                   $(this).addClass(&#039;answerCol-&#039;+(i+1)+&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
               });&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Some styling&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qID+&#039; table.question tbody input[type=&amp;quot;text&amp;quot;]&#039;).css({&lt;br /&gt;
&lt;br /&gt;
               &#039;width&#039;: &#039;50%&#039;&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Insert the suffixes&lt;br /&gt;
&lt;br /&gt;
           $(arguments).each(function(i, val){&lt;br /&gt;
&lt;br /&gt;
               if(i &amp;gt; 0) {&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;#question&#039;+qID+&#039; td.answerCol-&#039;+i+&#039; label&#039;).append(val);&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For adding a prefix you need to substitute the following line in the code&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;$(&#039;#question&#039;+qID+&#039; td.answerCol-&#039;+i+&#039; label&#039;).append(val);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with this&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;$(&#039;#question&#039;+qID+&#039; td.answerCol-&#039;+i+&#039; label&#039;).prepend(val);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Add prefix or suffix to question type &amp;quot;Array (Texts)&amp;quot;=&lt;br /&gt;
&lt;br /&gt;
TASK&lt;br /&gt;
&lt;br /&gt;
Add a prefix or suffix to the text fields in questions of the &amp;quot;Array (Texts)&amp;quot; type.&lt;br /&gt;
&lt;br /&gt;
[[File:suffix.png]]&lt;br /&gt;
&lt;br /&gt;
Fig. 1: Suffix&lt;br /&gt;
&lt;br /&gt;
[[File:prefix.png]]&lt;br /&gt;
&lt;br /&gt;
Fig. 1: Prefix&lt;br /&gt;
&lt;br /&gt;
SOLUTION&lt;br /&gt;
*Set up your survey to use JavaScript.&lt;br /&gt;
*Add the following script to the source of the array. Replace &amp;quot;12345&amp;quot; with the array question ID and modify the suffixes/prefixes as required.&lt;br /&gt;
*The function call must consist of a question ID followed by the suffixes for each column. Suffixes/Prefixes must be enclosed in quotes and comma separated.&lt;br /&gt;
*In this example question ID 12345 will get an &amp;quot;in &amp;amp;euro;&amp;quot; suffix in the first column and an &amp;quot;in %&amp;quot; in the next 3 columns.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Call the function with the question ID followed by a comma-separated list of suffixes&lt;br /&gt;
&lt;br /&gt;
       addSuffix(12345, &#039;in &amp;amp;euro;&#039;, &#039;in %&#039;, &#039;in %&#039;, &#039;in %&#039;);&lt;br /&gt;
&lt;br /&gt;
       function addSuffix() {&lt;br /&gt;
&lt;br /&gt;
           var qID = $(arguments)[0];&lt;br /&gt;
&lt;br /&gt;
           // Assign some column-specific classes&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qID+&#039; table.question tbody tr&#039;).each(function(i){&lt;br /&gt;
&lt;br /&gt;
               $(&#039;td&#039;, this).each(function(i){&lt;br /&gt;
&lt;br /&gt;
                   $(this).addClass(&#039;answerCol-&#039;+(i+1)+&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
               });&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Some styling&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qID+&#039; table.question tbody input[type=&amp;quot;text&amp;quot;]&#039;).css({&lt;br /&gt;
&lt;br /&gt;
               &#039;width&#039;: &#039;50%&#039;&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Insert the suffixes&lt;br /&gt;
&lt;br /&gt;
           $(arguments).each(function(i, val){&lt;br /&gt;
&lt;br /&gt;
               if(i &amp;gt; 0) {&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;#question&#039;+qID+&#039; td.answerCol-&#039;+i+&#039; label&#039;).append(val);&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For adding a prefix you need to substitute the following line in the code&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;$(&#039;#question&#039;+qID+&#039; td.answerCol-&#039;+i+&#039; label&#039;).append(val);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with this&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;$(&#039;#question&#039;+qID+&#039; td.answerCol-&#039;+i+&#039; label&#039;).prepend(val);&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Holch</name></author>
	</entry>
	<entry>
		<id>https://www.limesurvey.org/manual/index.php?title=Workarounds:_Manipulating_a_survey_at_runtime_using_Javascript&amp;diff=3792</id>
		<title>Workarounds: Manipulating a survey at runtime using Javascript</title>
		<link rel="alternate" type="text/html" href="https://www.limesurvey.org/manual/index.php?title=Workarounds:_Manipulating_a_survey_at_runtime_using_Javascript&amp;diff=3792"/>
		<updated>2012-07-06T22:47:25Z</updated>

		<summary type="html">&lt;p&gt;Holch: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
Often you want to manipulate certain elements of a survey at runtime. The only solution without touching the source code is to use Javascript or jQuery which is shipped with Limesurvey. Here are some examples to hide and style elements, validate user input or do calculations at runtime.&lt;br /&gt;
&lt;br /&gt;
Non Javascript workarounds can be found at&lt;br /&gt;
* [http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Survey+behaviour&amp;amp;structure;=English+Instructions+for+LimeSurvey Workarounds - Survey Behavior]&lt;br /&gt;
* [http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Question+design%2C+layout+and+templating Workarounds - Question design, layout and templating]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;&amp;lt;center&amp;gt;&#039;&#039;&#039;Please keep in mind that the workarounds published here are no official Limesurvey extensions but solutions that other users created for themselves.&amp;lt;br/&amp;gt;&amp;lt;span style=&#039;color:#EE0000,#FFFFFF&#039;&amp;gt;Therefore we can&#039;t give support for any solution on this page.&amp;lt;/span&amp;gt;&amp;lt;br/&amp;gt;Please contact the users that, thankfully, shared their solutions with the community if you have any questions.&#039;&#039;&#039;&amp;lt;/center&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;Note:  Version 1.92 implements many new features that make some existing workarounds obsolete.  You can continue to use existing workarounds, but may want to consider switching over to using the new features (since those new features are officially supported, and the workarounds are not).  Please review below for details of which are no longer needed.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;Also Note:  Version 1.92&#039;s Expression Manager (EM) may cause some of these work-arounds to fail.  Any custom javascript included as a .js file will be fine.  However, if you in-line your JavaScript code, you must make sure that you have a space after every opening (left) curly brace, and a space before every closing (right) curly brace.  Otherwise, EM will think that the content between the curly braces is something it should parse and understand.  I have fixed all of the work-arounds below that can be fixed (many did not follow those rules).  However, some will continue to break.  If a work-around contains a regular expression which contains curly braces (to indicate a range of repeats of a sub-expression), EM will try to process those curly braces, and thus break your regular expression.  Strategies to continue to support that work-around functionality are discussed below.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=How to &#039;&#039;add&#039;&#039; a javascript workaround solution to this Wiki page?=&lt;br /&gt;
&lt;br /&gt;
Well, this is pretty easy. Click the edit icon and create your own headline within the javascript section starting with &amp;quot;&#039;&#039;&#039;!&#039;&#039;&#039;&amp;quot;. Then add a short note about the version you have used when creating your workaround, you can copy/paste this code snippet &amp;lt;nowiki&amp;gt;&#039;&#039;Tested with: (enter Limesurvey version and maybe browser)&#039;&#039;&amp;lt;/nowiki&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Finally it&#039;s imported to mark all your code with code tags, other wise you might break this page.&lt;br /&gt;
*Start tag: &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
*End tag: &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=How to &#039;&#039;use&#039;&#039; Script (eg. JavaScript etc.) in LimeSurvey?=&lt;br /&gt;
&lt;br /&gt;
To use JavaScript within Limesurvey, the XSS filter must be turned off and the code inserted in the source of a question or a group description.&lt;br /&gt;
*Go to Global settings --&amp;gt; Security and set &amp;quot;Filter HTML for XSS&amp;quot; to &amp;quot;Off&amp;quot;.&lt;br /&gt;
* [http://docs.limesurvey.org/tiki-index.php?page=Adding+A+Question Add a new question]&lt;br /&gt;
* Edit the question and click the &amp;quot;Source&amp;quot; button in the editor toolbar:&lt;br /&gt;
&lt;br /&gt;
   [[File:editor_1.gif]]&lt;br /&gt;
* Enter your script after the question text:&lt;br /&gt;
&lt;br /&gt;
   [[File:editor_2.gif]]&lt;br /&gt;
* Save the question&lt;br /&gt;
&lt;br /&gt;
A simple test to see if JavaScript is enabled is to echo an alert. Use this code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   alert(&amp;quot;Test!&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is a good practice to use the jQuery $(document).ready function to prevent the code from executing until the page is fully loaded:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       alert(&amp;quot;Test!&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Sum up input values using Javascript=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, this is easier to do using the sum() function in [[Expression Manager|Expression Manager]].  See this [[Expression Manager HowTos|#Calculate assessment values at runtime and store the results in the survey data|HowTo example]].&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is from a survey that is a invitation to a longer party, when the user clicks to the next page, the calculated results will be shown.&lt;br /&gt;
&lt;br /&gt;
If you wonder what the {INSERTANS:1X6X12} stuff is, look at [http://docs.limesurvey.org/tiki-index.php?page=SGQA+Identifier SGQA identifier] and [http://docs.limesurvey.org/tiki-index.php?page=Adding+a+Question#Information_from_previous_answers Using information from previous answers].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;text-align: left&amp;quot;&amp;gt;These are your answers:&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;u&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;u&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;u&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;u&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;script LANGUAGE=&amp;quot;JavaScript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
partyprice = 3;&lt;br /&gt;
&lt;br /&gt;
beadclothprice = 3;&lt;br /&gt;
&lt;br /&gt;
breakfastprice = 7;&lt;br /&gt;
&lt;br /&gt;
lunchprice = 8;&lt;br /&gt;
&lt;br /&gt;
dinnerprice = 10;&lt;br /&gt;
&lt;br /&gt;
foodtotal = 0;&lt;br /&gt;
&lt;br /&gt;
var isreallytrue = &amp;quot;Yes&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
var noanswer = &amp;quot;No answer&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
document.write( &amp;quot;Can you come? = {INSERTANS:45251X1X1}&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
if (&amp;quot;{INSERTANS:45251X1X1}&amp;quot; == isreallytrue )&lt;br /&gt;
&lt;br /&gt;
  {&lt;br /&gt;
&lt;br /&gt;
   if (&amp;quot;{INSERTANS:45251X1X3}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
   else { answer = &amp;quot;{INSERTANS:45251X1X3}&amp;quot;; }&lt;br /&gt;
&lt;br /&gt;
   partypeople = parseInt(answer);&lt;br /&gt;
&lt;br /&gt;
   partytotal = partyprice * partypeople;&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;It&#039;s {INSERTANS:45251X1X3} persons who will come = &amp;quot; + partytotal + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   if (&amp;quot;{INSERTANS:45251X1X4}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
   else { answer = &amp;quot;{INSERTANS:45251X1X4}&amp;quot;;}&lt;br /&gt;
&lt;br /&gt;
   beadcloths = parseInt(answer);&lt;br /&gt;
&lt;br /&gt;
   beadclothtotal = beadclothprice * beadcloths;&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;You want to borrow {INSERTANS:45251X1X4} beadcloths = &amp;quot; + beadclothtotal + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;Will you be there thursday? = {INSERTANS:45251X1X5}&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;On friday you will have these meals: &amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   if (&amp;quot;{INSERTANS:45251X1X71}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
   else { answer = &amp;quot;{INSERTANS:45251X1X71}&amp;quot;;}&lt;br /&gt;
&lt;br /&gt;
   breakfastfriday = parseInt(answer) * breakfastprice;&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; breakfeasts = &amp;quot; + breakfastfriday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   if (&amp;quot;{INSERTANS:45251X1X72}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
   else { answer = &amp;quot;{INSERTANS:45251X1X72}&amp;quot;;}&lt;br /&gt;
&lt;br /&gt;
   lunchfriday = parseInt(answer) * lunchprice ;&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; lunches = &amp;quot; + lunchfriday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   if (&amp;quot;{INSERTANS:45251X1X73}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
   else { answer = &amp;quot;{INSERTANS:45251X1X73}&amp;quot;;}&lt;br /&gt;
&lt;br /&gt;
   dinnerfriday = parseInt(answer)* dinnerprice ;&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; dinners = &amp;quot; + dinnerfriday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   foodtotal = breakfastfriday + lunchfriday + dinnerfriday;&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;Will you be there saturday? = {INSERTANS:45251X1X8}&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   if (&amp;quot;{INSERTANS:45251X1X8}&amp;quot; == isreallytrue )&lt;br /&gt;
&lt;br /&gt;
      {&lt;br /&gt;
&lt;br /&gt;
       document.write( &amp;quot;On saturday you will have these meals: &amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
       if (&amp;quot;{INSERTANS:45251X1X91}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
       else { answer = &amp;quot;{INSERTANS:45251X1X91}&amp;quot;; }&lt;br /&gt;
&lt;br /&gt;
       breakfastsaturday = parseInt(answer) * breakfastprice ;&lt;br /&gt;
&lt;br /&gt;
       document.write(&amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; breakfeasts = &amp;quot; + breakfastsaturday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
       if (&amp;quot;{INSERTANS:45251X1X92}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
       else { answer = &amp;quot;{INSERTANS:45251X1X92}&amp;quot;; }&lt;br /&gt;
&lt;br /&gt;
       lunchsaturday = parseInt(answer) * lunchprice ;&lt;br /&gt;
&lt;br /&gt;
       document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; lunches = &amp;quot; + lunchsaturday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
       if (&amp;quot;{INSERTANS:45251X1X93}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
       else { answer = &amp;quot;{INSERTANS:45251X1X93}&amp;quot;; }&lt;br /&gt;
&lt;br /&gt;
       dinnersaturday = parseInt(answer) * dinnerprice ;&lt;br /&gt;
&lt;br /&gt;
       document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; dinners = &amp;quot; + dinnersaturday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
       foodtotal = foodtotal + breakfastsaturday + lunchsaturday + dinnersaturday;&lt;br /&gt;
&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;Will you be there sunday? = {INSERTANS:45251X1X10}&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
   if (&amp;quot;{INSERTANS:45251X1X10}&amp;quot; == isreallytrue )&lt;br /&gt;
&lt;br /&gt;
      {&lt;br /&gt;
&lt;br /&gt;
       document.write( &amp;quot;On sunday you will have these meals: &amp;lt;br&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
       if (&amp;quot;{INSERTANS:45251X1X111}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
       else { answer = &amp;quot;{INSERTANS:45251X1X111}&amp;quot;; }&lt;br /&gt;
&lt;br /&gt;
       breakfastsunday = parseInt(answer) * breakfastprice ;&lt;br /&gt;
&lt;br /&gt;
       document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; breakfeasts = &amp;quot; + breakfastsunday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot;  );&lt;br /&gt;
&lt;br /&gt;
       if (&amp;quot;{INSERTANS:45251X1X112}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
       else { answer = &amp;quot;{INSERTANS:45251X1X112}&amp;quot;; }&lt;br /&gt;
&lt;br /&gt;
       lunchsunday = parseInt(answer) * lunchprice ;&lt;br /&gt;
&lt;br /&gt;
       document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; lunches = &amp;quot; + lunchsunday + &amp;quot;&amp;amp;euro;&amp;lt;BR&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
       if (&amp;quot;{INSERTANS:45251X1X113}&amp;quot;== noanswer) { answer = 0; }&lt;br /&gt;
&lt;br /&gt;
       else { answer = &amp;quot;{INSERTANS:45251X1X113}&amp;quot;; }&lt;br /&gt;
&lt;br /&gt;
       dinnersunday = parseInt(answer) * dinnerprice ;&lt;br /&gt;
&lt;br /&gt;
       document.write( &amp;quot;&#039;&#039;&#039;_ &amp;quot; + answer + &amp;quot; dinners = &amp;quot; + dinnersunday + &amp;quot;&amp;amp;euro;&amp;lt;p&amp;gt;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
       foodtotal = foodtotal + breakfastsunday + lunchsunday + dinnersunday;&lt;br /&gt;
&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
   total = partytotal + beadclothtotal + foodtotal;&lt;br /&gt;
&lt;br /&gt;
   document.write( &amp;quot;&amp;lt;h3&amp;gt;In total it will cost you &amp;quot; + total + &amp;quot;&amp;amp;euro;&amp;lt;/h3&amp;gt;&amp;lt;BR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   Put that sum in this bank account 1234 5678 9012&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/SCRIPT&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Multiple Question Validation=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, this is easier to do using the min/max/equals_num_value attributes (to validate sums), or the em_validation_q function, which lets you refer to other variables when you validate the current question [[Expression Manager|Expression Manager]].  Such validations also work on the current page, and properly handle array_filter and cascading relevance.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround is in case you need to do some validation involving more than one question, it implies a very little JavaScript programming and the use of SQGA Identifiers; this should work on almost any version of LimeSurvey.&lt;br /&gt;
&lt;br /&gt;
Is easy to explain with an example, we need to do a survey of the percentage of males and females and we want to be sure that the sum is 100, to do this follow this steps (the necessary data that is not indicated in these instructions are not important i.e. question codes, etc.):&lt;br /&gt;
#Create a new survey of type &amp;amp;ldquo;group by group&amp;amp;rdquo;, set the &amp;amp;ldquo;Show |&amp;lt;&amp;lt; Prev| button&amp;amp;rdquo; to yes and note the SID.&lt;br /&gt;
#Add a new group called &amp;amp;ldquo;Group 1&amp;amp;rdquo; and note the GID.&lt;br /&gt;
#Add a new question &amp;amp;ldquo;Percent of males&amp;amp;rdquo; of type &amp;amp;ldquo;numeric&amp;amp;rdquo;, make it mandatory and note the QID (we will refer to this as QID1).&lt;br /&gt;
#Add a new question &amp;amp;ldquo;Percent of females&amp;amp;rdquo; of type &amp;amp;ldquo;numeric&amp;amp;rdquo;, make it mandatory and note the QID (we will refer to this as QID2).&lt;br /&gt;
#Add a new group called &amp;amp;ldquo;Group 2&amp;amp;rdquo;&lt;br /&gt;
#Add a new non mandatory question, here is the trick the question text has to be (be sure to replace the SID, GID, QID1 and QID2&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
function validation()&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   if [[{INSERTANS:SIDXGIDXQID1}+{INSERTANS:SIDXGIDXQID2}) != 100)&lt;br /&gt;
&lt;br /&gt;
   {&lt;br /&gt;
&lt;br /&gt;
     alert(&amp;quot;Your responses don&#039;t sum 100! Check them&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
     document.limesurvey.move.value = &#039;moveprev&#039;;&lt;br /&gt;
&lt;br /&gt;
     document.limesurvey.submit();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   else&lt;br /&gt;
&lt;br /&gt;
   {&lt;br /&gt;
&lt;br /&gt;
     document.limesurvey.move.value = &#039;movelast&#039;;&lt;br /&gt;
&lt;br /&gt;
     document.limesurvey.submit();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 setTimeout(&amp;quot;validation()&amp;quot;,250);&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 But this will show shortly the question and will jump to the end page, a little weird for the survey taker but works.&lt;br /&gt;
&lt;br /&gt;
 This is a proof of concept, and may have some problems, please if you notice something or improve it send me an e-mail to leochaton-limesurvey at yahoo dot com.&lt;br /&gt;
&lt;br /&gt;
 This will work for 2 questions that you want to be the same.  Works well for email and confirm email questions&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  function validation() {&lt;br /&gt;
&lt;br /&gt;
  if (&amp;quot;{INSERTANS:SIDXGIDXQID}&amp;quot; != &amp;quot;{INSERTANS:SIDXGIDXQID}&amp;quot;) {&lt;br /&gt;
&lt;br /&gt;
     alert(&amp;quot;Your responses don&#039;t match Check them&amp;quot;); document.limesurvey.move.value = &#039;moveprev&#039;;&lt;br /&gt;
&lt;br /&gt;
     document.limesurvey.submit();&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  setTimeout(&amp;quot;validation()&amp;quot;,250);&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 =Alternate exit=&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with: &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 Using the same idea of the previous post, you can implement an alternate exit of your survey.&lt;br /&gt;
&lt;br /&gt;
 This script should be in the first question to be displayed in a next page after the question that should trigger the alternate exit. In this example the question that trigger the alternate exit is a Yes/No question, if the user chooses no, he is redirected to another page.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 if (&amp;quot;{INSERTANS:SIDXGIDXQID}&amp;quot; == &amp;quot;No&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
&lt;br /&gt;
   window.location=&amp;quot;http://www.limesurvey.org&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 =Custom onload function=&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with: &#039;All browsers&#039;, LimeSurvey 1.70 and up&lt;br /&gt;
&lt;br /&gt;
 ==General==&lt;br /&gt;
&lt;br /&gt;
 This simple workaround describes how to &#039;&#039;&#039;add a custom Javascript code&#039;&#039;&#039; that is triggered right after the page is loaded. It may have numerous applications, especially when you deal with a custom JS/HTML code. It may be used to hide form elements (&amp;lt;input&amp;gt;  tags), make them read-only, display alert messages, etc.&lt;br /&gt;
&lt;br /&gt;
 To run any Javascript code right after page load use the Query ready() function. It will be executed when the page is being loaded. For example when you add the following code to one of your question definitions...:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 jQuery(document).ready(&lt;br /&gt;
&lt;br /&gt;
    function(){&lt;br /&gt;
&lt;br /&gt;
        alert(&#039;onload alert!&#039;);&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
 );&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ...it will display a pop-up message immediately after the page has been loaded.&lt;br /&gt;
&lt;br /&gt;
 Some of the applications of this trick I&#039;ve explored are:&lt;br /&gt;
&lt;br /&gt;
 a) Hiding the form elements by calling in your Custom_On_Load:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;document.getElementById(&amp;quot;answer73166X16X54&amp;quot;).style.display=&#039;none&#039;;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 Note: As of svn build 9755, you can now dynamically reference the questions input fields by using the {SGQ} keyword. You can rewrite the previous example like this:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;document.getElementById(&amp;quot;answer{SGQ}&amp;quot;).style.display=&#039;none&#039;;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 this makes it a little easier when exporting surveys, so you don&#039;t have to worry about manually entering each questions SurveyGroupQuestion ID.&lt;br /&gt;
&lt;br /&gt;
 b) Making the elements read only:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;document.getElementById(&amp;quot;answer73166X16X54&amp;quot;).readOnly=true;&amp;lt;/syntaxhighlight&amp;gt; where the &amp;quot;answer73166X16X54&amp;quot; structure has been described in one of other workarounds above.&lt;br /&gt;
&lt;br /&gt;
 c) For Hiding by a lot of elements by calling in your Customer_On_Load&lt;br /&gt;
&lt;br /&gt;
 jQuery searchs in html document for input-fields with radio type, if his answer text empty then do the display css set to none.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 jQuery(document).ready(&lt;br /&gt;
&lt;br /&gt;
            function() {&lt;br /&gt;
&lt;br /&gt;
              jQuery(&#039;input:radio&#039;).each(&lt;br /&gt;
&lt;br /&gt;
                function() {&lt;br /&gt;
&lt;br /&gt;
                  var s = jQuery(this);&lt;br /&gt;
&lt;br /&gt;
                  var c = s.parent().children(&#039;.answertext&#039;);&lt;br /&gt;
&lt;br /&gt;
                  for(var i=0; i &amp;lt; c.length; i++) {&lt;br /&gt;
&lt;br /&gt;
                    var a = jQuery(c[i]]);&lt;br /&gt;
&lt;br /&gt;
                    if(this.id &amp;lt;/u&amp;gt; a.attr(&#039;for&#039;) &amp;amp;&amp;amp; a.text() == &#039;&#039;) {&lt;br /&gt;
&lt;br /&gt;
                      s.css({ &#039;display&#039; : &#039;none&#039; });&lt;br /&gt;
&lt;br /&gt;
                      a.css({ &#039;display&#039; : &#039;none&#039; });&lt;br /&gt;
&lt;br /&gt;
                      break;&lt;br /&gt;
&lt;br /&gt;
                    }&lt;br /&gt;
&lt;br /&gt;
                  }&lt;br /&gt;
&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
              )&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
          );&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ==Advanced usage==&lt;br /&gt;
&lt;br /&gt;
 If you want to place global Javascript code using the above jQuery(document).ready function then the best place to do this is the template javascript file template.js. You can edit this file using the template editor. Please be aware that placing it in the template javascript file will make the function available to all surveys using that template. If needed just create a new template copy for your survey.&lt;br /&gt;
&lt;br /&gt;
 Alternatively you can place the jQuery(document).ready function in the group description to make a Javascript function only available to a certain question group.&lt;br /&gt;
&lt;br /&gt;
 ==Language-specific Javascript code==&lt;br /&gt;
&lt;br /&gt;
 There is an easy way to find out the current language and execute according Javascript using jQuery: The &amp;lt;html&amp;gt; tag of any survey pages contains an &#039;lang&#039; attribute which holds the current language code. You can read that language code by using the followin code&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 jQuery(document).ready(&lt;br /&gt;
&lt;br /&gt;
    function(){&lt;br /&gt;
&lt;br /&gt;
        languagecode=$(&#039;html&#039;).attr(&#039;lang&#039;);&lt;br /&gt;
&lt;br /&gt;
        alert(&#039;This is the current language code: &#039;+languagecode);&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
 );&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 For an English survey the above code would show a messagebox with &amp;quot;This is the current language code: en&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 =Custom onload function in multi-language survey=&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with: 1.85+ (7253), IE 6/7, FireFox 3.0, Safari 3.2,&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 To use custom onload functions, as above, in multi-language surveys you must define the functions in the question source for &#039;&#039;&#039;all&#039;&#039;&#039; languages.&lt;br /&gt;
&lt;br /&gt;
 While this initially seems to be a bit tedious, it actually can be useful - you can alter your onload functions depending on the language in use. For example, you can dynamically display alerts or element contents in the current language.&lt;br /&gt;
&lt;br /&gt;
 =Skipping the welcome page=&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with: 1.85 (second code snippet)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;Note: As of version 1.91, there is a survey option letting you skip the welcome page, so this workaround is not needed.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Solution 1:&#039;&#039;&#039; Include this Javascript in your welcome template, in the file welcome.pstpl for all welcome page, or in the source of the welcome text for one survey:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 jQuery(document).ready(function($) {&lt;br /&gt;
&lt;br /&gt;
 document.limesurvey.move.value = &#039;movenext&#039;;&lt;br /&gt;
&lt;br /&gt;
 document.limesurvey.submit(); });&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 It will reproduce the onclick event of the submit button and submit the form.&lt;br /&gt;
&lt;br /&gt;
 Drawback of course is that users will see the page flashing up.&lt;br /&gt;
&lt;br /&gt;
 Therefore, you may want to announce &amp;quot;... loading survey ...&amp;quot; as a description of your welcome page (in the admin interface when creating the survey), to pretend loading something big.&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Solution 2:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 function custom_on_load(){&lt;br /&gt;
&lt;br /&gt;
   document.limesurvey.move.value = &#039;movenext&#039;;&lt;br /&gt;
&lt;br /&gt;
   document.limesurvey.submit();&lt;br /&gt;
&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 window.setTimeout( &#039;custom_on_load()&#039;,1);&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 =Filter answers of a question with the answer of another=&lt;br /&gt;
&lt;br /&gt;
 ===Method 1===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with: 1.70 - 1.72&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, this is easier to do using the the array_filter attribute, or relevance equations in general.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 If you want to filter the answer of a question with another answer, you can use this workaround.&lt;br /&gt;
&lt;br /&gt;
 First, use answer code like that: XX for the first question, and XXYYY for the second one.&lt;br /&gt;
&lt;br /&gt;
 Answer of the second question filter if the 2 first letters are the answer of the first question.&lt;br /&gt;
&lt;br /&gt;
 We use 1000X1X1 and 1000X1X2 for the example, question had to be on separate page (question by question for example).The second question had to be a dropdown list (we can do similar workaround, but droplis is the best). You can do this using JQuery.  It leaves the answer in the select box, but disables it.  You could also replace &amp;quot;disable&amp;quot; with &amp;quot;remove&amp;quot; to get rid of it altogether.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 var previousQuestionAnswer = &amp;quot;{INSERTANS:1000X1X1}&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
 var currentQuestionID = &amp;quot;#answer1000X1X1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
    // See if the answer for the previous question matches an answer in the current question&lt;br /&gt;
&lt;br /&gt;
    // (other than &#039;No Answer&#039;)&lt;br /&gt;
&lt;br /&gt;
    // If so, disable it.&lt;br /&gt;
&lt;br /&gt;
    if (previousQuestionAnswer!=&#039;No Answer&#039;) {&lt;br /&gt;
&lt;br /&gt;
        $(currentQuestionID).children().each(function(index, Element)&lt;br /&gt;
&lt;br /&gt;
        {&lt;br /&gt;
&lt;br /&gt;
            if ($(this).attr(&#039;text&#039;) == previousQuestionAnswer)&lt;br /&gt;
&lt;br /&gt;
                { $(this).attr(&#039;disabled&#039;, true); }&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
        );}&lt;br /&gt;
&lt;br /&gt;
 }); // End of JQuery ready function&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ===Method 2===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with 1.92 + Firefox 9.0&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 If you have a country, state, and city set of questions (or similar), you could code answer options as:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Q1 Country&#039;&#039;&#039; &#039;&#039;Single choice list (ratio, dropdown)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 X country#&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Q2 State&#039;&#039;&#039; &#039;&#039;Single choice list (dropdown)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 XY state#&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Q3 City&#039;&#039;&#039; &#039;&#039;Single choice list (dropdown)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 XYZZ city#&lt;br /&gt;
&lt;br /&gt;
 Now you must put the following Javascript code in the source of question 2 (State):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
        // Get the countryCode (first character of the country)&lt;br /&gt;
&lt;br /&gt;
        var countryCode = &#039;{INSERTANS:1000X1X1}&#039;.substr(0, 1).toUpperCase();&lt;br /&gt;
&lt;br /&gt;
        // Loop through all dropdown options and remove those with codes not starting with the countryCode&lt;br /&gt;
&lt;br /&gt;
        $(&#039;select[id&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&amp;quot;answer&amp;quot;] option&#039;).each(function(i){&lt;br /&gt;
&lt;br /&gt;
            if($(this).attr(&#039;value&#039;)  &amp;amp;&amp;amp; $(this).attr(&#039;value&#039;).substr(0, 1).toUpperCase() != countryCode) {&lt;br /&gt;
&lt;br /&gt;
                $(this).remove();&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
        });&lt;br /&gt;
&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 And the following code in the source of question 3 (City):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
        // Get the stateCode (two first characters of the state)&lt;br /&gt;
&lt;br /&gt;
        var stateCode = &#039;{INSERTANS:1000X1X2}&#039;.substr(0, 2).toUpperCase();&lt;br /&gt;
&lt;br /&gt;
        // Loop through all dropdown options and remove those with codes not starting with the stateCode&lt;br /&gt;
&lt;br /&gt;
        $(&#039;select[id&amp;lt;/div&amp;gt;=&amp;quot;answer&amp;quot;] option&#039;).each(function(i){&lt;br /&gt;
&lt;br /&gt;
            if($(this).attr(&#039;value&#039;)  &amp;amp;&amp;amp; $(this).attr(&#039;value&#039;).substr(0, 2).toUpperCase() != stateCode) {&lt;br /&gt;
&lt;br /&gt;
                $(this).remove();&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
        });&lt;br /&gt;
&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 Each question must be in different pages of survey to work, i.e. in a question by question survey, or in diferent groups in a group by group survey.&lt;br /&gt;
&lt;br /&gt;
 Note that if you choose a two characters answer option code in the State question, i.e. a XYY answer option code, you must change the &#039;&#039;substr(0, 2)&#039;&#039; part of code in question 3 to &#039;&#039;substr(0, 3)&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 =Filter answers of a multiple numeric type question=&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with: 1.90+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, this is easier to do using the the array_filter attribute, or relevance equations in general.  In 1.92, array_filter works with all questions that have sub-questions (e.g. also works for multiple numeric and multiple short text).&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 If you want to filter a question of type &amp;quot;multiple numeric&amp;quot;, you have to modify the workaround.&lt;br /&gt;
&lt;br /&gt;
 Note that this workaround assumes that the code for each of the subquestions are a numeric sequence 1,2,3...&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $(document).ready(function(){&lt;br /&gt;
&lt;br /&gt;
    // Match elements with labels using htmlFor and a loop&lt;br /&gt;
&lt;br /&gt;
    var labels = document.getElementsByTagName(&#039;LABEL&#039;);&lt;br /&gt;
&lt;br /&gt;
    for (var i = 0; i &amp;lt; labels.length; i++) {&lt;br /&gt;
&lt;br /&gt;
        if (labels[i].htmlFor != &#039;&#039;) {&lt;br /&gt;
&lt;br /&gt;
             var elem = document.getElementById(labels[i].htmlFor);&lt;br /&gt;
&lt;br /&gt;
             if (elem)&lt;br /&gt;
&lt;br /&gt;
                elem.label = labels[i];&lt;br /&gt;
&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    var answerFilter=&amp;quot;{INSERTANS:96553X63X759}&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
    for (i=0; i&amp;lt;30; i++){&lt;br /&gt;
&lt;br /&gt;
      var iLabel = document.getElementById(&#039;answer96553X63X760&#039;+(i+1]].label.innerHTML;&lt;br /&gt;
&lt;br /&gt;
     if (answerFilter.search(iLabel) == -1){&lt;br /&gt;
&lt;br /&gt;
       // Hide element&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question760&#039;).find(&#039;li&#039;).eq(i).hide();&lt;br /&gt;
&lt;br /&gt;
       // Set value of hidden elements to zero&lt;br /&gt;
&lt;br /&gt;
       document.getElementById(&#039;answer96553X63X760&#039;+(i+1)).value = 0;&lt;br /&gt;
&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
 });&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Use an answer to prefill another question (default value)=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.72&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;And tested with: 1.91+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, this is easier to do using the enhanced defaults feature, which lets you pre-fill most question types with default values.  In 1.91, you could set defaults for list and multiple choice questions.  In 1.92, you can set defaults for any text-entry question too.  Moreover, the defaults can be [[Expression Manager|Expression Manager]] compatible equations or tailored text.  Finally, with 1.92, defaults are properly managed even when set on the same page.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround gives you the ablility to use an answer to fill the default value for another question. It&#039;s explained for free text question type but can be adapted for another question type.&lt;br /&gt;
&lt;br /&gt;
We use SGQA identifier. For example, we use SGQA 1000X10X20 and 1000X10X21 to prefill 1000X11X30 and 1000X11X31. For the script to work, the question has to be on a different page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
 $(&#039;#answer1000X11X30&#039;).val(&#039;{INSERTANS:1000X10X20}&#039;);&lt;br /&gt;
&lt;br /&gt;
 $(&#039;#answer1000X11X31&#039;).val(&#039;{INSERTANS:1000X10X21}&#039;);&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want use two times the value of an integer input, you can also use this to prefill a question that you hide via CSS.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
 $(&#039;#answer1000X2X2&#039;).val(parseInt(&#039;{INSERTANS:1000X1X1}&#039;)*2);&lt;br /&gt;
&lt;br /&gt;
 $(&amp;quot;#question2&amp;quot;).hide();&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you can use {INSERTANS:1000X2X2} for giving you twice the value of the user input from question 1.&lt;br /&gt;
&lt;br /&gt;
=Dynamic Sum=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, this is easier to do with [[Expression Manager|Expression Manager]] using the sum() function.  Not only will sums be dynamic, but they wille exclude irrelevant values, so you can array_filter a multiple numeric question and get the sum of just the answers that are visible.  This [[Expression Manager HowTos|#Calculate assessment values at runtime and store the results in the survey data|HowTo example]] demonstrates the dynamic sum feature.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;Also note, as of version 1.92, the following workaround will fail, since it includes a a regular expression containing curly braces.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This script is used with a &amp;quot;Multiple Options&amp;quot; type question calculate a total price based on how which checkboxes are selected. The prices are listed as part of the answer. The answers are set up like this: &amp;quot;USB Mouse ($20)&amp;quot;. The script uses the number between the &amp;quot;($&amp;quot; and the &amp;quot;)&amp;quot; as the price for that item. You can adapt the script to if you need to change the currency or need to sum something other than money.&lt;br /&gt;
&lt;br /&gt;
This script works when used in a question-by-question format.  It does not work when there are more than one question on a page. I think it can be adapted to work, but I haven&#039;t done the coding yet.&lt;br /&gt;
&lt;br /&gt;
Put the following code into body of your question:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script language=Javascript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// General definitions&lt;br /&gt;
&lt;br /&gt;
// Define a regular expression to match the labels containing information about an answer&lt;br /&gt;
&lt;br /&gt;
// In LimeSurvey, these labels start with &amp;quot;answer...&amp;quot;&lt;br /&gt;
&lt;br /&gt;
var answerRegex = /^answer/;&lt;br /&gt;
&lt;br /&gt;
// Find all answer checkboxes in the document and set their&lt;br /&gt;
&lt;br /&gt;
// onchange events to updatePrice&lt;br /&gt;
&lt;br /&gt;
function Custom_On_Load()&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   // Find all input elements&lt;br /&gt;
&lt;br /&gt;
   var inputList=document.getElementsByTagName(&amp;quot;input&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
   // Loop through each, looking for checkboxes&lt;br /&gt;
&lt;br /&gt;
   var i;&lt;br /&gt;
&lt;br /&gt;
   for( i=0; i&amp;lt; inputList.length;i++ )&lt;br /&gt;
&lt;br /&gt;
   {&lt;br /&gt;
&lt;br /&gt;
       // If input item does not have an ID, skip&lt;br /&gt;
&lt;br /&gt;
       if (! (inputList[i].id)) { continue; }&lt;br /&gt;
&lt;br /&gt;
       // Skip to next if ID doesn&#039;t start with &amp;quot;answer&amp;quot;&lt;br /&gt;
&lt;br /&gt;
       if (!answerRegex.test(inputList[i].id)) { continue; }&lt;br /&gt;
&lt;br /&gt;
       // Skip to next if not a checkbox&lt;br /&gt;
&lt;br /&gt;
       if (inputList[i].type.toUpperCase()!=&#039;CHECKBOX&#039;)  { continue; }&lt;br /&gt;
&lt;br /&gt;
       // This is an answer checkbox!&lt;br /&gt;
&lt;br /&gt;
       // Setup onchange event&lt;br /&gt;
&lt;br /&gt;
       inputList[i].onclick = updatePrice;&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
       // Load initial sum&lt;br /&gt;
&lt;br /&gt;
   updatePrice();&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function updatePrice()&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
var labels=document.getElementsByTagName(&amp;quot;LABEL&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
// Define a regular expression to match a price inside parenthesis&lt;br /&gt;
&lt;br /&gt;
// For example: ($29) or ($29.54).&lt;br /&gt;
&lt;br /&gt;
// Set up&lt;br /&gt;
&lt;br /&gt;
priceRegex = /\(\$(\d*\.{0,1}\d+)\)/;&lt;br /&gt;
&lt;br /&gt;
// Loop through all the labels, looking for labels corresponding to&lt;br /&gt;
&lt;br /&gt;
// answers that have a price in them.&lt;br /&gt;
&lt;br /&gt;
var i;&lt;br /&gt;
&lt;br /&gt;
var total = 0;&lt;br /&gt;
&lt;br /&gt;
for( i=0; i&amp;lt;labels.length;i++ )&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   var myArray;    // Define array used for regex matching&lt;br /&gt;
&lt;br /&gt;
   var inputID;    // Define field element&lt;br /&gt;
&lt;br /&gt;
   // Get the ID of the field corresponding to the label using the&lt;br /&gt;
&lt;br /&gt;
   // &amp;quot;htmlFor&amp;quot; attribute&lt;br /&gt;
&lt;br /&gt;
   // (FYI, there are some labels that will have to be screened out&lt;br /&gt;
&lt;br /&gt;
   // because they don&#039;t correspond to an answer)&lt;br /&gt;
&lt;br /&gt;
   // Does the label start with &amp;quot;answer&amp;quot;?&lt;br /&gt;
&lt;br /&gt;
   // If not: exit.&lt;br /&gt;
&lt;br /&gt;
   if (!answerRegex.test(labels[i].htmlFor)) { continue; }&lt;br /&gt;
&lt;br /&gt;
   // First make sure this element exists&lt;br /&gt;
&lt;br /&gt;
   // If it doesn&#039;t, go to the next element&lt;br /&gt;
&lt;br /&gt;
   // If it does, it will be defined in inputID&lt;br /&gt;
&lt;br /&gt;
   if (! (inputID = document.getElementById(labels[i].htmlFor)) ) { continue; }&lt;br /&gt;
&lt;br /&gt;
   // See if the corresponding answer is a checkbox that is checked.&lt;br /&gt;
&lt;br /&gt;
   // If not, go to next label&lt;br /&gt;
&lt;br /&gt;
   if (inputID.type.toUpperCase()!=&#039;CHECKBOX&#039;)  { continue; }&lt;br /&gt;
&lt;br /&gt;
   if (!inputID.checked) { continue; }&lt;br /&gt;
&lt;br /&gt;
   // This is label for an answer.&lt;br /&gt;
&lt;br /&gt;
   // The innerHTML will give us the text of the label&lt;br /&gt;
&lt;br /&gt;
   // The price information will be in the form ($XX.XX)&lt;br /&gt;
&lt;br /&gt;
   // which in contained in the label text.&lt;br /&gt;
&lt;br /&gt;
   // Find a match for a decimal number inside the pattern &amp;quot;($&amp;quot; and &amp;quot;)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   if [[myArray = priceRegex.exec(labels[i].innerHTML]] != null)&lt;br /&gt;
&lt;br /&gt;
   {&lt;br /&gt;
&lt;br /&gt;
       // Keep a running tally&lt;br /&gt;
&lt;br /&gt;
       total += parseFloat(myArray[1]);&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
  // Update total price on form&lt;br /&gt;
&lt;br /&gt;
  document.getElementById(&amp;quot;totalPrice&amp;quot;).value = &amp;quot;$&amp;quot; + formatCurrency(total);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function formatCurrency(num) {&lt;br /&gt;
&lt;br /&gt;
  num = isNaN(num) || num &amp;lt;u&amp;gt; &#039;&#039; || num &amp;lt;/u&amp;gt; null ? 0.00 : num;&lt;br /&gt;
&lt;br /&gt;
  return parseFloat(num).toFixed(2);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Put the following code in the help section (or wherever you want the sum to appear):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;Total Cost for selected accessories: &amp;lt;input type=&amp;quot;readonly&amp;quot; value=&amp;quot;&amp;quot; id=&amp;quot;totalPrice&amp;quot; /&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Focus on the first Input field=&lt;br /&gt;
&lt;br /&gt;
(&#039;&#039;Tested with: Limesurvey 1.80 / IE6/7, Firefox 3, Safari, Opera, chrome&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.91, there is a built-in JavaScript function called  focusFirst() to focus on the first visible element.  It uses jQuery, so is more robust than this example.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again an onload Function is needed for this tasks. I have done it the DOM way with compatibility to IE6/7.&lt;br /&gt;
&lt;br /&gt;
Put the following code into the startpage.pstpl of your template, right before the &amp;lt;/head&amp;gt; closing tag:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   function focusFirst(Event)&lt;br /&gt;
&lt;br /&gt;
   {&lt;br /&gt;
&lt;br /&gt;
       var i=0;&lt;br /&gt;
&lt;br /&gt;
       while(document.forms[0].elements[i].type == &amp;quot;hidden&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
       {&lt;br /&gt;
&lt;br /&gt;
           i++;&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       document.forms[0].elements[i].focus();&lt;br /&gt;
&lt;br /&gt;
       return;&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   if(ie)&lt;br /&gt;
&lt;br /&gt;
   { window.attachEvent(&amp;quot;onload&amp;quot;, focusFirst); }&lt;br /&gt;
&lt;br /&gt;
   else&lt;br /&gt;
&lt;br /&gt;
   { document.addEventListener(&amp;quot;load&amp;quot;, focusFirst, true); }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; I am using this with version 1.80. As changes happened to the templates in the last release, you might need to add the following before the code, if your template is older than 1.80 stable and does not include this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   var ie = false;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will need this for the var ie to be set. Without this var, the function will not work with ie.&lt;br /&gt;
&lt;br /&gt;
=Answer questions by keypress=&lt;br /&gt;
&lt;br /&gt;
(&#039;&#039;Tested with: IE7, Firefox 3&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
This workaround allow to answer the question on key 0-9 (0 is for the 10 answer).&lt;br /&gt;
&lt;br /&gt;
Follow issues are supported at the moment:&lt;br /&gt;
*Yes-No Questions&lt;br /&gt;
*List Questions (radio)&lt;br /&gt;
*other radio questions&lt;br /&gt;
&lt;br /&gt;
In lists the answer limit is ten.&lt;br /&gt;
&lt;br /&gt;
You supply the template &amp;quot;endpage&amp;quot; of your template with the following script.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
jQuery(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
   jQuery(document).bind(&#039;keypress&#039;, function(e){&lt;br /&gt;
&lt;br /&gt;
       if (48 &amp;lt;= e.which &amp;amp;&amp;amp; e.which &amp;lt;= 57) {&lt;br /&gt;
&lt;br /&gt;
           jQuery(&#039;input:radio&#039;).each(function() {&lt;br /&gt;
&lt;br /&gt;
               var v = jQuery(this).val();&lt;br /&gt;
&lt;br /&gt;
               var c = (e.which &amp;lt;u&amp;gt; 48) ? 10 : e.which - 48;&lt;br /&gt;
&lt;br /&gt;
               if(v &amp;lt;/u&amp;gt; &#039;Y&#039; || v &amp;lt;u&amp;gt; &#039;N&#039;) {&lt;br /&gt;
&lt;br /&gt;
                   v = (v &amp;lt;/u&amp;gt; &#039;Y&#039;) ? 1 : 2;&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               if(v == c) {&lt;br /&gt;
&lt;br /&gt;
                   jQuery(this).click();&lt;br /&gt;
&lt;br /&gt;
                   jQuery(&#039;#limesurvey input:submit&#039;).click();&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   })&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Math notation in LimeSurvey=&lt;br /&gt;
#download the js file from [http://mathcs.chapman.edu/~jipsen/mathml/asciimathdownload.html AsciiMath script]&lt;br /&gt;
#copy it in the /scripts/ folder in your installation&lt;br /&gt;
#modify the startpage.psptl of the template you want to use adding the reference to the script (if you use an older version make sure that you copy the template folder first!) for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;ASCIIMathML.js&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the notation where you need it!&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; If you use internet explorer or safari you will need to download the plugin as well, but firefox does the lot for you.&lt;br /&gt;
&lt;br /&gt;
Finally, if you are confident with the limesurvey structure you could add the editor which support math notation and change the reference to the editor you want to use in the configuration file. here is the [http://www.imathas.com/editordemo/demo.html link for a TinyMCE with math support].&lt;br /&gt;
&lt;br /&gt;
=Reverse array_filter (for pre-1.90)=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.85+ (7253), IE 6/7, FireFox 3.0, Safari 3.2, Chrome 2.0&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;Note: Version 1.91 natively supports this functionality via the array_filter_exclude advanced quation option.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This can be used to filter the answers of an array question to be displayed based on the answers of a multi option question that were &#039;&#039;&#039;NOT&#039;&#039;&#039; selected. A possible application would be to have a multi-option question asking which products were purchased, followed by 2 array questions - one asking to rate the purchased products and another asking why the remaining products were not purchased. Another would be to ask about sessions attended at a conference as in [http://www.limesurvey.org/en/support/forums/5-can-i-do-this-with-limesurvey/27970-reverse-of-arrayfilter.html this forum thread] and pictured below. There is a live [http://www.partnersinc.biz/surveys//index.php?sid=43358&amp;amp;newtest;=Y&amp;amp;lang;=en demo here]&lt;br /&gt;
&lt;br /&gt;
[[File:sessions_645x344.gif]]&lt;br /&gt;
&lt;br /&gt;
We&#039;ll use the above example to explain the process as follows:&lt;br /&gt;
#In group 1 - Create a &#039;&#039;SessionsAttended&#039;&#039; multi-options question&lt;br /&gt;
#In group 1 - Create a &#039;&#039;SessionsNotAttended&#039;&#039; multi-options question with identical answers as &#039;&#039;SessionsAttended&#039;&#039; and hide it with styles or conditions&lt;br /&gt;
#In group 2 - Create a &#039;&#039;RateSessionsAttended&#039;&#039; array question with an [http://docs.limesurvey.org/tiki-index.php?page=Question+attributes&amp;amp;structure;=English+Instructions+for+LimeSurvey#array_filter array_filter] based on &#039;&#039;SessionsAttended&#039;&#039;&lt;br /&gt;
#In group 2 - Create a &#039;&#039;ReasonNotAttended&#039;&#039; array question with an [http://docs.limesurvey.org/tiki-index.php?page=Question+attributes&amp;amp;structure;=English+Instructions+for+LimeSurvey#array_filter array_filter] based on &#039;&#039;SessionsNotAttended&#039;&#039;&lt;br /&gt;
#In group 1 - Place JavaScript/jQeury listeners on each of the checkboxes in &#039;&#039;SessionsAttended&#039;&#039; that would toggle the corresponding checkbox in &#039;&#039;SessionsNotAttended&#039;&#039; to the opposite state&lt;br /&gt;
&lt;br /&gt;
The JavaScript/jQuery code used would be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
       // The toggle function&lt;br /&gt;
&lt;br /&gt;
   function toggle(q1, q2) {&lt;br /&gt;
&lt;br /&gt;
       if ($(q1).attr(&#039;checked&#039;) == false ) {&lt;br /&gt;
&lt;br /&gt;
           $(q2).attr(&#039;checked&#039;, true);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       else {&lt;br /&gt;
&lt;br /&gt;
           $(q2).attr(&#039;checked&#039;, false);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   // Initialize the SessionNotAttended checkboxes to &amp;quot;checked&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   toggle (&#039;#answer11111X22X331&#039;, &#039;#answer11111X22X441&#039;);&lt;br /&gt;
&lt;br /&gt;
   toggle (&#039;#answer11111X22X332&#039;, &#039;#answer11111X22X442&#039;);&lt;br /&gt;
&lt;br /&gt;
   toggle (&#039;#answer11111X22X333&#039;, &#039;#answer11111X22X443&#039;);&lt;br /&gt;
&lt;br /&gt;
   toggle (&#039;#answer11111X22X334&#039;, &#039;#answer11111X22X444&#039;);&lt;br /&gt;
&lt;br /&gt;
   // The jQuery listeners on the SessionAttended checkboxes&lt;br /&gt;
&lt;br /&gt;
   // that toggle the SessionNotAttended checkboxes&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#answer11111X22X331&#039;).change(function() {&lt;br /&gt;
&lt;br /&gt;
       toggle (&#039;#answer11111X22X331&#039;, &#039;#answer11111X22X441&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#answer11111X22X332&#039;).change(function() {&lt;br /&gt;
&lt;br /&gt;
       toggle (&#039;#answer11111X22X332&#039;, &#039;#answer11111X22X442&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#answer11111X22X333&#039;).change(function() {&lt;br /&gt;
&lt;br /&gt;
       toggle (&#039;#answer11111X22X333&#039;, &#039;#answer11111X22X443&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#answer11111X22X334&#039;).change(function() {&lt;br /&gt;
&lt;br /&gt;
       toggle (&#039;#answer11111X22X334&#039;, &#039;#answer11111X22X444&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some notes about the code:&lt;br /&gt;
*The code is in an onload function defined in the first question of group 1 - see [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#Custom_onload_function workarounds here]&lt;br /&gt;
*Both &#039;&#039;SessionsAttended&#039;&#039; and &#039;&#039;SessionsNotAttended&#039;&#039; must be in the same group for the toggling to work&lt;br /&gt;
*This case only uses 4 checkboxes but could be expanded as required&lt;br /&gt;
*In this case the survey ID is 11111, the group ID is 22, &#039;&#039;SessionsAttended&#039;&#039; ID is 33 and SessionsNotAttended ID is 44 - these would need to be modified for your survey&lt;br /&gt;
*The toggle function looks for the state of a checkbox in &#039;&#039;SessionsAttended&#039;&#039; and sets the corresponding checkbox in &#039;&#039;SessionsNotAttended&#039;&#039; to the opposite state&lt;br /&gt;
*The &amp;quot;Initialize&amp;quot; section sets the state of &#039;&#039;SessionsNotAttended&#039;&#039; checkboxes whenever we navigate to the group&lt;br /&gt;
*The &amp;quot;Listener&amp;quot; section uses jQuery listeners to detect any change in the &#039;&#039;SessionsAttended&#039;&#039; checkboxes and then toggle the corresponding &#039;&#039;SessionsNotAttended&#039;&#039; checkbox&lt;br /&gt;
&lt;br /&gt;
Some general notes about the questions:&lt;br /&gt;
*CSS can be used to hide &#039;&#039;SessionsNotAttended&#039;&#039; (div#question44 { display: none; }) if you don&#039;t want to use conditions (because maybe you&#039;ve got [http://docs.limesurvey.org/tiki-index.php?page=Optional+settings&amp;amp;structure;=English+Instructions+for+LimeSurvey#Survey_Behavior $deletenonvalues set to 1])&lt;br /&gt;
*&#039;&#039;RateSessionsAttended&#039;&#039; and &#039;&#039;ReasonNotAttended&#039;&#039; are another group to avoid things popping in and out of existence as &#039;&#039;SessionsAttended&#039;&#039; is answered&lt;br /&gt;
*[http://docs.limesurvey.org/tiki-index.php?page=Setting+conditions&amp;amp;structure;=English+Instructions+for+LimeSurvey Conditions] are used to ensure that &#039;&#039;RateSessionsAttended&#039;&#039; only appears if some sessions are selected and &#039;&#039;ReasonNotAttended&#039;&#039; only appears if no sessions are selected&lt;br /&gt;
&lt;br /&gt;
=Filter Ranking Question With Multiple-Options=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90, IE 7/8, FireFox 3/4, Safari 5.0, Chrome 10.0&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, most of this is easier to do using the the array_filter attribute, or relevance equations in general.  They all work on the same page, and fully support cascading relevance.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround applies a filter to a ranking question based on the checked boxes of a previous multiple-options question. There are two methods - one for filter and ranking questions being on the same page and a slightly different one for the filter question being on a page before the ranking question.&lt;br /&gt;
&lt;br /&gt;
There is a [http://www.partnersinc.biz/surveys//index.php?sid=96314&amp;amp;newtest;=Y&amp;amp;lang;=en demo of both methods here].&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FOR BOTH METHODS:&#039;&#039;&#039;&lt;br /&gt;
*[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_ Set up your survey to use JavaScript].&lt;br /&gt;
*Place the following script in your template.js file. This function will be accessed by either method.&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// A function to filter choices in a ranking question&lt;br /&gt;
&lt;br /&gt;
function rankFilter(q1ID, q2ID, prevPage) {&lt;br /&gt;
&lt;br /&gt;
   // If filter question is on a previous page, hide Q1 and check all &amp;quot;visible&amp;quot; boxes&lt;br /&gt;
&lt;br /&gt;
   if(prevPage == 1) {&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q1ID+&#039; li[id&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&amp;quot;javatbd&amp;quot;]:visible input.checkbox&#039;).attr(&#039;checked&#039;, true);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q1ID+&#039;&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   handleChecked(q1ID, q2ID);&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#question&#039;+q1ID+&#039; input.checkbox&#039;).click(function() {&lt;br /&gt;
&lt;br /&gt;
       handleChecked(q1ID, q2ID);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   function handleChecked(q1ID, q2ID) {&lt;br /&gt;
&lt;br /&gt;
       // Find the survey and group IDs&lt;br /&gt;
&lt;br /&gt;
       if($( &#039;input#fieldnames&#039; ).length != 0) {&lt;br /&gt;
&lt;br /&gt;
           var fieldNames = $( &#039;input#fieldnames&#039; ).attr(&#039;value&#039;);&lt;br /&gt;
&lt;br /&gt;
           var tmp = fieldNames.split(&#039;X&#039;);&lt;br /&gt;
&lt;br /&gt;
           var sID = tmp[0];&lt;br /&gt;
&lt;br /&gt;
           var gID = tmp[1];&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       // Loop through all Q1 options&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q1ID+&#039; input.checkbox&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
           // Find the answer code and value&lt;br /&gt;
&lt;br /&gt;
           var tmp2 = $(this).attr(&#039;id&#039;).split(&#039;X&#039;+gID+&#039;X&#039;+q1ID+&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
           var ansCode = tmp2[1];&lt;br /&gt;
&lt;br /&gt;
           var ansTxt = $(this).next(&#039;label&#039;).text();&lt;br /&gt;
&lt;br /&gt;
           // If option is checked and not in rank choices or output, add it to the rank choices&lt;br /&gt;
&lt;br /&gt;
           if($(this).attr(&#039;checked&#039;) == true&lt;br /&gt;
&lt;br /&gt;
                          &amp;amp;&amp;amp; $(&#039;#question&#039;+q2ID+&#039; select.select option[value=&amp;quot;&#039;+ansCode+&#039;&amp;quot;]&#039;).length == 0&lt;br /&gt;
&lt;br /&gt;
                          &amp;amp;&amp;amp; $(&#039;#question&#039;+q2ID+&#039; .output input[id&amp;lt;/div&amp;gt;=&amp;quot;fvalue_&amp;quot;][value=&amp;quot;&#039;+ansCode+&#039;&amp;quot;]&#039;).length == 0) {&lt;br /&gt;
&lt;br /&gt;
               $(&#039;&amp;lt;option value=&amp;quot;&#039;+ansCode+&#039;&amp;quot;&amp;gt;&#039;+ansTxt+&#039;&amp;lt;/option&amp;gt;&#039;).appendTo(&#039;#question&#039;+q2ID+&#039; select.select&#039;);&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
           // If option is unchecked...&lt;br /&gt;
&lt;br /&gt;
           else if($(this).attr(&#039;checked&#039;) == false) {&lt;br /&gt;
&lt;br /&gt;
               // Remove it from the rank choices&lt;br /&gt;
&lt;br /&gt;
               $(&#039;#question&#039;+q2ID+&#039; select.select option[value=&amp;quot;&#039;+ansCode+&#039;&amp;quot;]&#039;).remove();&lt;br /&gt;
&lt;br /&gt;
               // Remove it from the rank output and reset hidden values&lt;br /&gt;
&lt;br /&gt;
$(&#039;#question&#039;+q2ID+&#039; .output input[id&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&amp;quot;fvalue_&amp;quot;][value=&amp;quot;&#039;+ansCode+&#039;&amp;quot;]&#039;).attr(&#039;value&#039;, &#039;&#039;).siblings(&#039;input.text&#039;).val(&#039;&#039;).siblings(&#039;img&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // Clean up empty inputs in the rank output table&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q2ID+&#039; .output table tr&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
           var nextRow = $(this).next(&#039;tr&#039;);&lt;br /&gt;
&lt;br /&gt;
           if($(&#039;input.text&#039;, this).val() == &#039;&#039; &amp;amp;&amp;amp; $(&#039;input.text&#039;, nextRow).val() != &#039;&#039;) {&lt;br /&gt;
&lt;br /&gt;
               $(&#039;input.text&#039;, this).val($(&#039;input.text&#039;, nextRow).val());&lt;br /&gt;
&lt;br /&gt;
               $(&#039;input.text&#039;, nextRow).val(&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
               $(&#039;input[id&amp;lt;/div&amp;gt;=&amp;quot;fvalue_&amp;quot;]&#039;, this).attr(&#039;value&#039;, $(&#039;input[id&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&amp;quot;fvalue_&amp;quot;]&#039;, nextRow).attr(&#039;value&#039;));&lt;br /&gt;
&lt;br /&gt;
               $(&#039;input[id&amp;lt;/div&amp;gt;=&amp;quot;fvalue_&amp;quot;]&#039;, nextRow).attr(&#039;value&#039;, &#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // Show the scissors for the last populated rank output row&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q2ID+&#039; .output table img[id&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&amp;quot;cut_&amp;quot;]&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q2ID+&#039; .output table input.text[value!=&amp;quot;&amp;quot;]:last&#039;).siblings(&#039;img[id&amp;lt;/div&amp;gt;=&amp;quot;cut_&amp;quot;]&#039;).show();&lt;br /&gt;
&lt;br /&gt;
       // Hide extra rank output rows&lt;br /&gt;
&lt;br /&gt;
       var optNum = $(&#039;#question&#039;+q1ID+&#039; input.checkbox:checked&#039;).length;&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q2ID+&#039; .output table tr&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q2ID+&#039; .output table tr:lt(&#039;+(optNum+1)+&#039;)&#039;).show();&lt;br /&gt;
&lt;br /&gt;
       // Hide and clear the ranking question if there are less than 2 checked options in Q1&lt;br /&gt;
&lt;br /&gt;
       if(optNum &amp;lt; 2) {&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+q2ID+&#039;&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+q2ID+&#039; input.text&#039;).val(&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+q2ID+&#039; input[id&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&amp;quot;fvalue_&amp;quot;]&#039;).attr(&#039;value&#039;, &#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       else {&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+q2ID+&#039;&#039;).show();&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       // A work around for the built in max-answers function&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q2ID+&#039; select.select&#039;).attr(&#039;disabled&#039;, true);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q2ID+&#039; td.output tr:visible&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
           if($(&#039;input.text&#039;, this).val() == &#039;&#039;) {&lt;br /&gt;
&lt;br /&gt;
               $(&#039;#question&#039;+q2ID+&#039; select.select&#039;).attr(&#039;disabled&#039;, false);&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   // A listener to work around the built in max-answers function&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#question&#039;+q2ID+&#039; td.rank&#039;).click(function (event) {&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q2ID+&#039; select.select&#039;).attr(&#039;disabled&#039;, true);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q2ID+&#039; td.item input.text&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
           if ($(this).val() == &#039;&#039;) {&lt;br /&gt;
&lt;br /&gt;
               $(&#039;#question&#039;+q2ID+&#039; select.select&#039;).attr(&#039;disabled&#039;, false);&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FOR BOTH FILTER AND RANKING QUESTIONS ON SAME PAGE:&#039;&#039;&#039;&lt;br /&gt;
*Create a multiple options question and a ranking question on the same page (in the same group).&lt;br /&gt;
*Both questions &#039;&#039;&#039;MUST&#039;&#039;&#039; have identical sub-questions and sub-question codes.&lt;br /&gt;
*Place the following script in the source of one of the questions.&lt;br /&gt;
*Replace &amp;quot;MM&amp;quot; with the ID of the multiple options question and &amp;quot;RR&amp;quot; with the ID of the ranking question.&lt;br /&gt;
*The function will hide the ranking question unless at least two options are selected in the multiple options question, in which case, it will only show the options selected.&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       rankFilter(MM, RR);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FOR FILTER AND RANKING QUESTIONS ON SEPARATE PAGES:&#039;&#039;&#039;&lt;br /&gt;
*Create a multiple options question on page 1.&lt;br /&gt;
*Create a multiple options question and a ranking question on page 2.&lt;br /&gt;
*All three questions &#039;&#039;&#039;MUST&#039;&#039;&#039; have identical sub-questions and sub-question codes.&lt;br /&gt;
*Set the multiple options on page 2 to be filtered by the multiple options on page 1.&lt;br /&gt;
*Place the following script in the source of one of the questions on page 2.&lt;br /&gt;
*Replace &amp;quot;MM&amp;quot; with the ID of the multiple options question and &amp;quot;RR&amp;quot; with the ID of the ranking question. Do not modify the &amp;quot;1&amp;quot;.&lt;br /&gt;
*The function will hide the multiple options question. If at least 2 options were selected in the multiple options on page 1, the corresponding options will be checked in the hidden multiple options question which will then be used to control the display of the ranking question.&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       rankFilter(MM, RR, 1);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Filter &amp;quot;Array by Column&amp;quot; Question With &amp;quot;Multiple-Options&amp;quot;=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.91, IE 7/8, FireFox 3/4, Safari 5.0, Chrome 10.0&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround applies a filter to an &amp;quot;Array by Column&amp;quot; question based on the checked boxes of a previous multiple-options question. There are two methods - one for filter and array questions being on the same page and a slightly different one for the filter question being on a page before the array question.&lt;br /&gt;
&lt;br /&gt;
There is a [http://www.partnersinc.biz/surveys//index.php?sid=74213&amp;amp;newtest;=Y&amp;amp;lang;=en demo of both methods here].&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FOR BOTH METHODS:&#039;&#039;&#039;&lt;br /&gt;
*[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_ Set up your survey to use JavaScript].&lt;br /&gt;
*Place the following scripts in your template.js file. These functions will be accessed by either method.&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
   function filterArrByCol(qMultiOpt, qArray, prevPage) {&lt;br /&gt;
&lt;br /&gt;
       // If filter question is on a previous page, hide Q1 and check all &amp;quot;visible&amp;quot; boxes&lt;br /&gt;
&lt;br /&gt;
       if(prevPage == 1) {&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qMultiOpt+&#039; li[id&amp;lt;/div&amp;gt;=&amp;quot;javatbd&amp;quot;]:visible input.checkbox&#039;).attr(&#039;checked&#039;, true);&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qMultiOpt+&#039;&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       // Assign classes to the answer cells&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+qArray+&#039; table.question tbody td&#039;).each(function(i){&lt;br /&gt;
&lt;br /&gt;
           var classArr = $(this).attr(&#039;class&#039;).split(&#039;answer_cell_00&#039;);&lt;br /&gt;
&lt;br /&gt;
           var ansCode = classArr[1];&lt;br /&gt;
&lt;br /&gt;
           $(this).addClass(&#039;ans-&#039;+ansCode+&#039; filtered&#039;);&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // Assign classes to the answer label cells&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+qArray+&#039; table.question tbody tr:eq(0) td&#039;).each(function(i){&lt;br /&gt;
&lt;br /&gt;
           var classArr2 = $(this).attr(&#039;class&#039;).split(&#039; ans-&#039;);&lt;br /&gt;
&lt;br /&gt;
           var ansCode2 = classArr2[1];&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qArray+&#039; table.question thead tr:eq(0) th:eq(&#039;+i+&#039;)&#039;).addClass(&#039;ans-&#039;+ansCode2+&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // Fire the filter function on page load&lt;br /&gt;
&lt;br /&gt;
       filterArr(qMultiOpt, qArray);&lt;br /&gt;
&lt;br /&gt;
       // Listener on multi-opt checkboxes to fire the filter function&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+qMultiOpt+&#039; input.checkbox&#039;).click(function(){&lt;br /&gt;
&lt;br /&gt;
           filterArr(qMultiOpt, qArray);&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // On submit, clear all hidden radios of array&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#movenextbtn, #movesubmitbtn&#039;).click(function(){&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qArray+&#039; td.filtered:hidden&#039;).each(function(i){&lt;br /&gt;
&lt;br /&gt;
               $(&#039;input.radio&#039;, this).attr(&#039;checked&#039;, false);&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           return true;&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   function filterArr(qMultiOpt, qArray) {&lt;br /&gt;
&lt;br /&gt;
       if($(&#039;#question&#039;+qMultiOpt+&#039; input.checkbox:checked&#039;).length &amp;lt; 1) {&lt;br /&gt;
&lt;br /&gt;
           // Hide the array if no multi-opt options are checked&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qArray+&#039;&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       else {&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qArray+&#039;&#039;).show();&lt;br /&gt;
&lt;br /&gt;
           // Hide all columns of array&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qArray+&#039; table.question tbody td, #question&#039;+qArray+&#039; table.question thead th&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
           // Loop through multi-opt checkboxes and, if checked, show corresponding column of array&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qMultiOpt+&#039; input.checkbox&#039;).each(function(i){&lt;br /&gt;
&lt;br /&gt;
               if($(this).attr(&#039;checked&#039;) == true) {&lt;br /&gt;
&lt;br /&gt;
                   var classArr3 = $(this).attr(&#039;id&#039;).split(&#039;X&#039;+qMultiOpt);&lt;br /&gt;
&lt;br /&gt;
                   var ansCode3 = classArr3[1];&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;#question&#039;+qArray+&#039; .ans-&#039;+ansCode3+&#039;&#039;).show();&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FOR BOTH FILTER AND ARRAY QUESTIONS ON SAME PAGE:&#039;&#039;&#039;&lt;br /&gt;
*Create a multiple options question and an array-by-column question on the same page (in the same group).&lt;br /&gt;
*Both questions &#039;&#039;&#039;MUST&#039;&#039;&#039; have identical sub-questions and sub-question codes.&lt;br /&gt;
*Place the following script in the source of one of the questions.&lt;br /&gt;
*Replace &amp;quot;MM&amp;quot; with the ID of the multiple options question and &amp;quot;AA&amp;quot; with the ID of the ranking question.&lt;br /&gt;
*The function will hide the array question unless at least one option is selected in the multiple-options question, in which case, it will only show the corresponding array column(s).&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       filterArrByCol(MM, AA);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FOR FILTER AND ARRAY QUESTIONS ON SEPARATE PAGES:&#039;&#039;&#039;&lt;br /&gt;
*Create a multiple options question on page 1.&lt;br /&gt;
*Create a multiple options question and an array-by-column question on page 2.&lt;br /&gt;
*All three questions &#039;&#039;&#039;MUST&#039;&#039;&#039; have identical sub-questions and sub-question codes.&lt;br /&gt;
*Set the multiple options on page 2 to be filtered by the multiple options on page 1.&lt;br /&gt;
*Place the following script in the source of one of the questions on page 2.&lt;br /&gt;
*Replace &amp;quot;MM&amp;quot; with the ID of the multiple options question and &amp;quot;AA&amp;quot; with the ID of the array question. Do not modify the &amp;quot;1&amp;quot;.&lt;br /&gt;
*The function will hide the multiple options question. If options were selected in the multiple options on page 1, the corresponding options will be checked in the hidden multiple options question which will then be used to control the display of the array columns.&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       filterArrByCol(MM, AA, 1);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Auto-tabbing between text input fields=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 6/7, FireFox 3.0, Safari 3.2, Chrome 2.0&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This is a workaround to facilitate auto-tabbing between text input questions in a single group using a [http://plugins.jquery.com/project/autotab jQuery plugin by Mathachew] and the Maximum characters attribute of questions.&lt;br /&gt;
&lt;br /&gt;
The behaviour will be: When the maximum number of characters has been entered into an input field, the focus (cursor) will be automatically moved to the next input field. When the backspace key is used to remove all characters from a field, the focus will be moved to the previous field. It&#039;s very useful in surveys having many text input questions to avoid having to manually tab or click between fields.&lt;br /&gt;
&lt;br /&gt;
You can view a small demo survey [http://www.partnersinc.biz/surveys//index.php?sid=11327&amp;amp;newtest;=Y&amp;amp;lang;=en here].&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#Visit [http://plugins.jquery.com/node/4046 http://plugins.jquery.com/node/4046], download the plugin script and save it as &#039;&#039;jquery.autotab-1.1b.js&#039;&#039; in the template folder.&lt;br /&gt;
#Link to the script by placing &#039;&#039;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;{TEMPLATEURL}jquery.autotab-1.1b.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&#039;&#039; within the &#039;&#039;&amp;lt;head&amp;gt;&#039;&#039; tag of startpage.pstpl.&lt;br /&gt;
#[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_ Set up your survey to use JavaScript].&lt;br /&gt;
#Create the text based questions that auto-tabbing is to be applied to. (All must be in the same group if you&#039;re using group by group presentation)&lt;br /&gt;
#Define a Maximum characters attribute for all questions that the autotab is applied to. (See [http://docs.limesurvey.org/tiki-index.php?page=Question+attributes&amp;amp;structure;=English+Instructions+for+LimeSurvey#maximum_chars documentation here])&lt;br /&gt;
#In the source of the first question of the group that contains the auto-tabbed questions, add the following code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#answerSSSSSXGGXAA&#039;).focus(); //initially focus on the first input&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#answerSSSSSXGGXAA&#039;).autotab({ target: &#039;answerSSSSSXGGXBB&#039; });&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#answerSSSSSXGGXBB&#039;).autotab({ previous: &#039;answerSSSSSXGGXAA&#039;, target: &#039;answerSSSSSXGGXCC&#039; });&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#answerSSSSSXGGXCC&#039;).autotab({ previous: &#039;answerSSSSSXGGXBB&#039;, target: &#039;answerSSSSSXGGXDD&#039; });&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#answerSSSSSXGGXDD&#039;).autotab({ previous: &#039;answerSSSSSXGGXCC&#039; });&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example has 4 fields to be auto-tabbed between - all instances of the following must be replaced to be compatible with your survey (See image below):&lt;br /&gt;
*SSSSS -&amp;gt; Survey ID&lt;br /&gt;
*GG -&amp;gt; Group ID&lt;br /&gt;
*AA -&amp;gt; First question&lt;br /&gt;
*BB -&amp;gt; Second question&lt;br /&gt;
*CC -&amp;gt; Third question&lt;br /&gt;
*DD -&amp;gt; Last question&lt;br /&gt;
&lt;br /&gt;
[[File:ids_343x252.gif]]&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;target&#039;&#039; parameter defines where the next input is and the &#039;&#039;previous&#039;&#039; parameter defines (you guessed it) the previous input.&lt;br /&gt;
&lt;br /&gt;
This plugin also has limited capability of formatting the input text - see comments in the plugin script.&lt;br /&gt;
&lt;br /&gt;
=Custom response listeners=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.85+ (7253), IE 6/7, FireFox 3.0, Safari 3.2, Chrome 2.0&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Listeners can be used to perform functions when a change in an input is detected. There are many uses such as the [http://docs.limesurvey.org/tiki-index.php?page=Workarounds#Reverse_array_filter Reverse array_filter] but a simple one would be to warn a respondent if they enter a value that may be too high.&lt;br /&gt;
&lt;br /&gt;
We can use the [http://docs.jquery.com/Events/change jQuery change( ) event] to fire a function whenever there is a change to the input. The function will look for an input value higher than 10 and, if found, will warn the respondent.&lt;br /&gt;
#[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_ Set up your survey to use JavaScript].&lt;br /&gt;
#Place the script below in the source of one of the questions on the page where:&lt;br /&gt;
**11111 is the survey ID&lt;br /&gt;
**22 is the group ID&lt;br /&gt;
**33 is the question ID&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#answer11111X22X33&#039;).change(function() {&lt;br /&gt;
&lt;br /&gt;
           if ( $(&#039;#answer11111X22X33&#039;).val() &amp;gt; 10 ) {&lt;br /&gt;
&lt;br /&gt;
               alert (&amp;quot;That&#039;s an awful lot. Are you sure?&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Text input masks=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 7, FireFox 3.0, Safari 3.2, Chrome 2.0&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;We&#039;re considering adding this as a built-in feature for version 1.92 (e.g. an advanced question attribute).&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There may be instances where you would like to place a mask on a text input - for example only allowing respondents to enter the correct characters for a North American phone number [[Expression Manager|Expression Manager]] rand() function.  This can be part of a relevance equation to randomly control which questions are shown; or you can create an Equation question type to store the random value, and let that question be part of downstream relevance equations.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround allows you to generate a random number and then populate a hidden question with that number. You can then use this question to control the display of subsequent questions with [http://docs.limesurvey.org/tiki-index.php?page=Setting+conditions&amp;amp;structure;=English+Instructions+for+LimeSurvey Conditions]. It&#039;s useful if you have several sets of questions that you would like to randomly present to participants - see this  [http://www.limesurvey.org/en/support/forums/5-can-i-do-this-with-limesurvey/29579-experiment-with-random-questions.html forum post].&lt;br /&gt;
&lt;br /&gt;
There is a small demo [http://www.partnersinc.biz/surveys//index.php?sid=12659&amp;amp;newtest;=Y&amp;amp;lang;=en here].&lt;br /&gt;
&lt;br /&gt;
In the demo, in the first group, we generate a random number between 1 and 4 and populate a hidden question with it. Then in the second group we have 4 questions, each showing conditional on the answer of the first question.&lt;br /&gt;
&lt;br /&gt;
Implementation for this demo is as follows:&lt;br /&gt;
#Turn off &#039;&#039;$filterxsshtml&#039;&#039; to allow insertion of JavaScript in the questions. (See [http://docs.limesurvey.org/tiki-index.php?page=Optional+settings&amp;amp;structure;=English+Instructions+for+LimeSurvey#Filtering_dangerous_HTML_tags_in_survey_objects documentation here])&lt;br /&gt;
#Set up the template to use custom onload functions. (See the [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#Custom_onload_function workaround here])&lt;br /&gt;
#In the first group add a &amp;quot;Short free text&amp;quot; question (We&#039;re going to hide this with JavaScript)&lt;br /&gt;
#In the source of that question add the following onload function. (See [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._ How to use script here])&lt;br /&gt;
#In the following groups add the questions that are conditional on the answer of the first question.&lt;br /&gt;
&lt;br /&gt;
Onload code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
function Custom_On_Load(){&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Find a random number between 1 and 4&lt;br /&gt;
&lt;br /&gt;
       var randNumber = Math.floor(Math.random()*4 + 1);&lt;br /&gt;
&lt;br /&gt;
       // Populate and hide the hidden question&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input#answerSSSSSXGGXQQ&#039;).val(randNumber);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#questionQQ&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
       /***********************************************************/&lt;br /&gt;
&lt;br /&gt;
       // This just tells the user which number has been selected&lt;br /&gt;
&lt;br /&gt;
       // You can remove this from your onload function&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input#setNumber&#039;).val(randNumber);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input#setNumber&#039;).css({&lt;br /&gt;
&lt;br /&gt;
           &#039;margin-left&#039;:&#039;0.5em&#039;,&lt;br /&gt;
&lt;br /&gt;
           &#039;width&#039;:&#039;1.5em&#039;,&lt;br /&gt;
&lt;br /&gt;
           &#039;text-align&#039;:&#039;center&#039;,&lt;br /&gt;
&lt;br /&gt;
           &#039;font-weight&#039;:&#039;bold&#039;&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input#setNumber&#039;).attr(&#039;disabled&#039;, true);&lt;br /&gt;
&lt;br /&gt;
       /***********************************************************/&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &#039;&#039;&#039;SSSSS&#039;&#039;&#039; is the survey ID, &#039;&#039;&#039;GG&#039;&#039;&#039; is the group ID and &#039;&#039;&#039;QQ&#039;&#039;&#039; is the hidden question ID.&lt;br /&gt;
&lt;br /&gt;
Increase or decrease the maximum value of the random number by modifying the first section. For example to get a number between 1 and 10 you would use this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
var randNumber = Math.floor(Math.random()*10 + 1);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The third section of code just populates a placeholder element that I use to tell the participant what&#039;s going on. You can remove it from your code.&lt;br /&gt;
&lt;br /&gt;
=Minimum number of required answers in an array=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 6/7, FireFox 3.0, Safari 3.2,&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92 all array style questions have the min_answers and max_answers options, so this script is obsolete.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround allows you to specify a &#039;&#039;&#039;minimum number&#039;&#039;&#039; of answers required in an array question. It is an alternative to the &amp;quot;Mandatory&amp;quot; parameter which specifies that &#039;&#039;&#039;all&#039;&#039;&#039; answers are required. It could also be easily modified to specify a maximum number of answers.&lt;br /&gt;
&lt;br /&gt;
We accomplish this by placing an onload function in the source of the array question. This function hides the Next/Submit button and displays a warning element until it detects a minimum number of responses. It then hides the warning and shows the Next/Submit button.&lt;br /&gt;
&lt;br /&gt;
There is a demo [http://www.partnersinc.biz/surveys//index.php?sid=97166&amp;amp;newtest;=Y&amp;amp;lang;=en here].&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#Turn off &#039;&#039;$filterxsshtml&#039;&#039; to allow insertion of JavaScript in the questions. (See [http://docs.limesurvey.org/tiki-index.php?page=Optional+settings&amp;amp;structure;=English+Instructions+for+LimeSurvey#Filtering_dangerous_HTML_tags_in_survey_objects documentation here])&lt;br /&gt;
#Set up the template to use custom onload functions. (See the [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#Custom_onload_function workaround here])&lt;br /&gt;
#In the source of the array question add the following onload function. (See [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._ How to use script here])&lt;br /&gt;
#Modify the &#039;&#039;SETTINGS&#039;&#039; section of the code as required.&lt;br /&gt;
&lt;br /&gt;
Onload code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Wait until the document is fully loaded&lt;br /&gt;
&lt;br /&gt;
$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
   /********************** SETTINGS **********************/&lt;br /&gt;
&lt;br /&gt;
   // The text to appear in the warning element&lt;br /&gt;
&lt;br /&gt;
   var warningText = &#039;Please answer at least 4 to continue&#039;;&lt;br /&gt;
&lt;br /&gt;
   // The question ID&lt;br /&gt;
&lt;br /&gt;
   var questionId = 137;&lt;br /&gt;
&lt;br /&gt;
   // The minimum number of answers required&lt;br /&gt;
&lt;br /&gt;
   var minNumber = 4;&lt;br /&gt;
&lt;br /&gt;
   /******************************************************/&lt;br /&gt;
&lt;br /&gt;
   // Create the warning element and place it after the submit button&lt;br /&gt;
&lt;br /&gt;
   var el = document.createElement(&#039;div&#039;);&lt;br /&gt;
&lt;br /&gt;
   el.setAttribute(&#039;id&#039;,&#039;warning&#039;);&lt;br /&gt;
&lt;br /&gt;
   document.body.appendChild(el);&lt;br /&gt;
&lt;br /&gt;
   $( &#039;#warning&#039; ).css({&lt;br /&gt;
&lt;br /&gt;
       &#039;border&#039;:&#039;1px solid #333333&#039;,&lt;br /&gt;
&lt;br /&gt;
       &#039;width&#039;:&#039;200px&#039;,&lt;br /&gt;
&lt;br /&gt;
       &#039;padding&#039;:&#039;3px&#039;,&lt;br /&gt;
&lt;br /&gt;
       &#039;color&#039;:&#039;red&#039;&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#warning&#039;).html(warningText);&lt;br /&gt;
&lt;br /&gt;
   $(&#039;input[type=&amp;quot;submit&amp;quot;]&#039;).after($(&#039;#warning&#039;));&lt;br /&gt;
&lt;br /&gt;
   // Detect the initial number of checked answers &amp;amp; display Next/Submit button accordingly&lt;br /&gt;
&lt;br /&gt;
   var inputInitCount = 0;&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#question&#039; + questionId + &#039; input&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
       if ($( this ).attr(&#039;checked&#039;) == true ) {&lt;br /&gt;
&lt;br /&gt;
           inputInitCount++;&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   if (inputInitCount &amp;gt; (minNumber - 1)) {&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input[type=&amp;quot;submit&amp;quot;]&#039;).show();&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#warning&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   else {&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#warning&#039;).show();&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input[type=&amp;quot;submit&amp;quot;]&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   // Listener to detect number of checked answers &amp;amp; display Next/Submit button accordingly&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#question&#039; + questionId + &#039; input.radio, #question&#039;+questionId+&#039; tbody[id&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&amp;quot;javatbd&amp;quot;] td&#039;).click(function() {&lt;br /&gt;
&lt;br /&gt;
       var inputCount = 0;&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039; + questionId + &#039; input.radio&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
           if ($( this ).attr(&#039;checked&#039;) == true ) {&lt;br /&gt;
&lt;br /&gt;
               inputCount++;&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       if (inputCount &amp;gt; (minNumber - 1)) {&lt;br /&gt;
&lt;br /&gt;
           $(&#039;input[type=&amp;quot;submit&amp;quot;]&#039;).show();&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#warning&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       else {&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#warning&#039;).show();&lt;br /&gt;
&lt;br /&gt;
           $(&#039;input[type=&amp;quot;submit&amp;quot;]&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       // The original functions of the click event&lt;br /&gt;
&lt;br /&gt;
       checkconditions(this.value, this.name, this.type);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Minimum elapsed time before moving forward in survey=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.91, IE 7/8, Firefox 7.0, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround interrupts the Next/Submit function and checks the amount of time elapsed since the page loaded. If the time is less than the minimum dictated, the respondent is alerted and not allowed to proceed. It is useful if you want to enforce a minimum amount of time spent viewing a page.&lt;br /&gt;
#[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_ Set up your survey to use JavaScript].&lt;br /&gt;
#Place the script below in the source of one of the questions on the page, replacing &amp;quot;TT&amp;quot; with the minimum number of seconds required before advancing is allowed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       minTime(TT);&lt;br /&gt;
&lt;br /&gt;
       function minTime(minTime) {&lt;br /&gt;
&lt;br /&gt;
           var startTime = new Date();&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#movenextbtn, #movesubmitbtn&#039;).click(function(){&lt;br /&gt;
&lt;br /&gt;
               var endTime = new Date();&lt;br /&gt;
&lt;br /&gt;
               if[[endTime - startTime)/1000 &amp;lt;= minTime) {&lt;br /&gt;
&lt;br /&gt;
                    alert (&#039;You must spend at least &#039;+minTime+&#039; seconds on the question.&#039;);&lt;br /&gt;
&lt;br /&gt;
                    return false;&lt;br /&gt;
&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
                else {&lt;br /&gt;
&lt;br /&gt;
                    return true;&lt;br /&gt;
&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
            });&lt;br /&gt;
&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 =Minimum number of characters in Long free text or Huge free text questions=&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with: 1.91, IE 7/8, Firefox 7.0, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/div&amp;gt;As of version 1.91, you can use regular expression masks (validation) to specify the minimum number of required characters.  However, even if the question is mandatory, it can still be blank.&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/div&amp;gt;As of version  1.92, if you make the question mandatory and use a validation mask to specify the minimum number of characters, then the user will be forced to answer the question.  Note that unlike 1.91, they can submit their current answers, even if partially invalid (so they are stored in the database), but they will not ber able to proceed to the next page until they have passed all mandatory and validity checks.&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 This workaround interrupts the Next/Submit function and checks the number of characters entered in a Long free text or Huge free text question. If the number is less than the minimum dictated, the respondent is alerted and not allowed to proceed.&lt;br /&gt;
&lt;br /&gt;
 #[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_|Set up your survey to use JavaScript].&lt;br /&gt;
&lt;br /&gt;
 #Place the script below in the source of one of the questions on the page, replace &amp;quot;QQ&amp;quot; with the question ID and &amp;quot;CC&amp;quot; with the minimum number of characters required before advancing is allowed.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
        minChar(QQ, CC);&lt;br /&gt;
&lt;br /&gt;
        function minChar(qID, minChars) {&lt;br /&gt;
&lt;br /&gt;
            $(&#039;#movenextbtn, #movesubmitbtn&#039;).click(function(){&lt;br /&gt;
&lt;br /&gt;
                if($(&#039;#question&#039;+qID+&#039; textarea&#039;).val().replace(/ /g,&#039;&#039;).length &amp;lt; minChars) {&lt;br /&gt;
&lt;br /&gt;
                    alert (&#039;You must enter at least &#039;+minChars+&#039; characters.&#039;);&lt;br /&gt;
&lt;br /&gt;
                    return false;&lt;br /&gt;
&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
                else {&lt;br /&gt;
&lt;br /&gt;
                    return true;&lt;br /&gt;
&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
            });&lt;br /&gt;
&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 =Variable Length Array (Multi Flexible Text) question=&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with: 1.90+, IE 6/7/8, FireFox 3.0, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 This workaround allows a respondent to add or remove rows of an Array (Multi Flexible Text) question. It&#039;s useful to avoid the page being cluttered with unnecessary array rows.&lt;br /&gt;
&lt;br /&gt;
 A function is placed in the template.js file of your template (use template editor). This function hides all of the array rows except the first and inserts two elements that when clicked show or hide rows accordingly.&lt;br /&gt;
&lt;br /&gt;
 There is a demo [http://www.partnersinc.biz/surveys//index.php?sid=53132&amp;amp;newtest;=Y&amp;amp;lang;=en|here].&lt;br /&gt;
&lt;br /&gt;
 It must be noted that you can not make this question Mandatory as the respondent will have no way to complete hidden fields. If you want the displayed fields to be mandatory you will need to validate them in another function or modify this function to only allow the addition of rows if all fields in the last row are completed and then disable those fields - that, however, is a little over the top for this example.&lt;br /&gt;
&lt;br /&gt;
 Implementation is as follows:&lt;br /&gt;
&lt;br /&gt;
 #Set up your survey to use JavaScript (See instructions [http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_|here])&lt;br /&gt;
&lt;br /&gt;
 #Add the following script to your &#039;&#039;template.js&#039;&#039; file.&lt;br /&gt;
&lt;br /&gt;
 #Replace &amp;quot;QQ&amp;quot; in the function call at the end with the question ID.&lt;br /&gt;
&lt;br /&gt;
 #Create one or more Array (Multi Flexible Text) questions&lt;br /&gt;
&lt;br /&gt;
 #If you want to apply it to more arrays on the same page simply add more calls with the appropriate question IDs. (eg. varLengthArray(1); varLengthArray(2);...)&lt;br /&gt;
&lt;br /&gt;
 Onload code:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
        // A function to add or remove rows of an Array (Multi Flexible)(Text) question&lt;br /&gt;
&lt;br /&gt;
        function varLengthArray(qID) {&lt;br /&gt;
&lt;br /&gt;
            if ($(&#039;#question&#039;+qID+&#039;&#039;).length &amp;gt; 0) {&lt;br /&gt;
&lt;br /&gt;
                // The HTML content of the Add/Remove elements - modify as you wish&lt;br /&gt;
&lt;br /&gt;
                var addContent = &#039;[+]&#039;;&lt;br /&gt;
&lt;br /&gt;
                var removeContent = &#039;[-]&#039;;&lt;br /&gt;
&lt;br /&gt;
                // Create the Add and Remove elements &amp;amp; insert them&lt;br /&gt;
&lt;br /&gt;
                var el1 = document.createElement(&#039;div&#039;);&lt;br /&gt;
&lt;br /&gt;
                el1.setAttribute(&#039;id&#039;,&#039;addButton&#039;+qID);&lt;br /&gt;
&lt;br /&gt;
                document.body.appendChild(el1);&lt;br /&gt;
&lt;br /&gt;
                var el2 = document.createElement(&#039;div&#039;);&lt;br /&gt;
&lt;br /&gt;
                el2.setAttribute(&#039;id&#039;,&#039;removeButton&#039;+qID);&lt;br /&gt;
&lt;br /&gt;
                document.body.appendChild(el2);&lt;br /&gt;
&lt;br /&gt;
                // Move them to after the array&lt;br /&gt;
&lt;br /&gt;
                $( &#039;div#addButton&#039;+qID ).appendTo($( &#039;#question&#039; + qID + &#039; table.question&#039; ).parent(]];&lt;br /&gt;
&lt;br /&gt;
               $( &#039;div#removeButton&#039;+qID ).appendTo($( &#039;#question&#039; + qID + &#039; table.question&#039; ).parent());&lt;br /&gt;
&lt;br /&gt;
               // Insert their HTML&lt;br /&gt;
&lt;br /&gt;
               $( &#039;div#addButton&#039;+qID ).html( addContent );&lt;br /&gt;
&lt;br /&gt;
               $( &#039;div#removeButton&#039;+qID ).html( removeContent );&lt;br /&gt;
&lt;br /&gt;
               // Style the elements - you can modify here if you wish&lt;br /&gt;
&lt;br /&gt;
               $( &#039;div#addButton&#039;+qID ).css({&lt;br /&gt;
&lt;br /&gt;
                   &#039;margin&#039;:&#039;10px 0 0 10px&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;padding&#039;:&#039;1px&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;text-align&#039;:&#039;center&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;font-weight&#039;:&#039;bold&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;width&#039;:&#039;auto&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;cursor&#039;:&#039;pointer&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;float&#039;:&#039;left&#039;&lt;br /&gt;
&lt;br /&gt;
               });&lt;br /&gt;
&lt;br /&gt;
               $( &#039;div#removeButton&#039;+qID ).css({&lt;br /&gt;
&lt;br /&gt;
                   &#039;margin&#039;:&#039;10px 0 0 10px&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;padding&#039;:&#039;1px&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;text-align&#039;:&#039;center&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;font-weight&#039;:&#039;bold&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;width&#039;:&#039;auto&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;cursor&#039;:&#039;pointer&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;float&#039;:&#039;left&#039;&lt;br /&gt;
&lt;br /&gt;
               });&lt;br /&gt;
&lt;br /&gt;
               // Initially hide the Remove element&lt;br /&gt;
&lt;br /&gt;
               $( &#039;div#removeButton&#039;+qID ).hide();&lt;br /&gt;
&lt;br /&gt;
               // Call the functions below when clicked&lt;br /&gt;
&lt;br /&gt;
               $( &#039;div#addButton&#039;+qID ).click(function (event) {&lt;br /&gt;
&lt;br /&gt;
                   addRow(qID);&lt;br /&gt;
&lt;br /&gt;
               });&lt;br /&gt;
&lt;br /&gt;
               $( &#039;div#removeButton&#039;+qID ).click(function (event) {&lt;br /&gt;
&lt;br /&gt;
                   removeRow(qID);&lt;br /&gt;
&lt;br /&gt;
               });&lt;br /&gt;
&lt;br /&gt;
               // Function to add a row, also shows the Remove element and hides the&lt;br /&gt;
&lt;br /&gt;
               //Add element if all rows are shown&lt;br /&gt;
&lt;br /&gt;
               function addRow(qID) {&lt;br /&gt;
&lt;br /&gt;
                   var arrayRow = &#039;#question&#039; + qID + &#039; table.question tbody&#039;;&lt;br /&gt;
&lt;br /&gt;
                   var rowCount = $( arrayRow ).size() - 1;&lt;br /&gt;
&lt;br /&gt;
                   $( arrayRow + &#039;[name=&amp;quot;hidden&amp;quot;]:first&#039; ).attr(&#039;name&#039;, &#039;visible&#039;).show();&lt;br /&gt;
&lt;br /&gt;
                   $( &#039;div#removeButton&#039;+qID ).show();&lt;br /&gt;
&lt;br /&gt;
                   if ( $( arrayRow + &#039;:eq(&#039; + rowCount + &#039;)&#039; ).attr(&#039;name&#039;) == &#039;visible&#039; )  {&lt;br /&gt;
&lt;br /&gt;
                       $( &#039;div#addButton&#039;+qID ).hide();&lt;br /&gt;
&lt;br /&gt;
                   }&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               // Function to remove a row, also clears the contents of the removed row,&lt;br /&gt;
&lt;br /&gt;
               // shows the Add element if the last row is hidden and hides the Remove&lt;br /&gt;
&lt;br /&gt;
               // element if only the first row is shown&lt;br /&gt;
&lt;br /&gt;
               function removeRow(qID) {&lt;br /&gt;
&lt;br /&gt;
                   var arrayRow = &#039;#question&#039; + qID + &#039; table.question tbody&#039;;&lt;br /&gt;
&lt;br /&gt;
                   var rowCount = $( arrayRow ).size() - 1;&lt;br /&gt;
&lt;br /&gt;
                   $( arrayRow + &#039;[name=&amp;quot;visible&amp;quot;]:last input[type=&amp;quot;text&amp;quot;]&#039; ).val(&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
                   $( arrayRow + &#039;[name=&amp;quot;visible&amp;quot;]:last&#039; ).attr(&#039;name&#039;, &#039;hidden&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
                   $( &#039;div#addButton&#039;+qID ).show();&lt;br /&gt;
&lt;br /&gt;
                   if ( $( arrayRow + &#039;:eq(1)&#039; ).attr(&#039;name&#039;) == &#039;hidden&#039; )  {&lt;br /&gt;
&lt;br /&gt;
                       $( &#039;div#removeButton&#039;+qID ).hide();&lt;br /&gt;
&lt;br /&gt;
                   }&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               // Just some initialization stuff&lt;br /&gt;
&lt;br /&gt;
               var arrayRow = &#039;#question&#039; + qID + &#039; table.question tbody&#039;;&lt;br /&gt;
&lt;br /&gt;
               var rowCount = &#039;&#039;;&lt;br /&gt;
&lt;br /&gt;
               // Initially hide all except first row or any rows with populated inputs&lt;br /&gt;
&lt;br /&gt;
               $( arrayRow ).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
                   if ( i &amp;gt; 0 ) {&lt;br /&gt;
&lt;br /&gt;
                       // We also need to give the hidden rows a name cause IE doesn&#039;t&lt;br /&gt;
&lt;br /&gt;
                       // recognize jQuery :visible selector consistently&lt;br /&gt;
&lt;br /&gt;
                       $( this ).attr(&#039;name&#039;, &#039;hidden&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
                       $(&#039;input[type=text]&#039;, this).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
                           if ($(this).attr(&#039;value&#039;) != &#039;&#039;) {&lt;br /&gt;
&lt;br /&gt;
                               $(this).parents(&#039;tbody:eq(0)&#039;).attr(&#039;name&#039;, &#039;visible&#039;).show();&lt;br /&gt;
&lt;br /&gt;
                               $( &#039;div#removeButton&#039;+qID ).show();&lt;br /&gt;
&lt;br /&gt;
                           }&lt;br /&gt;
&lt;br /&gt;
                       });&lt;br /&gt;
&lt;br /&gt;
                       rowCount = i;&lt;br /&gt;
&lt;br /&gt;
                   }&lt;br /&gt;
&lt;br /&gt;
               });&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       // Call the function with a question ID&lt;br /&gt;
&lt;br /&gt;
       varLengthArray(QQ);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Expandable Array=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 6/7, FireFox 3.5, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround allows you to present an array question incrementally. That is to say that initially only the first option (row) in the array is shown. When that option is answered the next is shown and so-on.&lt;br /&gt;
&lt;br /&gt;
A JavaScript function is placed in the source of the array question. This function hides all of the array rows except the first and then displays them as options are answered.&lt;br /&gt;
&lt;br /&gt;
There is a demo [http://www.partnersinc.biz/surveys//index.php?sid=94958&amp;amp;newtest;=Y&amp;amp;lang;=en here].&lt;br /&gt;
&lt;br /&gt;
The workaround supports following question types:&lt;br /&gt;
*Array (flexible labels)&lt;br /&gt;
*Array (flexible labels) by column&lt;br /&gt;
*Array (Yes/No/Uncertain)&lt;br /&gt;
*Array (Increase, Same, Decrease)&lt;br /&gt;
*Array (Flexible Labels) dual scale&lt;br /&gt;
*Array (10 point choice)&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#Set up your survey to use JavaScript. (See [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._ documentation here])&lt;br /&gt;
#Create one or more Array questions&lt;br /&gt;
#In the source of the first array question add the following script.&lt;br /&gt;
#Replace &amp;quot;QQ&amp;quot; in the function call at the end of the script with the question ID of the array you would like to manipulate.&lt;br /&gt;
#If you want to apply it to more arrays on the same page, simply add more calls with the appropriate question IDs. (eg. expandingArray(1); expandingArray(2);...)&lt;br /&gt;
&lt;br /&gt;
Onload code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // A function to show subsequent rows of an array as options are checked&lt;br /&gt;
&lt;br /&gt;
       function expandingArray(qID) {&lt;br /&gt;
&lt;br /&gt;
           // Build an array of the question rows&lt;br /&gt;
&lt;br /&gt;
           var arrayRow = &#039;#question&#039; + qID + &#039; table.question tbody tr&#039;;&lt;br /&gt;
&lt;br /&gt;
           // Initially hide all rows unless an input was previously checked&lt;br /&gt;
&lt;br /&gt;
           $( arrayRow ).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
               if ( $( arrayRow  + &#039;:eq(&#039; + i + &#039;) input.radio:checked&#039; ).length != 0 ) {&lt;br /&gt;
&lt;br /&gt;
                   $( this ).attr(&#039;name&#039;, &#039;clickedRow&#039;);&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               else {&lt;br /&gt;
&lt;br /&gt;
                   $( this ).attr(&#039;name&#039;, &#039;hidden&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Now show the first hidden row&lt;br /&gt;
&lt;br /&gt;
           addRow();&lt;br /&gt;
&lt;br /&gt;
           // Add another row when an option is checked for the first time&lt;br /&gt;
&lt;br /&gt;
           $( &#039;#question&#039; + qID + &#039; td.answer input.radio&#039; ).click(function (event) {&lt;br /&gt;
&lt;br /&gt;
               if ($( this ).parents(&#039;tr:eq(0)&#039;).attr(&#039;name&#039;) != &#039;clickedRow&#039;) {&lt;br /&gt;
&lt;br /&gt;
                   addRow();&lt;br /&gt;
&lt;br /&gt;
                   $( this ).parents(&#039;tr:eq(0)&#039;).attr(&#039;name&#039;, &#039;clickedRow&#039;);&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               // The original function of the click event&lt;br /&gt;
&lt;br /&gt;
               checkconditions(this.value, this.name, this.type);&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Add another row when an table cell is clicked for the first time&lt;br /&gt;
&lt;br /&gt;
           $( &#039;#question&#039; + qID + &#039; table.question tbody td&#039; ).click(function (event) {&lt;br /&gt;
&lt;br /&gt;
               if ($( this ).parents(&#039;tr:eq(0)&#039;).attr(&#039;name&#039;) != &#039;clickedRow&#039;) {&lt;br /&gt;
&lt;br /&gt;
                   addRow();&lt;br /&gt;
&lt;br /&gt;
                   $( this ).parents(&#039;tr:eq(0)&#039;).attr(&#039;name&#039;, &#039;clickedRow&#039;);&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Function to add a row&lt;br /&gt;
&lt;br /&gt;
           function addRow() {&lt;br /&gt;
&lt;br /&gt;
               $( arrayRow + &#039;[name=&amp;quot;hidden&amp;quot;]:first&#039; ).attr(&#039;name&#039;, &#039;visible&#039;).show();&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       // Call the function with a question ID&lt;br /&gt;
&lt;br /&gt;
       expandingArray(QQ);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Partially Randomized Answers - Multiple Options &amp;amp; List (radio) questions=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 6/7, FireFox 3.0, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround allows the answers of Multiple Options &amp;amp; List (radio) questions to be randomized while always keeping one answer at the end of the list. It&#039;s useful if you want to randomize, say, the first 4 of your answers but always have the fifth displayed last as in the image below:&lt;br /&gt;
&lt;br /&gt;
[[File:random_336x179gif.gif]]&lt;br /&gt;
&lt;br /&gt;
An onload function is placed in the source of a question. After the randomizing has occurred this function moves the answer with the highest answer code to the end of the list.&lt;br /&gt;
&lt;br /&gt;
There is a demo [http://www.partnersinc.biz/surveys//index.php?sid=89344&amp;amp;newtest;=Y&amp;amp;lang;=en here].&lt;br /&gt;
&lt;br /&gt;
Some conditions on the use of this are:&lt;br /&gt;
*For Select/radio type questions it will only work if the [http://docs.limesurvey.org/tiki-index.php?page=Optional+settings&amp;amp;structure;=English+Instructions+for+LimeSurvey#Survey_Behavior $shownoanswer option] is set to 0 in config.php. (&amp;quot;No answer&amp;quot; is removed from the end of questions)&lt;br /&gt;
*You must use sequential numbers, starting at 1 as response codes. (See image below)&lt;br /&gt;
&lt;br /&gt;
[[File:random_700x154.png]]&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#Turn off &#039;&#039;$filterxsshtml&#039;&#039; to allow insertion of JavaScript in the questions. (See [http://docs.limesurvey.org/tiki-index.php?page=Optional+settings&amp;amp;structure;=English+Instructions+for+LimeSurvey#Filtering_dangerous_HTML_tags_in_survey_objects documentation here])&lt;br /&gt;
#Create one or more Multiple Options or List (radio) questions with sequential response codes. Set the [http://docs.limesurvey.org/tiki-index.php?page=Question+attributes&amp;amp;structure;=English+Instructions+for+LimeSurvey#random_order random_order question attribute] to 1.&lt;br /&gt;
#In the source of the first question add the following onload function. (See [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._ How to use script here])&lt;br /&gt;
#Replace &amp;quot;SSSSS&amp;quot;, &amp;quot;GG&amp;quot;, &amp;quot;QQ&amp;quot; in the function call at the end with the survey ID, group ID and question ID respectively.&lt;br /&gt;
#If you want to apply it to more questions on the same page simply add more calls with the appropriate IDs. (eg. partRand(11111, 22, 1); partRand(11111, 22, 2); ...)&lt;br /&gt;
&lt;br /&gt;
Onload code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Function to allow randomization of all answers except the last one in Multiple options and List/radio questions&lt;br /&gt;
&lt;br /&gt;
       function partRand(sID, gID, qID) {&lt;br /&gt;
&lt;br /&gt;
           // Find the number of answers&lt;br /&gt;
&lt;br /&gt;
           var ansCount = &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
           $( &#039;div#question&#039; + qID + &#039; td.answer li&#039; ).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
               ansCount = (i + 1);&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Place the last answer created at the end of the list&lt;br /&gt;
&lt;br /&gt;
           $( &#039;input#answer&#039; + sID + &#039;X&#039; + gID + &#039;X&#039; + qID + ansCount + &#039;&#039; ).parent().appendTo($( &#039;#question&#039; + qID + &#039; td.answer ul&#039; ));&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       // Call the function with the SID, GID and QID&lt;br /&gt;
&lt;br /&gt;
       partRand(SSSSS, GG, QQ);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Partially Randomized Answers - List (dropdown) questions=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 6/7, FireFox 3.0, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround, similar to the one above, allows the answers of List (dropdown) questions to be randomized while always keeping one answer at the end of the list. It&#039;s useful if you want to randomize, say, the first 4 of your answers but always have the fifth displayed last.&lt;br /&gt;
&lt;br /&gt;
An onload function is placed in the source of a question. After the randomizing has occurred this function moves the answer with the highest answer code to the end of the list.&lt;br /&gt;
&lt;br /&gt;
There is a demo [http://www.partnersinc.biz/surveys//index.php?sid=89344&amp;amp;newtest;=Y&amp;amp;lang;=en here].&lt;br /&gt;
&lt;br /&gt;
A condition is that you must use sequential numbers, starting at 1 as response codes. (See image below)&lt;br /&gt;
&lt;br /&gt;
[[File:random_700x154.png]]&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#Turn off &#039;&#039;$filterxsshtml&#039;&#039; to allow insertion of JavaScript in the questions. (See [http://docs.limesurvey.org/tiki-index.php?page=Optional+settings&amp;amp;structure;=English+Instructions+for+LimeSurvey#Filtering_dangerous_HTML_tags_in_survey_objects documentation here])&lt;br /&gt;
#Create one or more List (dropdown) questions with sequential response codes. Set the [http://docs.limesurvey.org/tiki-index.php?page=Question+attributes&amp;amp;structure;=English+Instructions+for+LimeSurvey#random_order random_order question attribute] to 1.&lt;br /&gt;
#In the source of the first question add the following onload function. (See [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._ How to use script here])&lt;br /&gt;
#Replace &amp;quot;SSSSS&amp;quot;, &amp;quot;GG&amp;quot;, &amp;quot;QQ&amp;quot; in the function call at the end with the survey ID, group ID and question ID respectively.&lt;br /&gt;
#If you want to apply it to more questions on the same page simply add more calls with the appropriate IDs. (eg. partRandDD(11111, 22, 1); partRandDD(11111, 22, 2); ...)&lt;br /&gt;
&lt;br /&gt;
Onload code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
   // Function to allow randomization of all answers&lt;br /&gt;
&lt;br /&gt;
   //except the last one in List/dropdown questions&lt;br /&gt;
&lt;br /&gt;
   function partRandDD(sID, gID, qID) {&lt;br /&gt;
&lt;br /&gt;
       // Find the number of answers&lt;br /&gt;
&lt;br /&gt;
       var ansCount = &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
       $( &#039;div#question&#039; + qID + &#039; select option&#039; ).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
           ansCount = i;&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // Place the last answer created at the end of the list&lt;br /&gt;
&lt;br /&gt;
$( &#039;option[value=&amp;quot;&#039; + ansCount + &#039;&amp;quot;]&#039; ).appendTo($( &#039;div#question&#039; + qID + &#039; select&#039; ));&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   // Call the function with the SID, GID and QID&lt;br /&gt;
&lt;br /&gt;
   partRandDD(89344, 72, 244);&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Partially Randomized Answers - Multiple numerical input=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, Safari 5.1&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround, similar to the ones above, allows the answers of Multiple numerical input questions to be randomized while always keeping one answer at the end of the list. It&#039;s useful if you want to randomize, say, the first 4 of your answers but always have the fifth displayed last.&lt;br /&gt;
&lt;br /&gt;
An onload function is placed in the source of a question. After the randomizing has occurred this function moves the answer with the highest answer code to the end of the list.&lt;br /&gt;
&lt;br /&gt;
A condition is that you must use sequential numbers, starting at 1 as response codes. (See image below)&lt;br /&gt;
&lt;br /&gt;
[[File:random_700x154.png]]&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#Turn off &#039;&#039;$filterxsshtml&#039;&#039; to allow insertion of JavaScript in the questions. (See [http://docs.limesurvey.org/tiki-index.php?page=Optional+settings&amp;amp;structure;=English+Instructions+for+LimeSurvey#Filtering_dangerous_HTML_tags_in_survey_objects documentation here])&lt;br /&gt;
#Create one or more Multiple numerical input question with sequential response codes. Set the [http://docs.limesurvey.org/tiki-index.php?page=Question+attributes&amp;amp;structure;=English+Instructions+for+LimeSurvey#random_order random_order question attribute] to 1.&lt;br /&gt;
#In the source of the first question add the following onload function. (See [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._ How to use script here])&lt;br /&gt;
#Replace &amp;quot;SSSSS&amp;quot;, &amp;quot;GG&amp;quot;, &amp;quot;QQ&amp;quot; in the function call at the end with the survey ID, group ID and question ID respectively.&lt;br /&gt;
#If you want to apply it to more questions on the same page simply add more calls with the appropriate IDs. (eg. partRandDD(11111, 22, 1); partRandDD(11111, 22, 2); ...)&lt;br /&gt;
&lt;br /&gt;
Onload code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Function to allow randomization of all answers except the last one in multiple numeric input questions&lt;br /&gt;
&lt;br /&gt;
       function partRand(sID, gID, qID) {&lt;br /&gt;
&lt;br /&gt;
           // Find the number of answers&lt;br /&gt;
&lt;br /&gt;
           var ansCount = &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
           $( &#039;div#question&#039; + qID + &#039; div.answers li&#039; ).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
               ansCount = (i - 1);&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Place the last answer created at the end of the list - but before the first helping sum&lt;br /&gt;
&lt;br /&gt;
           $( &#039;li#javatbd&#039; + sID + &#039;X&#039; + gID + &#039;X&#039; + qID + ansCount + &#039;&#039; ).insertBefore($( &#039;div#question&#039; + qID + &#039; div.answers li.multiplenumerichelp&#039; ).first());&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       // Call the function with the SID, GID and QID&lt;br /&gt;
&lt;br /&gt;
       partRand(SID, GID, QID);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using this solution for Multiple numerical input questions might be a bit more complicated than for other question types. All answers are organized in an unordered list (&amp;lt;ul&amp;gt;) structure. However, if advanced question settings like &#039;&#039;Equals sum value&#039;&#039; are used, LimeSurvey adds helping information (e.g. sum of all entries and remainder) to the same unordered list using the class &#039;&#039;multiplenumerichelp&#039;&#039; for these additional list items. The above example  assumes that at least one of these list items is present and moves the last answer to the position right above the first helper item. Without such advanced settings, the code will most certainly need adaptation.&lt;br /&gt;
&lt;br /&gt;
=Making one (or more) rows of an array mandatory=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 6/7, Firefox 3.0, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround allows you to define one or more rows of an array question as mandatory (instead of all of them which the &amp;quot;Mandatory&amp;quot; question setting does). It is [http://www.partnersinc.biz/surveys//index.php?sid=26842&amp;amp;newtest;=Y&amp;amp;lang;=en demonstrated here].&lt;br /&gt;
&lt;br /&gt;
A JavaScript function interrupts the submit function and checks if the inputs in the mandatory row(s) are populated. If not, an alert is popped up, the offending inputs are turned pink and the submit is aborted. Otherwise the submit goes ahead.&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#Turn off &#039;&#039;$filterxsshtml&#039;&#039; to allow insertion of JavaScript in the questions (see [http://docs.limesurvey.org/tiki-index.php?page=Optional+settings&amp;amp;structure;=English+Instructions+for+LimeSurvey#Filtering_dangerous_HTML_tags_in_survey_objects documentation here]).&lt;br /&gt;
#Create the array question.&lt;br /&gt;
#In the source of the array question add the following script (see [http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._ How to use script here]).&lt;br /&gt;
#Modify the warningText (line10)as required.&lt;br /&gt;
#Replace &amp;quot;QQ&amp;quot; (lines 13 and 14)  with the question ID and add calls as necessary for more rows - the example code renders rows 1 and 3 mandatory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$(document).ready(function () {&lt;br /&gt;
&lt;br /&gt;
 // Interrupt the submit function&lt;br /&gt;
&lt;br /&gt;
 $(&#039;form#limesurvey&#039;).submit(function () {&lt;br /&gt;
&lt;br /&gt;
   // Override the built-in &amp;quot;disable navigation buttons&amp;quot; feature&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#moveprevbtn, #movenextbtn, #movesubmitbtn&#039;).attr(&#039;disabled&#039;, &#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
   var empty = 0;&lt;br /&gt;
&lt;br /&gt;
   var warningText = &#039;Please complete the highlighted inputs.&#039;;&lt;br /&gt;
&lt;br /&gt;
   // Call the mandatory row function with question IDs and row numbers&lt;br /&gt;
&lt;br /&gt;
   mandatoryRow(QQ, 1);&lt;br /&gt;
&lt;br /&gt;
   mandatoryRow(QQ, 3);&lt;br /&gt;
&lt;br /&gt;
   // A function to render rows of an array mandatory&lt;br /&gt;
&lt;br /&gt;
   function mandatoryRow(qID, rowNum) {&lt;br /&gt;
&lt;br /&gt;
     $(&#039;div#question&#039; + qID + &#039; table.question tbody[id&amp;lt;/div&amp;gt;=&amp;quot;javatbd&amp;quot;]:eq(&#039; + Number(rowNum - 1) + &#039;) input[type=&amp;quot;text&amp;quot;]&#039;).each(function (i) {&lt;br /&gt;
&lt;br /&gt;
       if ($(this).val() == &#039;&#039;) {&lt;br /&gt;
&lt;br /&gt;
         $(this).css(&#039;background-color&#039;, &#039;pink&#039;);&lt;br /&gt;
&lt;br /&gt;
         empty = 1;&lt;br /&gt;
&lt;br /&gt;
       } else {&lt;br /&gt;
&lt;br /&gt;
         $(this).css(&#039;background-color&#039;, &#039;#FFFFFF&#039;);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
     });&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   if (empty == 1) {&lt;br /&gt;
&lt;br /&gt;
     alert(warningText);&lt;br /&gt;
&lt;br /&gt;
     return false;&lt;br /&gt;
&lt;br /&gt;
   } else {&lt;br /&gt;
&lt;br /&gt;
     return true;&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Randomly displaying one of a few YouTube videos, and recording which was displayed=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested in 1.85+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Jason Cleeland has created and documented a method to randomly display one of a number of youtube videos in a single question, and save which one was displayed.&lt;br /&gt;
&lt;br /&gt;
http://www.aptigence.com.au/home/archives/23-Random-display-of-videos-in-a-question-2-YouTube.html&lt;br /&gt;
&lt;br /&gt;
=Randomly displaying one of a few pictures, and recording which was displayed=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested in 1.91+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The following steps allow you to randomly display one of a few pictures and record in the dataset which picture was displayed. We use four pictures in this example, but you can easily adapt these scripts according to your needs.&lt;br /&gt;
&lt;br /&gt;
1. Create a new sub-directory &#039;&#039;&#039;pic&#039;&#039;&#039; in your LimeSurvey folder.&lt;br /&gt;
&lt;br /&gt;
2. Copy four pictures (named &#039;&#039;1.jpg&#039;&#039;, &#039;&#039;2.jpg&#039;&#039;, &#039;&#039;3.jpg&#039;&#039;, and &#039;&#039;4.jpg&#039;&#039;) in this pic sub-directory.&lt;br /&gt;
&lt;br /&gt;
3. Deactivate the &#039;&#039;Filter HTML for XSS&#039;&#039; function in LimeSurvey&#039;s &#039;&#039;Global Settings&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
4. Create a &#039;&#039;&#039;Short free text&#039;&#039;&#039; question where you want these pictures to be displayed.&lt;br /&gt;
&lt;br /&gt;
5. Figure out the [http://docs.limesurvey.org/SGQA+identifier SGQA Identifier] of this question (e.g., 12345X67X89).&lt;br /&gt;
&lt;br /&gt;
6. Paste the following code as question text after activating the editor&#039;s &#039;&#039;Source&#039;&#039; view and replace both SSSSSXGGXQQ strings with your SGQA identifier:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please have a look at this picture:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$(document).ready(&lt;br /&gt;
&lt;br /&gt;
function(){&lt;br /&gt;
&lt;br /&gt;
// Find a random number (here between 1 and 4)&lt;br /&gt;
&lt;br /&gt;
var randNumber = Math.floor(Math.random()*4 + 1);&lt;br /&gt;
&lt;br /&gt;
// Save the number as answer of this question&lt;br /&gt;
&lt;br /&gt;
$(&#039;input#answerSSSSSXGGXQQ&#039;).val(randNumber);&lt;br /&gt;
&lt;br /&gt;
// Hide this answer field&lt;br /&gt;
&lt;br /&gt;
document.getElementById(&amp;quot;answerSSSSSXGGXQQ&amp;quot;).style.display=&#039;none&#039;;&lt;br /&gt;
&lt;br /&gt;
// Show the picture&lt;br /&gt;
&lt;br /&gt;
picString = &#039;&amp;lt;img src=&amp;quot;pic/&#039; + String(randNumber) + &#039;.jpg&amp;quot;&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
document.getElementById(&#039;pic&#039;).innerHTML = picString;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;pic&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to display the number of this picture in a later question, use the following code as question text (don&#039;t forget to replace the SSSSSXGGXQQ string acordingly):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You saw picture number {INSERTANS:SSSSSXGGXQQ}.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Perhaps you want to display the same picture again in a later question, but a little bit smaller (100px width, 100px height)? Just paste the following code as question text after activating the editor&#039;s &#039;&#039;Source&#039;&#039; view, and replace the SSSSSXGGXQQ string acordingly:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here you see the picture again: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$(document).ready(&lt;br /&gt;
&lt;br /&gt;
function(){&lt;br /&gt;
&lt;br /&gt;
// Get the picture number from previous question&lt;br /&gt;
&lt;br /&gt;
var randNumber = &amp;quot;{INSERTANS:SSSSSXGGXQQ}&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
// Show picture&lt;br /&gt;
&lt;br /&gt;
picString = &#039;&amp;lt;img width=&amp;quot;100&amp;quot; height=&amp;quot;100&amp;quot; src=&amp;quot;pic/&#039; + String(randNumber) + &#039;.jpg&amp;quot;&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
document.getElementById(&#039;pic&#039;).innerHTML = picString;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;pic&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Multiple numerical input with max_num_value defined in token (personalized limit)=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested in 1.85+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, max_num_value can be an experession, so you can simply enter the {TOKEN} or other variable in that question attribute.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To make personalized survey with multiple numerical input when max_num_value (Maximum sum value) is different for each user and is loaded from the token use following tricks:&lt;br /&gt;
*Create 1st group with numerical input field (1000X10X11). &amp;quot;Limit&amp;quot;&lt;br /&gt;
*Add java script into this question:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
function Custom_On_Load(){&lt;br /&gt;
&lt;br /&gt;
  document.getElementById(&#039;answer1000X10X11&#039;).value=&#039;{TOKEN:ATTRIBUTE_1}&#039;;&lt;br /&gt;
&lt;br /&gt;
  document.getElementById(&#039;answer1000X10X11&#039;).readOnly=1;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where:&lt;br /&gt;
&lt;br /&gt;
TOKEN:ATTRIBUTE_1 is individual limit defined in token.&lt;br /&gt;
&lt;br /&gt;
readOnly=1 // user shouldn&#039;t change it.&lt;br /&gt;
*Create 2nd group with multiple numerical input and add &amp;quot;Max value from SGQA&amp;quot; with 1000X10X11 as argument.&lt;br /&gt;
&lt;br /&gt;
Note: If you don&#039;t want to show first field with numerical input (and show definied limit in different way) you can add 2 lines to above script to hide whole question:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
document.getElementById(&#039;question85&#039;).style.display=&#039;none&#039;;&lt;br /&gt;
&lt;br /&gt;
document.getElementById(&#039;display85&#039;).value=&#039;&#039;;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where:&lt;br /&gt;
&lt;br /&gt;
question85 and display85 are field names.&lt;br /&gt;
&lt;br /&gt;
Note: It&#039;s no possible to create it into one group, because all SGQA references can only refer to data on a previous page because when clicking next the answer is stored at the DB and the SGQA is replaced by querying the database.&lt;br /&gt;
&lt;br /&gt;
=Default values in array questions=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.87+ (7557), IE 6/7, Firefox 3.5, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of Version 1.92, many more question types support default values.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround uses JavaScript to allow you to pre-check default answers in all sub-questions of an array type question. You can select a column of the array to be checked as the page loads. The script first checks to see if a sub-question has already been answered and, if not, checks the default answer.&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#[http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._ Set up your survey to use JavaScript].&lt;br /&gt;
#Create the array question.&lt;br /&gt;
#In the source of the array question add the following script.&lt;br /&gt;
#Replace&amp;quot;QQ&amp;quot; with the question ID and &amp;quot;CC&amp;quot; with the column number to be checked.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // A function to pre-check a column of an array&lt;br /&gt;
&lt;br /&gt;
       function checkedDefault(qID, column) {&lt;br /&gt;
&lt;br /&gt;
           var checkedCol = column - 1;&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039; + qID + &#039; table.question tbody tr&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
               if ($(&#039;input.radio[checked=true]&#039;, this).length == 0) {&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;input.radio:eq(&#039; + checkedCol + &#039;)&#039;, this).attr(&#039;checked&#039;, true);&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       // Call the function with a question ID and column number&lt;br /&gt;
&lt;br /&gt;
       checkedDefault(QQ, CC);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Record group view time=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.87+ (8518), IE 6/7, Firefox 3.5, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;As of version 1.92, group view time is accurately recorded in the timings table if you choose the Record Timings survey option.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround uses JavaScript to populate a hidden question with the total time that a respondent views a group. If used in a group with only one question, it could be used to track the amount of time required to answer the question.&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#[http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._ Set up your survey to use JavaScript].&lt;br /&gt;
#In the group, create a short-text question. We will hide this later with JavaScript and populate it with the elapsed time.&lt;br /&gt;
#Place the following script in the source of the short-text question.&lt;br /&gt;
#Replace &amp;quot;QQ&amp;quot; in line 6 with the ID of the short-text question.&lt;br /&gt;
&lt;br /&gt;
The script populates the hidden question with the elapsed time since the group was opened. If a respondent leaves the group and then returns, the timer continues up from the elapsed time of the last visit.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function(){&lt;br /&gt;
&lt;br /&gt;
       // call the functions with the hidden timer question ID&lt;br /&gt;
&lt;br /&gt;
       runTimer(QQ);&lt;br /&gt;
&lt;br /&gt;
       function runTimer(timeQID) {&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+timeQID).hide();&lt;br /&gt;
&lt;br /&gt;
           var initSec = &#039;0&#039;;&lt;br /&gt;
&lt;br /&gt;
           // Check for elapsed time from previous visits&lt;br /&gt;
&lt;br /&gt;
           if ($(&#039;#question&#039;+timeQID+&#039; input.text&#039;).val()) {&lt;br /&gt;
&lt;br /&gt;
               var initTime = $(&#039;#question&#039;+timeQID+&#039; input.text&#039;).val();&lt;br /&gt;
&lt;br /&gt;
               initTimeArr = initTime.split(&#039;:&#039;);&lt;br /&gt;
&lt;br /&gt;
               initSec = Number[[initTimeArr[0]*3600]]+Number[[initTimeArr[1]*60]]+Number(initTimeArr[2]);&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
           // Run the timer update function&lt;br /&gt;
&lt;br /&gt;
           recordTime(initSec, timeQID);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   // Timer update function&lt;br /&gt;
&lt;br /&gt;
   function recordTime(elapsedSec, timeQID){&lt;br /&gt;
&lt;br /&gt;
       elapsedSec++;&lt;br /&gt;
&lt;br /&gt;
       var h = Math.floor(elapsedSec / 3600);&lt;br /&gt;
&lt;br /&gt;
       var m = Math.floor(elapsedSec % 3600 / 60);&lt;br /&gt;
&lt;br /&gt;
       var s = Math.floor(elapsedSec % 3600 % 60);&lt;br /&gt;
&lt;br /&gt;
       var elapsedTime = [[h &amp;gt; 0 ? h + &amp;quot;:&amp;quot; : &amp;quot;00:&amp;quot;) + (m &amp;gt; 0 ? (m &amp;lt; 10 ? &amp;quot;0&amp;quot; : &amp;quot;&amp;quot;) + m + &amp;quot;:&amp;quot; : &amp;quot;00:&amp;quot;) + (s &amp;lt; 10 ? &amp;quot;0&amp;quot; : &amp;quot;&amp;quot;) + s);&lt;br /&gt;
&lt;br /&gt;
        $(&#039;#question&#039;+timeQID+&#039; input.text&#039;).val(elapsedTime);&lt;br /&gt;
&lt;br /&gt;
        // Run the timer update function every second&lt;br /&gt;
&lt;br /&gt;
        setTimeout(&#039;recordTime(&#039;+elapsedSec+&#039;, &#039;+timeQID+&#039;)&#039;,1000);&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 =Toggle visibility of groups=&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;Tested with: 1.90+, IE 6/7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;Version 1.92 supports group-level relevance, making this workaround obsolete.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 This workaround uses JavaScript to toggle the visibility of groups in an &amp;quot;all in one&amp;quot; survey. Initially the groups are hidden and there are links inserted to display the groups. It&#039;s useful to avoid the page being cluttered with many groups and lets the respondent focus on one at a time.&lt;br /&gt;
&lt;br /&gt;
 It&#039;s [http://www.partnersinc.biz/surveys//index.php?sid=33613&amp;amp;newtest;=Y&amp;amp;lang;=en|demonstrated here].&lt;br /&gt;
&lt;br /&gt;
 Implementation is as follows:&lt;br /&gt;
&lt;br /&gt;
 #[http://docs.limesurvey.org/tiki-index.php?page=Workarounds&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._|Set up your survey to use JavaScript].&lt;br /&gt;
&lt;br /&gt;
 #Set the survey to run in &amp;quot;all in one&amp;quot; mode.&lt;br /&gt;
&lt;br /&gt;
 #Add your groups and questions.&lt;br /&gt;
&lt;br /&gt;
 #Place the following script in the source of one of the questions in the first group.&lt;br /&gt;
&lt;br /&gt;
 The comments in the script are pretty self-explanatory but it does the following:&lt;br /&gt;
&lt;br /&gt;
 #initially hides all of the groups&lt;br /&gt;
&lt;br /&gt;
 #inserts a link above each one to toggle its display&lt;br /&gt;
&lt;br /&gt;
 #some styles are added to the clickable links but these could be done in template.css instead&lt;br /&gt;
&lt;br /&gt;
 #shows any groups that have an unanswered mandatory after a submit attempt&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    $(document).ready(function(){&lt;br /&gt;
&lt;br /&gt;
       // Insert show/hide elements before all group wrapper divs&lt;br /&gt;
&lt;br /&gt;
        $(&#039;&amp;lt;div class=&amp;quot;groupToggler&amp;quot;&amp;gt;&amp;lt;span&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;/div&amp;gt;&#039;).insertBefore(&#039;div[id&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&amp;quot;group-&amp;quot;]&#039;);&lt;br /&gt;
&lt;br /&gt;
        // Add some text to the show/hide elements&lt;br /&gt;
&lt;br /&gt;
        $(&#039;.groupToggler span&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
            ($( this ).text(&#039;Show/Hide Group &#039;+(i+1)+&#039;&#039;]];&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // Add some styles to the show/hide elements&lt;br /&gt;
&lt;br /&gt;
       $(&#039;.groupToggler&#039;).css({&lt;br /&gt;
&lt;br /&gt;
           &#039;padding&#039;:&#039;5px 0 10px 0&#039;,&lt;br /&gt;
&lt;br /&gt;
           &#039;text-align&#039;:&#039;center&#039;&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       $(&#039;.groupToggler span&#039;).css({&lt;br /&gt;
&lt;br /&gt;
           &#039;text-decoration&#039;:&#039;underline&#039;,&lt;br /&gt;
&lt;br /&gt;
           &#039;cursor&#039;:&#039;pointer&#039;&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // Add some hover effects to the show/hide elements&lt;br /&gt;
&lt;br /&gt;
       $(&amp;quot;.groupToggler span&amp;quot;).hover(&lt;br /&gt;
&lt;br /&gt;
           function () {&lt;br /&gt;
&lt;br /&gt;
               $(this).css({&lt;br /&gt;
&lt;br /&gt;
                   &#039;text-decoration&#039;:&#039;none&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;font-weight&#039;:&#039;bold&#039;&lt;br /&gt;
&lt;br /&gt;
               });&lt;br /&gt;
&lt;br /&gt;
           },&lt;br /&gt;
&lt;br /&gt;
           function () {&lt;br /&gt;
&lt;br /&gt;
               $(this).css({&lt;br /&gt;
&lt;br /&gt;
                   &#039;text-decoration&#039;:&#039;underline&#039;,&lt;br /&gt;
&lt;br /&gt;
                   &#039;font-weight&#039;:&#039;normal&#039;&lt;br /&gt;
&lt;br /&gt;
               });&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       );&lt;br /&gt;
&lt;br /&gt;
       // Initially hide all of the groups&lt;br /&gt;
&lt;br /&gt;
       // Toggle their visibility when the show/hide element is clicked&lt;br /&gt;
&lt;br /&gt;
       $(&#039;.groupToggler span&#039;).click(function() {&lt;br /&gt;
&lt;br /&gt;
           $(this).parent().next().toggle();&lt;br /&gt;
&lt;br /&gt;
           return false;&lt;br /&gt;
&lt;br /&gt;
       }).parent().next().hide();&lt;br /&gt;
&lt;br /&gt;
       // Display any groups that have unanswered mandatories&lt;br /&gt;
&lt;br /&gt;
       $(&#039;.errormandatory&#039;).parents(&#039;div[id&amp;lt;/div&amp;gt;=&amp;quot;group-&amp;quot;]&#039;).show();&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Use jQuery Autocomplete plugin to suggest answers for text inputs=&lt;br /&gt;
&lt;br /&gt;
== 1.90 and previous versions==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 6/7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround uses the [http://docs.jquery.com/Plugins/Autocomplete jQuery Autocomplete] plugin to provide a respondent a list of suggested answers that the they can select from as they type in a text input.&lt;br /&gt;
&lt;br /&gt;
Although the plugin allows for much more complex applications, the two that I use most frequently are outlined below. The first method uses a relatively small list of suggestions that is stored in an array locally. The second is a little more complex - it uses a remote CSV file of suggestions that is accessed through AJAX an PHP.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve put together a small demonstration [http://www.partnersinc.biz/surveys//index.php?sid=78611&amp;amp;newtest;=Y&amp;amp;lang;=en here] and implementation is as follows.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Both methods:&#039;&#039;&#039;&lt;br /&gt;
*[http://docs.jquery.com/Plugins/Autocomplete Download the plugin]&lt;br /&gt;
*Place the files &#039;&#039;jquery.autocomplete.css&#039;&#039; and &#039;&#039;jquery.autocomplete.js&#039;&#039; in your template directory&lt;br /&gt;
*Add the following code inside the &amp;lt;head&amp;gt; element of startpage.pstpl&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;{TEMPLATEURL}jquery.autocomplete.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;link rel=&amp;quot;stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot; href=&amp;quot;{TEMPLATEURL}jquery.autocomplete.css&amp;quot; /&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Method 1 (&amp;quot;States&amp;quot; question in the demo):&#039;&#039;&#039;&lt;br /&gt;
*Create a text input question&lt;br /&gt;
*Add the following script to the source of the text question&lt;br /&gt;
*Replace &amp;quot;QQ&amp;quot; with the ID of the text input question&lt;br /&gt;
*Replace the states with your list of suggestions (comma separated)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       var q1ID = QQ;&lt;br /&gt;
&lt;br /&gt;
       var states = &amp;quot;Alabama,Alaska,Arizona,Arkansas,California,Colorado,Connecticut,Delaware,&lt;br /&gt;
&lt;br /&gt;
       District of Columbia,Florida,Georgia,Hawaii,Idaho,Illinois,Indiana,Iowa,Kansas,Kentucky,&lt;br /&gt;
&lt;br /&gt;
       Louisiana,Maine,Montana,Nebraska,Nevada,New Hampshire,New Jersey,New Mexico,New York,&lt;br /&gt;
&lt;br /&gt;
       North Carolina,North Dakota,Ohio,Oklahoma,Oregon,Maryland,Massachusetts,Michigan,&lt;br /&gt;
&lt;br /&gt;
       Minnesota,Mississippi,Missouri,Pennsylvania,Rhode Island,South Carolina,South Dakota,&lt;br /&gt;
&lt;br /&gt;
       Tennessee,Texas,Utah,Vermont,Virginia,Washington,West Virginia,Wisconsin,Wyoming&amp;quot;.split(&#039;,&#039;);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q1ID+&#039; input.text&#039;).autocomplete(states, {&lt;br /&gt;
&lt;br /&gt;
           matchContains: true,&lt;br /&gt;
&lt;br /&gt;
           minChars: 0&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Method 2 (&amp;quot;Countries&amp;quot; question in the demo):&#039;&#039;&#039;&lt;br /&gt;
*Place the CSV file of suggestions in your template directory (you can download my demo CSV [http://www.partnersinc.biz/surveys/templates/default_autocompleting_input/countries2.csv here])&lt;br /&gt;
*Place a PHP file containing the code below in your template directory&lt;br /&gt;
*Replace &amp;quot;countries2.csv&amp;quot; with your CSV filename (you could make this more universal by passing the filename in the URL)&lt;br /&gt;
*This file will grab the contents of the CSV and encode them in JSON format that the JavaScript can use&lt;br /&gt;
*Place the JavaScript code below in ths source of the text question&lt;br /&gt;
*Replace &amp;quot;QQ&amp;quot; with the ID of the text input question&lt;br /&gt;
*Replace &amp;quot;templates/yourTemplate/countries.php&amp;quot; with the path to the PHP file (from LimeSurvey root)&lt;br /&gt;
*This script will grab the jsonized data from the PHP file and load it into an array that the plugin can use&lt;br /&gt;
&lt;br /&gt;
PHP code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
   $countriesArr = array();&lt;br /&gt;
&lt;br /&gt;
   $file_handle = fopen(&amp;quot;countries2.csv&amp;quot;, &amp;quot;r&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
   while (!feof($file_handle) ) {&lt;br /&gt;
&lt;br /&gt;
       $line_of_text = fgetcsv($file_handle);&lt;br /&gt;
&lt;br /&gt;
       array_push($countriesArr, $line_of_text[0]);&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   fclose($file_handle);&lt;br /&gt;
&lt;br /&gt;
   echo json_encode($countriesArr);&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
JavaScript code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       var qID = QQ;&lt;br /&gt;
&lt;br /&gt;
       var url = &amp;quot;templates/yourTemplate/countries.php&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
       var countriesArr = new Array();&lt;br /&gt;
&lt;br /&gt;
       $.getJSON(url,function(data){&lt;br /&gt;
&lt;br /&gt;
           $(data).each(function(i, item){&lt;br /&gt;
&lt;br /&gt;
               countriesArr.push(item);&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qID+&#039; input.text&#039;).autocomplete(countriesArr, {&lt;br /&gt;
&lt;br /&gt;
               matchContains: true,&lt;br /&gt;
&lt;br /&gt;
               minChars: 0&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 1.91 and later versions==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.91+, IE 6/7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround uses the [http://jqueryui.com/demos/autocomplete/ Autocomplete widget] included with jQuery UI to provide a respondent a list of suggested answers that the they can select from as they type in a text input.&lt;br /&gt;
&lt;br /&gt;
Although the plugin allows for much more complex applications, the two that I use most frequently are outlined below. The first method uses a relatively small list of suggestions that is stored in an array locally. The second is a little more complex - it uses a remote CSV file of suggestions that is accessed through AJAX an PHP.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Both methods:&#039;&#039;&#039;&lt;br /&gt;
*Add the following styles to the end of your &#039;template.css&#039; file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;/* Autocomplete styles */&lt;br /&gt;
&lt;br /&gt;
ul.ui-autocomplete {&lt;br /&gt;
&lt;br /&gt;
   width: 250px !important;&lt;br /&gt;
&lt;br /&gt;
   padding: 5px 10px;&lt;br /&gt;
&lt;br /&gt;
   list-style: none;&lt;br /&gt;
&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Method 1 (use local JavaScript array for data):&#039;&#039;&#039;&lt;br /&gt;
*Create a text input question&lt;br /&gt;
*Add the following script to the source of the text question&lt;br /&gt;
*Replace &amp;quot;QQ&amp;quot; with the ID of the text input question&lt;br /&gt;
*Replace the states with your list of suggestions (comma separated)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       var q1ID = QQ;&lt;br /&gt;
&lt;br /&gt;
       var states = &amp;quot;Alabama,Alaska,Arizona,Arkansas,California,Colorado,Connecticut,Delaware,&lt;br /&gt;
&lt;br /&gt;
       District of Columbia,Florida,Georgia,Hawaii,Idaho,Illinois,Indiana,Iowa,Kansas,Kentucky,&lt;br /&gt;
&lt;br /&gt;
       Louisiana,Maine,Montana,Nebraska,Nevada,New Hampshire,New Jersey,New Mexico,New York,&lt;br /&gt;
&lt;br /&gt;
       North Carolina,North Dakota,Ohio,Oklahoma,Oregon,Maryland,Massachusetts,Michigan,&lt;br /&gt;
&lt;br /&gt;
       Minnesota,Mississippi,Missouri,Pennsylvania,Rhode Island,South Carolina,South Dakota,&lt;br /&gt;
&lt;br /&gt;
       Tennessee,Texas,Utah,Vermont,Virginia,Washington,West Virginia,Wisconsin,Wyoming&amp;quot;.split(&#039;,&#039;);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+q1ID+&#039; input.text&#039;).autocomplete({&lt;br /&gt;
&lt;br /&gt;
           source: states&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Method 2 (use remote CSV file for data):&#039;&#039;&#039;&lt;br /&gt;
*Place the CSV file of suggestions in your template directory (you can download my demo CSV [http://www.partnersinc.biz/surveys/templates/default_autocompleting_input/countries2.csv here])&lt;br /&gt;
*Place a PHP file containing the code below in your template directory&lt;br /&gt;
*Replace &amp;quot;countries2.csv&amp;quot; with your CSV filename (you could make this more universal by passing the filename in the URL)&lt;br /&gt;
*This file will grab the contents of the CSV and encode them in JSON format that the JavaScript can use&lt;br /&gt;
*Place the JavaScript code below in ths source of the text question&lt;br /&gt;
*Replace &amp;quot;QQ&amp;quot; with the ID of the text input question&lt;br /&gt;
*Replace &amp;quot;templates/yourTemplate/countries.php&amp;quot; with the path to the PHP file (from LimeSurvey root)&lt;br /&gt;
*This script will grab the jsonized data from the PHP file and load it into an array that the plugin can use&lt;br /&gt;
&lt;br /&gt;
PHP code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
   $countriesArr = array();&lt;br /&gt;
&lt;br /&gt;
   $file_handle = fopen(&amp;quot;countries2.csv&amp;quot;, &amp;quot;r&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
   while (!feof($file_handle) ) {&lt;br /&gt;
&lt;br /&gt;
       $line_of_text = fgetcsv($file_handle);&lt;br /&gt;
&lt;br /&gt;
       array_push($countriesArr, $line_of_text[0]);&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   fclose($file_handle);&lt;br /&gt;
&lt;br /&gt;
   echo json_encode($countriesArr);&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
JavaScript code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
       $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       var qID = QQ;&lt;br /&gt;
&lt;br /&gt;
       var url = &amp;quot;templates/yourTemplate/countries.php&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
       var dataArr = [];&lt;br /&gt;
&lt;br /&gt;
       $.getJSON(url,function(data){&lt;br /&gt;
&lt;br /&gt;
           $.each(data,function(i, item){&lt;br /&gt;
&lt;br /&gt;
               dataArr.push(item);&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
          $(&#039;#question&#039;+qID+&#039; input.text&#039;).autocomplete({&lt;br /&gt;
&lt;br /&gt;
               source: dataArr&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Use autocomplete to populate several fields==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.91+, IE 7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround uses the [http://jqueryui.com/demos/autocomplete/ Autocomplete widget] included with jQuery UI and the [http://plugins.jquery.com/project/csv jquery.csv.js] plugin to provide a respondent with a list of suggested answers as they type in a text input and then to automatically populate other fields depending on the selection.&lt;br /&gt;
&lt;br /&gt;
For example, if you have 3 questions - &amp;quot;Name&amp;quot;, &amp;quot;ID&amp;quot; and &amp;quot;Email&amp;quot; - you can use this workaround to autocomplete the &amp;quot;Name&amp;quot; question and then the &amp;quot;ID&amp;quot; and &amp;quot;Email&amp;quot; questions can be automatically populated with values associated with the selected name.&lt;br /&gt;
*Download the [http://plugins.jquery.com/project/csv jquery.csv.js] plugin and place it in your template folder&lt;br /&gt;
*Add the following line to your startpage.pstpl BEFORE the tag for template.js&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;{TEMPLATEURL}jquery.csv.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
*Create your CSV file with 3 columns (name, ID, email) as in this example and place it in your template folder&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;Bob,    Bob&#039;s ID,    Bob&#039;s email&lt;br /&gt;
&lt;br /&gt;
Andy,    Andy&#039;s ID,    Andy&#039;s email&lt;br /&gt;
&lt;br /&gt;
Sam,    Sam&#039;s ID,    Sam&#039;s email&lt;br /&gt;
&lt;br /&gt;
Tony,    Tony&#039;s ID,    Tony&#039;s email&lt;br /&gt;
&lt;br /&gt;
Fred,    Fred&#039;s ID,    Fred&#039;s email&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
*Create your 3 questions - &amp;quot;Name&amp;quot;, &amp;quot;ID&amp;quot; and &amp;quot;Email&amp;quot;. They must be in the same group/page.&lt;br /&gt;
*Add the following styles to the end of your &#039;template.css&#039; file&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;/* Autocomplete styles */&lt;br /&gt;
&lt;br /&gt;
ul.ui-autocomplete {&lt;br /&gt;
&lt;br /&gt;
   width: 250px !important;&lt;br /&gt;
&lt;br /&gt;
   padding: 5px 10px;&lt;br /&gt;
&lt;br /&gt;
   list-style: none;&lt;br /&gt;
&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
*Add the following script to the source of one of the questions&lt;br /&gt;
*Replace:&lt;br /&gt;
**&amp;quot;NN&amp;quot; with the &amp;quot;Name&amp;quot; question ID&lt;br /&gt;
**&amp;quot;II&amp;quot; with the &amp;quot;ID&amp;quot; question ID&lt;br /&gt;
**&amp;quot;EE&amp;quot; with the &amp;quot;Email&amp;quot; question ID&lt;br /&gt;
*Modify the path to your CSV file&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       var qNameID = NN;&lt;br /&gt;
&lt;br /&gt;
       var qIDID = II;&lt;br /&gt;
&lt;br /&gt;
       var qEmailID = EE;&lt;br /&gt;
&lt;br /&gt;
       var url = &amp;quot;upload/templates/yourTemplate/yourCsvFile.csv&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
       // Create an array to hold the names&lt;br /&gt;
&lt;br /&gt;
       var namesArr = new Array();&lt;br /&gt;
&lt;br /&gt;
       // Grab the CSV contents&lt;br /&gt;
&lt;br /&gt;
       $.get(url,function(data){&lt;br /&gt;
&lt;br /&gt;
           // Convert CSV contents to an array of arrays&lt;br /&gt;
&lt;br /&gt;
           fullArray = jQuery.csv()(data);&lt;br /&gt;
&lt;br /&gt;
           // Load the names array&lt;br /&gt;
&lt;br /&gt;
           $(fullArray).each(function(i, item){&lt;br /&gt;
&lt;br /&gt;
               namesArr.push(item[0]);&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Initialise the autocomplete plugin&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qNameID+&#039; input.text&#039;).autocomplete({&lt;br /&gt;
&lt;br /&gt;
               source: namesArr,&lt;br /&gt;
&lt;br /&gt;
               // Event fired when a selection is made (ui.item.value refers to the selected item)&lt;br /&gt;
&lt;br /&gt;
               select: function(event, ui) {&lt;br /&gt;
&lt;br /&gt;
                   // Find the &amp;quot;ID&amp;quot; and &amp;quot;Email&amp;quot; values associated with the selected name value and load those questions&lt;br /&gt;
&lt;br /&gt;
                   $(fullArray).each(function(i, item){&lt;br /&gt;
&lt;br /&gt;
                       if(item[0] == ui.item.value) {&lt;br /&gt;
&lt;br /&gt;
                           // The value from column 2 of the CSV&lt;br /&gt;
&lt;br /&gt;
                           $(&#039;#question&#039;+qIDID+&#039; input.text&#039;).val(item[1]);&lt;br /&gt;
&lt;br /&gt;
                           // The value from column 3 of the CSV&lt;br /&gt;
&lt;br /&gt;
                           $(&#039;#question&#039;+qEmailID+&#039; input.text&#039;).val(item[2]);&lt;br /&gt;
&lt;br /&gt;
                       }&lt;br /&gt;
&lt;br /&gt;
                   });&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Drag and Drop Rankings=&lt;br /&gt;
&lt;br /&gt;
==Drag and Drop Ranking - Version 1.90 and newer==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+ &amp;amp; 1.91RC4, IE 6/7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround is a modification of the workaround below and also uses [http://jqueryui.com/demos/sortable/#connect-lists JQuery connected sortables]. Thanks to the author of that workaround.&lt;br /&gt;
&lt;br /&gt;
[[File:Untitled-12.png]]&lt;br /&gt;
&lt;br /&gt;
Modifications include:&lt;br /&gt;
*Allow for multiple drag-n-drop ranking questions on a page&lt;br /&gt;
*Handle minimum and maximum answers settings&lt;br /&gt;
*Allow double clicking of items to add or remove them from the ranking list&lt;br /&gt;
*Work with the new shipped jQuery UI&lt;br /&gt;
&lt;br /&gt;
There is a &#039;&#039;&#039;[http://www.partnersinc.biz/surveys//index.php?sid=36981&amp;amp;newtest;=Y&amp;amp;lang;=en demonstrated here]&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_ Set up your survey to use JavaScript].&lt;br /&gt;
#Place the large script below in your template.js file.&lt;br /&gt;
#Place the small script below in the source a ranking question, (this applies the &amp;quot;dragDropRank&amp;quot; function to the question). Replace &amp;quot;QQ&amp;quot; with the ranking [http://docs.limesurvey.org/SGQA+identifier&amp;amp;structure;=English+Instructions+for+LimeSurvey#General_Description question ID].&lt;br /&gt;
**Note: the LimeSurvey translations will be automatically used for the &amp;quot;Choices&amp;quot; and &amp;quot;Rankings&amp;quot; header labels but can be overridden with custom labels - see the example calls below.&lt;br /&gt;
#Insert the CSS below at the end of template.css (these styles are for the default template).&lt;br /&gt;
&lt;br /&gt;
NOTE: I have not tested this workaround with conditions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Code for template.js:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
function dragDropRank(qID, choiceText, rankText) {&lt;br /&gt;
&lt;br /&gt;
   if(!choiceText) {&lt;br /&gt;
&lt;br /&gt;
       choiceText = $(&#039;#question&#039;+qID+&#039; td.label label&#039;).text();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   if(!rankText) {&lt;br /&gt;
&lt;br /&gt;
       rankText = $(&#039;#question&#039;+qID+&#039; td.output tr:first td:eq(1)&#039;).text();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   //Add a class to the question&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#question&#039;+qID+&#039;&#039;).addClass(&#039;dragDropRanking&#039;);&lt;br /&gt;
&lt;br /&gt;
   // Hide the original question in LimeSurvey (so that we can replace with drag and drop)&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#question&#039;+qID+&#039; .rank, #question&#039;+qID+&#039; .questionhelp&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
   // Turn off display of question (to override error checking built into LimeSurvey ranking question)&lt;br /&gt;
&lt;br /&gt;
   //$(&#039;#display&#039;+qID).val(&#039;off&#039;);&lt;br /&gt;
&lt;br /&gt;
   // Add connected sortables elements to the question&lt;br /&gt;
&lt;br /&gt;
   var htmlCode = &#039;&amp;lt;table class=&amp;quot;dragDropTable&amp;quot;&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
       &amp;lt;tbody&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
           &amp;lt;tr&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
               &amp;lt;td&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                   &amp;lt;span class=&amp;quot;dragDropHeader choicesLabel&amp;quot;&amp;gt;&#039;+choiceText+&#039;&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                   &amp;lt;div class=&amp;quot;ui-state-highlight dragDropChoices&amp;quot;&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                       &amp;lt;ul id=&amp;quot;sortable1&#039;+qID+&#039;&amp;quot; class=&amp;quot;connectedSortable&#039;+qID+&#039; dragDropChoiceList&amp;quot;&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                           &amp;lt;li&amp;gt;Choices&amp;lt;/li&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                       &amp;lt;/ul&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                   &amp;lt;/div&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
               &amp;lt;/td&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
               &amp;lt;td&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                   &amp;lt;span class=&amp;quot;dragDropHeader rankingLabel&amp;quot;&amp;gt;&#039;+rankText+&#039;&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                   &amp;lt;div class=&amp;quot;ui-state-highlight dragDropRanks&amp;quot;&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                       &amp;lt;ol id=&amp;quot;sortable2&#039;+qID+&#039;&amp;quot; class=&amp;quot;connectedSortable&#039;+qID+&#039; dragDropRankList&amp;quot;&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                           &amp;lt;li&amp;gt;Ranks&amp;lt;/li&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                       &amp;lt;/ol&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                   &amp;lt;/div&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
               &amp;lt;/td&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
           &amp;lt;/tr&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
       &amp;lt;/tbody&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                   &amp;lt;/table&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
   $(htmlCode).insertAfter(&#039;#question&#039;+qID+&#039; table.rank&#039;);&lt;br /&gt;
&lt;br /&gt;
   // Remove placeholder list items (have to have one item so that LimeSurvey doesn&amp;quot;t remove the &amp;lt;ul&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#sortable1&#039;+qID+&#039; li, #sortable2&#039;+qID+&#039; li&#039;).remove();&lt;br /&gt;
&lt;br /&gt;
   // Load any previously-set values&lt;br /&gt;
&lt;br /&gt;
   loadDragDropRank(qID);&lt;br /&gt;
&lt;br /&gt;
   // Find the number of LimeSurvey ranking inputs (&amp;quot;Maximum answers&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
   var maxAnswer = $(&#039;#question&#039;+qID+&#039; td.output input.text&#039;).length;&lt;br /&gt;
&lt;br /&gt;
   // Set up the connected sortable&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#sortable1&#039;+qID+&#039;, #sortable2&#039;+qID+&#039;&#039;).sortable({&lt;br /&gt;
&lt;br /&gt;
       connectWith: &#039;.connectedSortable&#039;+qID+&#039;&#039;,&lt;br /&gt;
&lt;br /&gt;
       placeholder: &#039;ui-sortable-placeholder&#039;,&lt;br /&gt;
&lt;br /&gt;
       helper: &#039;clone&#039;,&lt;br /&gt;
&lt;br /&gt;
       revert: 50,&lt;br /&gt;
&lt;br /&gt;
       receive: function(event, ui) {&lt;br /&gt;
&lt;br /&gt;
           if($(&#039;#sortable2&#039;+qID+&#039; li&#039;).length &amp;gt; maxAnswer) {&lt;br /&gt;
&lt;br /&gt;
               alert (&#039;You can only rank a maximum of &#039;+maxAnswer+&#039; choices.&#039;);&lt;br /&gt;
&lt;br /&gt;
               $(ui.sender).sortable(&#039;cancel&#039;);&lt;br /&gt;
&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       },&lt;br /&gt;
&lt;br /&gt;
       stop: function(event, ui) {&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#sortable1&#039;+qID+&#039;&#039;).sortable(&#039;refresh&#039;);&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#sortable2&#039;+qID+&#039;&#039;).sortable(&#039;refresh&#039;);&lt;br /&gt;
&lt;br /&gt;
           updateDragDropRank(qID);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   }).disableSelection();&lt;br /&gt;
&lt;br /&gt;
   // Get the list of choices from the LimeSurvey question and copy them as items into the sortable choices list&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#CHOICES_&#039; + qID).children().each(function(index, Element) {&lt;br /&gt;
&lt;br /&gt;
       var liCode = &#039;&amp;lt;li class=&amp;quot;ui-state-default&amp;quot; id=&amp;quot;choice_&#039; + $(this).attr(&amp;quot;value&amp;quot;) + &#039;&amp;quot;&amp;gt;&#039; + this.text + &#039;&amp;lt;/li&amp;gt;&#039;&lt;br /&gt;
&lt;br /&gt;
       $(liCode).appendTo(&#039;#sortable1&#039;+qID+&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   // Allow users to double click to move to selections from list to list&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#sortable1&#039;+qID+&#039; li&#039;).live(&#039;dblclick&#039;, function() {&lt;br /&gt;
&lt;br /&gt;
       if($(&#039;#sortable2&#039;+qID+&#039; li&#039;).length == maxAnswer) {&lt;br /&gt;
&lt;br /&gt;
           alert (&#039;You can only rank a maximum of &#039;+maxAnswer+&#039; choices.&#039;);&lt;br /&gt;
&lt;br /&gt;
           return false;&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       else {&lt;br /&gt;
&lt;br /&gt;
           $(this).appendTo(&#039;#sortable2&#039;+qID+&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#sortable1&#039;+qID+&#039;&#039;).sortable(&#039;refresh&#039;);&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#sortable2&#039;+qID+&#039;&#039;).sortable(&#039;refresh&#039;);&lt;br /&gt;
&lt;br /&gt;
           updateDragDropRank(qID);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#sortable2&#039;+qID+&#039; li&#039;).live(&#039;dblclick&#039;, function() {&lt;br /&gt;
&lt;br /&gt;
       $(this).appendTo(&#039;#sortable1&#039;+qID+&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#sortable2&#039;+qID+&#039;&#039;).sortable(&#039;refresh&#039;);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#sortable1&#039;+qID+&#039;&#039;).sortable(&#039;refresh&#039;);&lt;br /&gt;
&lt;br /&gt;
       updateDragDropRank(qID);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// This function copies the drag and drop sortable data into the LimeSurvey ranking list.&lt;br /&gt;
&lt;br /&gt;
function updateDragDropRank(qID)&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   // Reload the LimeSurvey choices select element&lt;br /&gt;
&lt;br /&gt;
   var rankees = [];&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#sortable2&#039;+qID+&#039; li&#039;).each(function(index) {&lt;br /&gt;
&lt;br /&gt;
       $(this).attr(&#039;value&#039;, index+1);&lt;br /&gt;
&lt;br /&gt;
       // Get value of ranked item&lt;br /&gt;
&lt;br /&gt;
       var liID = $(this).attr(&amp;quot;id&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
       liIDArray = liID.split(&#039;_&#039;);&lt;br /&gt;
&lt;br /&gt;
       // Save to an array&lt;br /&gt;
&lt;br /&gt;
       rankees[rankees.length] = { &amp;quot;r_name&amp;quot;:$(this).text(),&amp;quot;r_value&amp;quot;:liIDArray[1] };&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#question&#039;+qID+&#039; input[name&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&amp;quot;RANK_&amp;quot;]&#039;).each(function(index) {&lt;br /&gt;
&lt;br /&gt;
       if (rankees.length &amp;gt; index) {&lt;br /&gt;
&lt;br /&gt;
           $(this).val(rankees[index].r_name);&lt;br /&gt;
&lt;br /&gt;
           //alert (rankees[index].r_value);&lt;br /&gt;
&lt;br /&gt;
           $(this).next(&#039;input&#039;).attr(&#039;value&#039;, rankees[index].r_value);&lt;br /&gt;
&lt;br /&gt;
       } else {&lt;br /&gt;
&lt;br /&gt;
           $(this).val(&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
           $(this).next().val(&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
     });&lt;br /&gt;
&lt;br /&gt;
   // Reload the LimeSurvey choices select element (we need this for &amp;quot;Minimum answers&amp;quot; code)&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#question&#039;+qID+&#039; td.label select option&#039;).remove();&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#sortable1&#039;+qID+&#039; li&#039;).each(function(index) {&lt;br /&gt;
&lt;br /&gt;
       var liText = $(this).text();&lt;br /&gt;
&lt;br /&gt;
       var liID = $(this).attr(&#039;id&#039;);&lt;br /&gt;
&lt;br /&gt;
       liIDArray = liID.split(&#039;_&#039;);&lt;br /&gt;
&lt;br /&gt;
       var optionCode = &#039;&amp;lt;option value=&amp;quot;&#039;+liIDArray[1]+&#039;&amp;quot;&amp;gt;&#039;+liText+&#039;&amp;lt;/option&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
       $(optionCode).appendTo(&#039;#question&#039;+qID+&#039; td.label select&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   // Hack for IE6&lt;br /&gt;
&lt;br /&gt;
   if ($.browser.msie &amp;amp;&amp;amp; $.browser.version.substr(0,1)&amp;lt;7) {&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+qID+&#039; select&#039;).show();&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+qID+&#039; select&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// This function is called on page load to see if there are any items already ranked (from a previous visit&lt;br /&gt;
&lt;br /&gt;
// or cached due to a page change.  If so, the already-ranked items are loaded into the sortable list&lt;br /&gt;
&lt;br /&gt;
function loadDragDropRank(qID)&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   var rankees = [];&lt;br /&gt;
&lt;br /&gt;
   // Loop through each item in the built-in LimeSurvey ranking list looking for non-empty values&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#question&#039;+qID+&#039; input[name&amp;lt;/div&amp;gt;=&amp;quot;RANK_&amp;quot;]&#039;).each(function(index) {&lt;br /&gt;
&lt;br /&gt;
       // Check to see if the current item has a value&lt;br /&gt;
&lt;br /&gt;
       if ($(this).val()) {&lt;br /&gt;
&lt;br /&gt;
           // Item has a value - save to the array&lt;br /&gt;
&lt;br /&gt;
           // Use this element to contain the name and the next for the value (numeric)&lt;br /&gt;
&lt;br /&gt;
           rankees[rankees.length] = { &amp;quot;r_name&amp;quot;:$(this).val(),&amp;quot;r_value&amp;quot;:$(this).next().val() };&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   // Now that we have a list of all the pre-ranked items, populate the sortable list&lt;br /&gt;
&lt;br /&gt;
   // Note that the items *won&amp;quot;t* appear in the main list because LimeSurvey has removed them.&lt;br /&gt;
&lt;br /&gt;
   $.each(rankees, function(index, value) {&lt;br /&gt;
&lt;br /&gt;
       // Create the items in the sortable&lt;br /&gt;
&lt;br /&gt;
       var liCode = &#039;&amp;lt;li class=&amp;quot;ui-state-default&amp;quot; id=&amp;quot;choice_&#039; + value.r_value + &#039;&amp;quot;&amp;gt;&#039; + value.r_name + &#039;&amp;lt;/li&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
       $(liCode).appendTo(&#039;#sortable2&#039;+qID+&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Code in the source of the question(s) using the LimeSurvey translations for the &amp;quot;Choices&amp;quot; and &amp;quot;Rankings&amp;quot; element header labels&#039;&#039;&#039; (replace &amp;quot;QQ&amp;quot; with the ranking [http://docs.limesurvey.org/SGQA+identifier&amp;amp;structure;=English+Instructions+for+LimeSurvey#General_Description question ID]):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       dragDropRank(QQ);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Code in the source of the question(s) using custom text for the &amp;quot;Choices&amp;quot; and &amp;quot;Rankings&amp;quot; element header labels&#039;&#039;&#039; (replace &amp;quot;QQ&amp;quot; with the ranking [http://docs.limesurvey.org/SGQA+identifier&amp;amp;structure;=English+Instructions+for+LimeSurvey#General_Description question ID]):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       dragDropRank(QQ, &#039;Custom Choices Label&#039;, &#039;Custom Rankings Label&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Styles for template.css:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* Drag-n-drop ranking styles */&lt;br /&gt;
&lt;br /&gt;
.dragDropTable {&lt;br /&gt;
&lt;br /&gt;
   border: 0 none;&lt;br /&gt;
&lt;br /&gt;
   border-collapse: collapse;&lt;br /&gt;
&lt;br /&gt;
   width: 100%;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.dragDropTable td {&lt;br /&gt;
&lt;br /&gt;
   vertical-align: top;&lt;br /&gt;
&lt;br /&gt;
   width: 50%;&lt;br /&gt;
&lt;br /&gt;
   padding-right: 20px;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.dragDropTable .dragDropHeader {&lt;br /&gt;
&lt;br /&gt;
   font-weight: bold;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.dragDropTable .dragDropChoices,&lt;br /&gt;
&lt;br /&gt;
.dragDropTable .dragDropRanks {&lt;br /&gt;
&lt;br /&gt;
   margin: 5px 0 0 0;&lt;br /&gt;
&lt;br /&gt;
   background: transparent none;&lt;br /&gt;
&lt;br /&gt;
   border: 0 none;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.dragDropTable .dragDropChoiceList,&lt;br /&gt;
&lt;br /&gt;
.dragDropTable .dragDropRankList {&lt;br /&gt;
&lt;br /&gt;
   float: left;&lt;br /&gt;
&lt;br /&gt;
   width: 100%;&lt;br /&gt;
&lt;br /&gt;
   min-height: 2.4em;&lt;br /&gt;
&lt;br /&gt;
   _height: 2.4em; /* IE6 and below hack */&lt;br /&gt;
&lt;br /&gt;
   margin: 0;&lt;br /&gt;
&lt;br /&gt;
   padding: 0;&lt;br /&gt;
&lt;br /&gt;
   list-style-type: none;&lt;br /&gt;
&lt;br /&gt;
   background: #FBFBFB none;&lt;br /&gt;
&lt;br /&gt;
   border: 1px solid #CCCCCC;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.dragDropTable .dragDropChoiceList li,&lt;br /&gt;
&lt;br /&gt;
.dragDropTable .dragDropRankList li {&lt;br /&gt;
&lt;br /&gt;
   margin: 3px;&lt;br /&gt;
&lt;br /&gt;
   *margin-left: -13px; /* IE7 and below */&lt;br /&gt;
&lt;br /&gt;
   padding: 3px;&lt;br /&gt;
&lt;br /&gt;
   min-height: 1.3em;&lt;br /&gt;
&lt;br /&gt;
   _height: 1.3em; /* IE6 and below hack */&lt;br /&gt;
&lt;br /&gt;
   font-weight: normal;&lt;br /&gt;
&lt;br /&gt;
   cursor: move;&lt;br /&gt;
&lt;br /&gt;
   display: block; /* Force the li to full width */&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Drag and Drop Ranking using Images - Version 1.90 and newer==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+ &amp;amp; 1.91RC4, IE 6/7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround works in conjunction with the above workaround to allow ranking of images.&lt;br /&gt;
&lt;br /&gt;
[[File:Untitled-11.png]]&lt;br /&gt;
&lt;br /&gt;
There is a &#039;&#039;&#039;[http://www.partnersinc.biz/surveys//index.php?sid=36981&amp;amp;newtest;=Y&amp;amp;lang;=en demonstrated here]&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
&lt;br /&gt;
1) Follow the above workaround to get basic drag-n-drop functionality in your ranking question.&lt;br /&gt;
&lt;br /&gt;
2) Insert your images in the ranking question text or help section after any text that you wish to have there (we&#039;ll move them later with JavaScript).&lt;br /&gt;
&lt;br /&gt;
3) Give the images &#039;&#039;&#039;EXACTLY&#039;&#039;&#039; the same IDs as the answer code you would like them to be associated with:[[File:Untitled-8.png]]&lt;br /&gt;
&lt;br /&gt;
4) Place the first script below in your template.js file.&lt;br /&gt;
&lt;br /&gt;
5) Place the second script below in the source the ranking question &#039;&#039;&#039;AFTER&#039;&#039;&#039; the initial call for the dragDropRank function from the workaround above. Replace &amp;quot;QQ&amp;quot; with the ID of the ranking question (this applies the &amp;quot;dragDropRankImages&amp;quot; function to the question).&lt;br /&gt;
&lt;br /&gt;
6) Insert the CSS below at the end of template.css. Replace &amp;quot;11&amp;quot; with your question ID. These styles are for the default template using 50x50px images (as in the demo) and may need to be modified for other templates or image sizes.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Code for template.js:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
function dragDropRankImages(qID) {&lt;br /&gt;
&lt;br /&gt;
   $(&#039;.connectedSortable&#039;+qID+&#039; li&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
       // Remove any text in the sortable choice or rank items&lt;br /&gt;
&lt;br /&gt;
       $(this).text(&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
       // Move the images into the appropriate sortable list item&lt;br /&gt;
&lt;br /&gt;
       var liID = $(this).attr(&#039;id&#039;);&lt;br /&gt;
&lt;br /&gt;
       liIDArray = liID.split(&#039;_&#039;);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#question&#039;+qID+&#039; img#&#039;+liIDArray[1]+&#039;&#039;).appendTo(this);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Code in the source of the question(s):&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       dragDropRankImages(QQ);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Styles for template.css:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* Drag-n-drop for ranking images */&lt;br /&gt;
#question11 .dragDropTable {&lt;br /&gt;
&lt;br /&gt;
   width: auto;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
#question11 .dragDropTable .dragDropChoiceList,&lt;br /&gt;
#question11 .dragDropTable .dragDropRankList {&lt;br /&gt;
&lt;br /&gt;
   min-height: 60px;&lt;br /&gt;
&lt;br /&gt;
   _height: 60px; /* IE6 and below hack */&lt;br /&gt;
&lt;br /&gt;
   width: auto;&lt;br /&gt;
&lt;br /&gt;
   min-width: 60px;&lt;br /&gt;
&lt;br /&gt;
   _width: 60px; /* IE6 and below hack */&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
#question11 .dragDropTable li {&lt;br /&gt;
&lt;br /&gt;
   background: 0 none;&lt;br /&gt;
&lt;br /&gt;
   border: 0 none;&lt;br /&gt;
&lt;br /&gt;
   height: 50px;&lt;br /&gt;
&lt;br /&gt;
   width: 50px;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
#question11 .dragDropTable li img {&lt;br /&gt;
&lt;br /&gt;
   margin: 0;&lt;br /&gt;
&lt;br /&gt;
   padding: 0;&lt;br /&gt;
&lt;br /&gt;
   border: 0 none;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Drag and Drop Ranking for iPad - Version 1.91 and newer==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: LimeSurvey 1.91, iPad 2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround extends the above workarounds to work with the touch interface on iPads.&lt;br /&gt;
&lt;br /&gt;
1) Follow the &amp;quot;[http://docs.limesurvey.org/Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#Drag_and_Drop_Ranking_-_Version_1.90_and_newer Drag and Drop Ranking - Version 1.90 and newer]&amp;quot; workaround above to get basic drag-n-drop functionality in your ranking question.&lt;br /&gt;
&lt;br /&gt;
2) Download the [https://github.com/furf/jquery-ui-touch-punch jQuery.ui.touch-punch.js plugin] and save it in your template directory.&lt;br /&gt;
&lt;br /&gt;
3) Replace this line in your startpage.pstpl:&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;{TEMPLATEURL}template.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;With this:&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;{TEMPLATEURL}jquery.ui.touch-punch.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;{TEMPLATEURL}template.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Drag and Drop Ranking - Version 1.86==&lt;br /&gt;
&lt;br /&gt;
Tested with 1.86 on IE 7,8, FireFox 3, Chrome, and Safari 4&lt;br /&gt;
&lt;br /&gt;
This workaround uses [http://jqueryui.com/demos/sortable/#connect-lists JQuery connected sortables] to modify a ranking question and allow the survey taker to drag and drop choices instead of clicking.  The nice thing is that the choices can be easily re-arranged or removed from the ranking, all by drag and drop.&lt;br /&gt;
&lt;br /&gt;
I used it for a voting application and some of the element names reflect that use.&lt;br /&gt;
&lt;br /&gt;
It looks best when some CSS is added to control the appearance of the boxers around each choice.&lt;br /&gt;
&lt;br /&gt;
[[File:drag-n-drop.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   // Question ID global variable&lt;br /&gt;
&lt;br /&gt;
    var questionID;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Grab the question ID[[File:drag-n-drop.png]]&lt;br /&gt;
&lt;br /&gt;
       // This is something with a class of &amp;quot;ranking&amp;quot; and an ID that starts with &amp;quot;questionXXXXX&amp;quot;.  The X&#039;s represent the question ID&lt;br /&gt;
&lt;br /&gt;
       var entire_questionID = $(&amp;quot;.ranking[id&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&#039;question&#039;]&amp;quot;).attr(&#039;id&#039;);&lt;br /&gt;
&lt;br /&gt;
       // Get just the question number (ID)&lt;br /&gt;
&lt;br /&gt;
       var patt=/\d+$/;&lt;br /&gt;
&lt;br /&gt;
       questionID=patt.exec(entire_questionID);&lt;br /&gt;
&lt;br /&gt;
       // Hide the original quetion in LimeSurvey (so that we can replace with drag and drop)&lt;br /&gt;
&lt;br /&gt;
       $(&amp;quot;.rank, .questionhelp&amp;quot;).hide();&lt;br /&gt;
&lt;br /&gt;
       // Turn off display of question (to override error checking built into LimeSurvey ranking question)&lt;br /&gt;
&lt;br /&gt;
       $(&amp;quot;#display&amp;quot;+questionID).val(&amp;quot;off&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
       // Add connected sortables to the question&lt;br /&gt;
&lt;br /&gt;
       var html_code = &amp;quot;&amp;lt;table style=&#039;border: medium none ; width: 770px; margin-left: auto; \&lt;br /&gt;
&lt;br /&gt;
                                margin-right: auto;&#039;&amp;gt;&amp;lt;tbody&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td style=&#039;width: 590px; vertical-align: top;&#039;&amp;gt;&amp;lt;h3&amp;gt;List of Candidates:&amp;lt;/h3&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
               &amp;lt;div class=&#039;ui-state-highlight&#039; style=&#039;margin: 5px; float: left;&#039; id=&#039;ballot_list&#039;&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
                               &amp;lt;ul id=&#039;sortable1&#039; class=&#039;connectedSortable&#039;&amp;gt;&amp;lt;li&amp;gt;Candidates&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/td&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
               &amp;lt;td style=&#039;vertical-align: top;&#039;&amp;gt;&amp;lt;h3&amp;gt;Your selections:&amp;lt;/h3&amp;gt;&amp;lt;div class=&#039;ui-state-highlight&#039; \&lt;br /&gt;
&lt;br /&gt;
                               style=&#039;margin: 5px; float: left;&#039; id=&#039;voting_selections&#039;&amp;gt;&amp;lt;ol id=&#039;sortable2&#039; class=&#039;connectedSortable&#039;&amp;gt; \&lt;br /&gt;
&lt;br /&gt;
               &amp;lt;li&amp;gt;Voting Area&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/tbody&amp;gt;&amp;lt;/table&amp;gt;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
       $(html_code).appendTo(&amp;quot;#question&amp;quot; + questionID);&lt;br /&gt;
&lt;br /&gt;
       // Remove list items (have to have one item so that LimeSurvey doesn&#039;t remove the &amp;lt;ul&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
       $(&amp;quot;#sortable1 li, #sortable2 li&amp;quot;).remove();&lt;br /&gt;
&lt;br /&gt;
       // Load any previously-set values&lt;br /&gt;
&lt;br /&gt;
       loadRanking();&lt;br /&gt;
&lt;br /&gt;
       // Load jQuery UI&lt;br /&gt;
&lt;br /&gt;
       $.getScript(&amp;quot;/scripts/jquery/jquery-ui.js&amp;quot;, function() {&lt;br /&gt;
&lt;br /&gt;
           // After JQuery UI finishes loading, set up the connected sortable.&lt;br /&gt;
&lt;br /&gt;
           $(&amp;quot;#sortable1, #sortable2&amp;quot;).sortable({&lt;br /&gt;
&lt;br /&gt;
               connectWith: &#039;.connectedSortable&#039;,&lt;br /&gt;
&lt;br /&gt;
               placeholder: &#039;ui-sortable-placeholder&#039;,&lt;br /&gt;
&lt;br /&gt;
               stop: function(event, ui) {&lt;br /&gt;
&lt;br /&gt;
                   $(&amp;quot;#sortable1&amp;quot;).sortable(&amp;quot;refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                   $(&amp;quot;#sortable2&amp;quot;).sortable(&amp;quot;refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                   updateRanking();&lt;br /&gt;
&lt;br /&gt;
                   }&lt;br /&gt;
&lt;br /&gt;
           }).disableSelection();&lt;br /&gt;
&lt;br /&gt;
           // Get the list of candidates from the built-in LimeSurvey question and copy them as items in sortable1&lt;br /&gt;
&lt;br /&gt;
           $(&amp;quot;#CHOICES_&amp;quot; + questionID).children().each(function(index, Element) {&lt;br /&gt;
&lt;br /&gt;
               li_tag = &amp;quot;&amp;lt;li class=&#039;ui-state-default&#039; id=&#039;choice_&amp;quot; + $(this).attr(&#039;value&#039;) + &amp;quot;&#039;&amp;gt;&amp;quot; + this.text + &amp;quot;&amp;lt;/li&amp;gt;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
               $(li_tag).appendTo(&amp;quot;#sortable1&amp;quot;); }    );&lt;br /&gt;
&lt;br /&gt;
           // Make sure the submit button is showing&lt;br /&gt;
&lt;br /&gt;
           $(&amp;quot;:submit[value|=&#039; Submit&#039;]&amp;quot;).show();&lt;br /&gt;
&lt;br /&gt;
           // Show a confirmation alert upon submit&lt;br /&gt;
&lt;br /&gt;
           $(&amp;quot;form&amp;quot;).submit(function() {&lt;br /&gt;
&lt;br /&gt;
               // Override the built-in &amp;quot;disable navigation buttons&amp;quot; feature&lt;br /&gt;
&lt;br /&gt;
               $(&#039;#moveprevbtn, #movenextbtn, #movesubmitbtn&#039;).attr(&#039;disabled&#039;, &#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
               var validated = confirm(&amp;quot;Cast your ballot now?&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
               if (validated) { return true; } else { return false; }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Allow users to double click to move to selection list&lt;br /&gt;
&lt;br /&gt;
           $(&amp;quot;#sortable1 li&amp;quot;).assignDblClick();&lt;br /&gt;
&lt;br /&gt;
       });  // End of JQuery UI loading&lt;br /&gt;
&lt;br /&gt;
   }); // End of JQuery ready function&lt;br /&gt;
&lt;br /&gt;
// Define the actions when an item is double clicked&lt;br /&gt;
&lt;br /&gt;
$.fn.assignDblClick = function()&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   $(this).dblclick(function(){&lt;br /&gt;
&lt;br /&gt;
       $(this).appendTo(&#039;#sortable2&#039;);&lt;br /&gt;
&lt;br /&gt;
       $(&amp;quot;#sortable1&amp;quot;).sortable(&amp;quot;refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
       $(&amp;quot;#sortable2&amp;quot;).sortable(&amp;quot;refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
       updateRanking();&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// This function copies the drag and drop sortable data into the standard LimeSurvey ranking structure.&lt;br /&gt;
&lt;br /&gt;
function updateRanking()&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   var rankees = [];&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#sortable2 li&#039;).each(function(index) {&lt;br /&gt;
&lt;br /&gt;
   $(this).attr(&amp;quot;value&amp;quot;, index+1);&lt;br /&gt;
&lt;br /&gt;
       // Get value of person&lt;br /&gt;
&lt;br /&gt;
       li_tag = $(this).attr(&#039;id&#039;);&lt;br /&gt;
&lt;br /&gt;
       li_tag_array = li_tag.split(&amp;quot;_&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
       // Save to an array&lt;br /&gt;
&lt;br /&gt;
       rankees[rankees.length] = { &#039;r_name&#039;:$(this).text(),&#039;r_value&#039;:li_tag_array[1] };&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   $(&amp;quot;input[name&amp;lt;/div&amp;gt;=&#039;RANK_&#039;]&amp;quot;).each(function(index) {&lt;br /&gt;
&lt;br /&gt;
       if (rankees.length &amp;gt; index) {&lt;br /&gt;
&lt;br /&gt;
           $(this).val(rankees[index].r_name);&lt;br /&gt;
&lt;br /&gt;
           $(this).next().val(rankees[index].r_value);&lt;br /&gt;
&lt;br /&gt;
       } else {&lt;br /&gt;
&lt;br /&gt;
           $(this).val(&amp;quot;&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
           $(this).next().val(&amp;quot;&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
     });&lt;br /&gt;
&lt;br /&gt;
   // Re-assign double click action to first list items and remove&lt;br /&gt;
&lt;br /&gt;
   // double click action from section list items&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#sortable1 li&#039;).unbind(&#039;dblclick&#039;).assignDblClick();&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#sortable2 li&#039;).unbind(&#039;dblclick&#039;);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// This function is called on page load to see if there are any items already ranked (from a previous visit&lt;br /&gt;
&lt;br /&gt;
// or cached due to a page change.  If so, the already-ranked items are loaded into the sortable list&lt;br /&gt;
&lt;br /&gt;
function loadRanking()&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   var rankees = [];&lt;br /&gt;
&lt;br /&gt;
   // Loop through each item in the built-in LimeSurvey ranking list looking for non-empty values&lt;br /&gt;
&lt;br /&gt;
   $(&amp;quot;input[name&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;=&#039;RANK_&#039;]&amp;quot;).each(function(index) {&lt;br /&gt;
&lt;br /&gt;
       // Check to see if the current item has a value&lt;br /&gt;
&lt;br /&gt;
       if ($(this).val()) {&lt;br /&gt;
&lt;br /&gt;
           // Item has a value - save to the array&lt;br /&gt;
&lt;br /&gt;
           // Use this element to contain the name and the next for the value (numeric)&lt;br /&gt;
&lt;br /&gt;
           rankees[rankees.length] = { &#039;r_name&#039;:$(this).val(),&#039;r_value&#039;:$(this).next().val() };&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
   // Now that we have a list of all the pre-ranked items, populate the sortable list&lt;br /&gt;
&lt;br /&gt;
   // Note that the items *won&#039;t* appear in the main list because LimeSurvey has removed them.&lt;br /&gt;
&lt;br /&gt;
   $.each(rankees, function(index, value) {&lt;br /&gt;
&lt;br /&gt;
       // Create the items in the sortable&lt;br /&gt;
&lt;br /&gt;
       li_tag = &amp;quot;&amp;lt;li class=&#039;ui-state-default&#039; id=&#039;choice_&amp;quot; + value.r_value + &amp;quot;&#039;&amp;gt;&amp;quot; + value.r_name + &amp;quot;&amp;lt;/li&amp;gt;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
       $(li_tag).appendTo(&amp;quot;#sortable2&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Create MaxDiff question type=&lt;br /&gt;
&lt;br /&gt;
See the &amp;quot;[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Question+design%2C+layout+and+templating&amp;amp;structure;=English+Instructions+for+LimeSurvey Question design, layout and templating]&amp;quot; section for a workaround that uses JavaScript to convert an &#039;&#039;&#039;&#039;&#039;Array (flexible labels) by column&#039;&#039;&#039;&#039;&#039; question into a [http://en.wikipedia.org/wiki/MaxDiff MaxDiff] question type.&lt;br /&gt;
&lt;br /&gt;
[[File:max_diff_596x253.gif]]&lt;br /&gt;
&lt;br /&gt;
=In a checkbox matrix, have the &#039;none&#039; option in a row disable all other columns in that row=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: Limesurvey 1.90+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The questionId parameter is the base ID of the question matrix (multiflexible).&lt;br /&gt;
&lt;br /&gt;
numColumns and numRows speak for themselves&lt;br /&gt;
&lt;br /&gt;
specialColumns is an array of the columns that have the special ability that when one of them&lt;br /&gt;
&lt;br /&gt;
is checked, none of the others can be checked. E.g., a &#039;none of these&#039; and/or a &#039;do now know&#039; option.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
numColumns=13;&lt;br /&gt;
&lt;br /&gt;
numRows=18;&lt;br /&gt;
&lt;br /&gt;
questionId=&#039;28417X2X24&#039;;&lt;br /&gt;
&lt;br /&gt;
specialColumns=[1,12,13];&lt;br /&gt;
&lt;br /&gt;
function action(obj){&lt;br /&gt;
&lt;br /&gt;
   locator=obj.id.replace(&#039;cbox_&#039;+questionId, &#039;&#039;).split(&#039;_&#039;);&lt;br /&gt;
&lt;br /&gt;
   row=locator[0];&lt;br /&gt;
&lt;br /&gt;
   column=locator[1];&lt;br /&gt;
&lt;br /&gt;
   //alert(&#039;Action for row,column=&#039;+row+&#039;,&#039;+column);&lt;br /&gt;
&lt;br /&gt;
   my_id=&#039;#cbox_&#039;+questionId+row+&#039;_&#039;+column+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
   if($(my_id).attr(&#039;checked&#039;) == false) {&lt;br /&gt;
&lt;br /&gt;
       for( var i=1; i&amp;lt;=numColumns; i++ ) {&lt;br /&gt;
&lt;br /&gt;
           if(i==column) continue;&lt;br /&gt;
&lt;br /&gt;
           id=&#039;#cbox_&#039;+questionId+row+&#039;_&#039;+i&lt;br /&gt;
&lt;br /&gt;
           $(id).attr(&#039;disabled&#039;,false);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   } else {&lt;br /&gt;
&lt;br /&gt;
       for( var i=1; i&amp;lt;=numColumns; i++ ) {&lt;br /&gt;
&lt;br /&gt;
           if(i==column) continue;&lt;br /&gt;
&lt;br /&gt;
           id=&#039;#cbox_&#039;+questionId+row+&#039;_&#039;+i&lt;br /&gt;
&lt;br /&gt;
           aid=&#039;#answer&#039;+questionId+row+&#039;_&#039;+i&lt;br /&gt;
&lt;br /&gt;
           $(aid).val(0);&lt;br /&gt;
&lt;br /&gt;
           $(id).attr(&#039;checked&#039;,false);&lt;br /&gt;
&lt;br /&gt;
           $(id).attr(&#039;disabled&#039;,true);&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function customOnLoad(){&lt;br /&gt;
&lt;br /&gt;
   for( var row=1; row&amp;lt;=numRows; row++ ) {&lt;br /&gt;
&lt;br /&gt;
       for( var k=0; k&amp;lt;specialColumns.length; k++ )&lt;br /&gt;
&lt;br /&gt;
       {&lt;br /&gt;
&lt;br /&gt;
           column=specialColumns[k];&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#cbox_&#039;+questionId+row+&#039;_&#039;+column).change(function() {&lt;br /&gt;
&lt;br /&gt;
               action(this);&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
jQuery(document).ready(&lt;br /&gt;
&lt;br /&gt;
   function(){&lt;br /&gt;
&lt;br /&gt;
   customOnLoad();&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Last Option In Array (Numbers) (Checkboxes) Row Excludes All Others=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround uses JavaScript/jQuery to make the last option of each Array (Numbers) (Checkboxes) row exclude all other options in the same row.&lt;br /&gt;
&lt;br /&gt;
The script will uncheck all options in a row if the last option is checked and uncheck the last option in a row if any other options are checked.&lt;br /&gt;
&lt;br /&gt;
It&#039;s [http://www.partnersinc.biz/surveys//index.php?sid=22532&amp;amp;newtest;=Y&amp;amp;lang;=en demonstrated here].&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_ Set up your survey to use JavaScript].&lt;br /&gt;
#Place the following script in the source of the array question or the group description.&lt;br /&gt;
#Call the script by replacing &amp;quot;QQ&amp;quot; in line 6 with your array question ID (you can call the script for more array questions by copying this line with new IDs).&lt;br /&gt;
&lt;br /&gt;
NOTE: Care should be taken when using this script and conditional questions on the same page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Call the exclude function using question ID(s)&lt;br /&gt;
&lt;br /&gt;
       excludeOpt (QQ);&lt;br /&gt;
&lt;br /&gt;
       // A function to make the last option in each array row exclusive&lt;br /&gt;
&lt;br /&gt;
       function excludeOpt (qID) {&lt;br /&gt;
&lt;br /&gt;
           // Add some classes to the checkboxes so we can manipulate them&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qID+&#039; table.question tbody td&#039;).addClass(&#039;normalOpt&#039;);&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qID+&#039; table.question tbody&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
               $(&#039;td:last&#039;, this).removeClass(&#039;normalOpt&#039;).addClass(&#039;exlusiveOpt&#039;)&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // A listener on the checkbox cells&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qID+&#039; table.question tbody td&#039;).click(function (event) {&lt;br /&gt;
&lt;br /&gt;
               // Set some vars&lt;br /&gt;
&lt;br /&gt;
               var el = $(this).parent();&lt;br /&gt;
&lt;br /&gt;
               var optLength = $(&#039;td&#039;, el).length&lt;br /&gt;
&lt;br /&gt;
               // Uncheck the appropriate boxes in a row&lt;br /&gt;
&lt;br /&gt;
               if ($(this).hasClass(&#039;normalOpt&#039;)) {&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;td:last input[type=checkbox]&#039;, el).attr(&#039;checked&#039;, false);&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               else {&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;td&#039;, el).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
                       if (i &amp;lt; (optLength - 1)) {&lt;br /&gt;
&lt;br /&gt;
                           $(&#039;input[type=checkbox]&#039;, this).attr(&#039;checked&#039;, false);&lt;br /&gt;
&lt;br /&gt;
                       }&lt;br /&gt;
&lt;br /&gt;
                   });&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // A listener on the checkboxes&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qID+&#039; table.question tbody td input[type=checkbox]&#039;).click(function (event) {&lt;br /&gt;
&lt;br /&gt;
               // Set some vars&lt;br /&gt;
&lt;br /&gt;
               var el2 = $(this).parent().parent();&lt;br /&gt;
&lt;br /&gt;
               var optLength = $(&#039;td&#039;, el2).length&lt;br /&gt;
&lt;br /&gt;
               // Uncheck the appropriate boxes in a row&lt;br /&gt;
&lt;br /&gt;
               if ($(this).parent().hasClass(&#039;normalOpt&#039;)) {&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;td:last input[type=checkbox]&#039;, el2).attr(&#039;checked&#039;, false);&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               else {&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;td&#039;, el2).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
                       if (i &amp;lt; (optLength - 1)) {&lt;br /&gt;
&lt;br /&gt;
                           $(&#039;input[type=checkbox]&#039;, this).attr(&#039;checked&#039;, false);&lt;br /&gt;
&lt;br /&gt;
                       }&lt;br /&gt;
&lt;br /&gt;
                   });&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Load SVG Code From Drawing Tool=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround uses JavaScript/jQuery to load a drawing tool and store the results in a huge-text question.&lt;br /&gt;
&lt;br /&gt;
The drawing tool is supplied by [http://www.mainada.net/inputdraw/ mainada.net].&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#Go to [www.mainada.net/inputdraw/downloads|www.mainada.net/inputdraw/downloads], download the latest package and install all files in the root of your LS installation (you only really need &#039;&#039;&#039;inputdraw.js&#039;&#039;&#039;, &#039;&#039;&#039;inputdraw.non-commercial.v1.5.swf&#039;&#039;&#039; and &#039;&#039;&#039;swfobject.js&#039;&#039;&#039; but the others are cool to play with).&lt;br /&gt;
#Add the following to the &amp;lt;head&amp;gt; element of your template startpage.pstpl file to pull in the scripts:&lt;br /&gt;
&lt;br /&gt;
+~hs&amp;lt;span style=&amp;quot;color:hs&amp;lt;/span&amp;gt;hs&amp;lt;span style=&amp;quot;color:hs~&amp;lt;script src=&amp;quot;swfobject.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
+~hs&amp;lt;/span&amp;gt;hs&amp;lt;span style=&amp;quot;color:hs&amp;lt;/span&amp;gt;hs~&amp;lt;script src=&amp;quot;inputdraw.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
#Create a huge-text question and add the following script to the source of that question.&lt;br /&gt;
&lt;br /&gt;
The script will&amp;quot;&amp;gt;&lt;br /&gt;
*Automatically find the ID of the first huge-text question on the page&lt;br /&gt;
*Insert the drawing element into the huge-text question&lt;br /&gt;
*Hide the textarea of that question&lt;br /&gt;
*Populate it with the SVG code generated by the drawing element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Find the survey, group and question IDs&lt;br /&gt;
&lt;br /&gt;
       if($( &#039;input#fieldnames&#039; ).length != 0) {&lt;br /&gt;
&lt;br /&gt;
           var fieldNames = $(&#039;input#fieldnames&#039;).attr(&#039;value&#039;);&lt;br /&gt;
&lt;br /&gt;
           var tmp = fieldNames.split(&#039;X&#039;);&lt;br /&gt;
&lt;br /&gt;
           var sID = tmp[0];&lt;br /&gt;
&lt;br /&gt;
           var gID = tmp[1];&lt;br /&gt;
&lt;br /&gt;
           var qIDStr = $(&#039;div.text-huge:eq(0)&#039;).attr(&#039;id&#039;);&lt;br /&gt;
&lt;br /&gt;
           var tmp2 = qIDStr.split(&#039;question&#039;);&lt;br /&gt;
&lt;br /&gt;
           var qID = tmp2[1];&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       var textAreaID = &#039;answer&#039;+sID+&#039;X&#039;+gID+&#039;X&#039;+qID;&lt;br /&gt;
&lt;br /&gt;
       // Hide the textarea&lt;br /&gt;
&lt;br /&gt;
   $(&#039;#&#039;+textAreaID+&#039;&#039;).hide();&lt;br /&gt;
&lt;br /&gt;
       // Insert an element for the drawing tool&lt;br /&gt;
&lt;br /&gt;
   $(&#039;&amp;lt;div id=&amp;quot;place&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&#039;).insertBefore($(&#039;#&#039;+textAreaID+&#039;&#039;));&lt;br /&gt;
&lt;br /&gt;
       // Load the drawing tool&lt;br /&gt;
&lt;br /&gt;
   var draw = new InputDraw(&#039;inputdraw.non-commercial.v1.5.swf&#039;, &#039;place&#039;, {&lt;br /&gt;
&lt;br /&gt;
           id:textAreaID,&lt;br /&gt;
&lt;br /&gt;
           width:&#039;350&#039;,&lt;br /&gt;
&lt;br /&gt;
           height:&#039;100&#039;,&lt;br /&gt;
&lt;br /&gt;
           stroke_style:&#039;2 1 rgb(255,0,0)&#039;,&lt;br /&gt;
&lt;br /&gt;
           animation:60,&lt;br /&gt;
&lt;br /&gt;
           color:&#039;#CCCCCC&#039; ,&lt;br /&gt;
&lt;br /&gt;
           tools_color:&#039;0xd6c004&#039;,&lt;br /&gt;
&lt;br /&gt;
           clean:&#039;clear.png&#039;,&lt;br /&gt;
&lt;br /&gt;
           undo:&#039;undo.png&#039;,&lt;br /&gt;
&lt;br /&gt;
           disable:&#039;size opacity color&#039; // Get rid of most of the tools&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Add Navigation Buttons (Next and Previous) To Top Of Page=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.90+, IE 7/8, Firefox 3.6, Safari 3.2&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Add the following to the end of template.js. It will insert a new div after the progress bar and then insert clones of the nav buttons in the new div.&lt;br /&gt;
&lt;br /&gt;
This example is for the default template in 1.90 or 1.91. The placement of the new div may need to be modified for other templates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Insert a new div after the progress bar&lt;br /&gt;
&lt;br /&gt;
       $(&#039;&amp;lt;div id=&amp;quot;navigator2&amp;quot; /&amp;gt;&#039;).insertAfter(&#039;#progress-wrapper&#039;);&lt;br /&gt;
&lt;br /&gt;
       // Style the new div&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#navigator2&#039;).css({&lt;br /&gt;
&lt;br /&gt;
           &#039;text-align&#039;:&#039;center&#039;&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // Insert clones of the nav buttons in the new div&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input.submit:eq(0)&#039;).clone().appendTo(&#039;#navigator2&#039;);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input.submit:eq(2)&#039;).clone().appendTo(&#039;#navigator2&#039;);&lt;br /&gt;
&lt;br /&gt;
       // Give the new buttons some new IDs&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#navigator2 input.submit&#039;).each(function(i) {&lt;br /&gt;
&lt;br /&gt;
           var oldID = $(this).attr(&#039;id&#039;);&lt;br /&gt;
&lt;br /&gt;
           var newID = oldID + &#039;2&#039;;&lt;br /&gt;
&lt;br /&gt;
           $(this).attr(&#039;id&#039;, newID)&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:extra_buttons.png]]&lt;br /&gt;
&lt;br /&gt;
=How to &#039;&#039;add&#039;&#039; an opt out link to your survey using javascript.=&lt;br /&gt;
&lt;br /&gt;
Tested with: 1.91+, Firefox 5.0&lt;br /&gt;
&lt;br /&gt;
This javascript inserts a link to opt out of the survey above the progress bar.&lt;br /&gt;
&lt;br /&gt;
First see the section above entitled: &amp;quot;How to use Script (eg. JavaScript etc.) in LimeSurvey?&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Then insert the following code into to the source of a group description or a question. I used the group description.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt; &amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Find the survey ID&lt;br /&gt;
&lt;br /&gt;
       if($(&#039;input#fieldnames&#039;).length != 0) {&lt;br /&gt;
&lt;br /&gt;
           var fieldNames = $(&#039;input#fieldnames&#039;).attr(&#039;value&#039;);&lt;br /&gt;
&lt;br /&gt;
           var tmp = fieldNames.split(&#039;X&#039;);&lt;br /&gt;
&lt;br /&gt;
           var sID = tmp[0];&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       // Insert a new div after the progress bar&lt;br /&gt;
&lt;br /&gt;
       $(&#039;&amp;lt;div id=&amp;quot;optOutLink&amp;quot; /&amp;gt;&#039;).insertBefore(&#039;#progress-wrapper&#039;);&lt;br /&gt;
&lt;br /&gt;
       // Style the new div&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#optOutLink&#039;).css({&lt;br /&gt;
&lt;br /&gt;
           &#039;text-align&#039;:&#039;center&#039;&lt;br /&gt;
&lt;br /&gt;
       });&lt;br /&gt;
&lt;br /&gt;
       // Insert opt out url in the new div&lt;br /&gt;
&lt;br /&gt;
       $(&#039;#optOutLink&#039;).html(&#039;&amp;lt;P&amp;gt;&amp;lt;a href=&amp;quot;optout.php?lang=en&amp;amp;sid;=&#039;+sID+&#039;&amp;amp;token;={TOKEN}&amp;quot;&amp;gt; /&lt;br /&gt;
&lt;br /&gt;
               Click here to opt out of this survey.&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;&amp;lt;br&amp;gt;&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Anonymously track respondents answers across multiple surveys=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.91+ and 1.92+&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This workaround uses JavaScript/jQuery to enable tracking of respondents across multiple surveys ensuring anonymity (it does not use tokens).&lt;br /&gt;
&lt;br /&gt;
To do this you have to use this question in all the surveys you want to link respondents answers.&lt;br /&gt;
&lt;br /&gt;
This workaround create an ID by asking some partial personal information (like initials, birth month ...). The ID will be encrypted using a one-way function (in this case SHA-1) and stored in a brief text answer.&lt;br /&gt;
&lt;br /&gt;
Implementation is as follows:&lt;br /&gt;
#[http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&amp;amp;structure;=English+Instructions+for+LimeSurvey#How_to_use_Script_eg._JavaScript_etc._in_LimeSurvey_ Set up your survey to use JavaScript].&lt;br /&gt;
#Place the following code in the source of a brief text question.&lt;br /&gt;
#Optional: you can also add other select field to avoid collisions (e.g. for large population sample)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;This answers are used to generate your ID. These information will be encrypted, it will not be possible in any case to identify you neither from your answers nor from your ID.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;Initial of your name&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;select id=&amp;quot;field1&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;&amp;quot;&amp;gt;&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;A&amp;quot;&amp;gt;A&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;B&amp;quot;&amp;gt;B&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;C&amp;quot;&amp;gt;C&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;D&amp;quot;&amp;gt;D&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;E&amp;quot;&amp;gt;E&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;F&amp;quot;&amp;gt;F&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;G&amp;quot;&amp;gt;G&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;H&amp;quot;&amp;gt;H&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;I&amp;quot;&amp;gt;I&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;J&amp;quot;&amp;gt;J&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;K&amp;quot;&amp;gt;K&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;L&amp;quot;&amp;gt;L&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;M&amp;quot;&amp;gt;M&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;N&amp;quot;&amp;gt;N&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;O&amp;quot;&amp;gt;O&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;P&amp;quot;&amp;gt;P&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;Q&amp;quot;&amp;gt;Q&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;R&amp;quot;&amp;gt;R&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;S&amp;quot;&amp;gt;S&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;T&amp;quot;&amp;gt;T&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;U&amp;quot;&amp;gt;U&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;V&amp;quot;&amp;gt;V&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;W&amp;quot;&amp;gt;W&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;X&amp;quot;&amp;gt;X&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;Y&amp;quot;&amp;gt;Y&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;Z&amp;quot;&amp;gt;Z&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/select&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;Your birth month&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;select id=&amp;quot;field2&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;&amp;quot;&amp;gt;&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;01&amp;quot;&amp;gt;January&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;02&amp;quot;&amp;gt;February&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;03&amp;quot;&amp;gt;March&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;04&amp;quot;&amp;gt;April&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;05&amp;quot;&amp;gt;May&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;06&amp;quot;&amp;gt;June&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;07&amp;quot;&amp;gt;July&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;08&amp;quot;&amp;gt;August&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;09&amp;quot;&amp;gt;September&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;10&amp;quot;&amp;gt;October&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;11&amp;quot;&amp;gt;November&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;option value=&amp;quot;12&amp;quot;&amp;gt;December&amp;lt;/option&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/select&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;http://crypto-js.googlecode.com/svn/tags/3.0.2/build/rollups/sha1.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
   $(&amp;quot;#answer{SGQ}&amp;quot;).attr(&#039;readonly&#039;, &#039;readonly&#039;);&lt;br /&gt;
&lt;br /&gt;
   //$(&amp;quot;#answer{SGQ}&amp;quot;).css(&#039;display&#039;, &#039;none&#039;); //uncomment this line for not displaying the code&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
$(&#039;#field1, #field2&#039;).bind(&#039;change keyup&#039;, function() {&lt;br /&gt;
&lt;br /&gt;
   if ($(&amp;quot;#field1&amp;quot;).val()==&#039;&#039; || $(&amp;quot;#field2&amp;quot;).val()==&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
       $(&amp;quot;#answer{SGQ}&amp;quot;).val(&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
   else {&lt;br /&gt;
&lt;br /&gt;
       var sha1 = CryptoJS.algo.SHA1.create();&lt;br /&gt;
&lt;br /&gt;
       sha1.update($(&amp;quot;#field1&amp;quot;).val());&lt;br /&gt;
&lt;br /&gt;
       sha1.update($(&amp;quot;#field2&amp;quot;).val());&lt;br /&gt;
&lt;br /&gt;
       // sha1.update($(&amp;quot;#otherfield&amp;quot;).val());&lt;br /&gt;
&lt;br /&gt;
       var hash = sha1.finalize();&lt;br /&gt;
&lt;br /&gt;
       $(&amp;quot;#answer{SGQ}&amp;quot;).val(hash);&lt;br /&gt;
&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Check validity of international phone number in subquestion=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.91+, Firefox 8, Chrome 15&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;As of version 1.92, you can use the core Validation querstion option to validate multiple short text and array text questions. Any question that fails that validation check will have its background color changed to red.&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;Note, the below workaround will fail in version 1.92 because it contains a regular expression with curly braces.  However, as described above, support for this feature is now built-in to version 1.92&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround uses javascript to check the validity of an international phone number in a subquestion of multiple short text.&lt;br /&gt;
&lt;br /&gt;
Add the following code to the source of your question.&lt;br /&gt;
&lt;br /&gt;
Replace &amp;quot;QQ&amp;quot; with the question ID and &amp;quot;NN&amp;quot; with the row number that you want to validate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Call the phone function with the question ID and the row number&lt;br /&gt;
&lt;br /&gt;
       phoneTest(QQ, NN);&lt;br /&gt;
&lt;br /&gt;
       function phoneTest(qID, inputNum) {&lt;br /&gt;
&lt;br /&gt;
           // Interrupt next/submit function&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#movenextbtn, #movesubmitbtn&#039;).click(function(){&lt;br /&gt;
&lt;br /&gt;
               // Some vars - modify as required&lt;br /&gt;
&lt;br /&gt;
               var phoneMatch = /^[0-9,+,(), ,]{1,}(,[0-9]+){0,}$/;&lt;br /&gt;
&lt;br /&gt;
               var msg1 = &#039;Please enter a valid phone number.&#039;;&lt;br /&gt;
&lt;br /&gt;
               // Test the input&lt;br /&gt;
&lt;br /&gt;
               var phoneInput = $(&#039;#question&#039;+qID+&#039; li:eq(&#039;+(inputNum-1)+&#039;) input.text&#039;).val();&lt;br /&gt;
&lt;br /&gt;
               if(phoneInput != &#039;&#039; &amp;amp;&amp;amp; !phoneMatch.test(phoneInput)) {&lt;br /&gt;
&lt;br /&gt;
                   alert(msg1);&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;#question&#039;+qID+&#039; li:eq(&#039;+(inputNum-1)+&#039;) input.text&#039;).css({ &#039;background&#039;:&#039;pink&#039; });&lt;br /&gt;
&lt;br /&gt;
                   return false;&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               else {&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;#question&#039;+qID+&#039; li:eq(&#039;+(inputNum-1)+&#039;) input.text&#039;).css({ &#039;background&#039;:&#039;&#039; });&lt;br /&gt;
&lt;br /&gt;
                   return true;&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The regex is from: [http://www.regexlib.com/REDetails.aspx?regexp_id=1136 regexlib.com blank]&lt;br /&gt;
&lt;br /&gt;
=Check validity of email address in subquestion=&lt;br /&gt;
&lt;br /&gt;
&#039;Tested with: 1.91+, Firefox 8, Chrome 15&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;As of version 1.92, you can use the core Validation querstion option to validate multiple short text and array text questions. Any question that fails that validation check will have its background color changed to red.&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;Note, the below workaround will fail in version 1.92 because it contains a regular expression with curly braces.  However, as described above, support for this feature is now built-in to version 1.92&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This workaround uses javascript to check the validity of an email address in a subquestion of multiple short text.&lt;br /&gt;
&lt;br /&gt;
Add the following code to the source of your question.&lt;br /&gt;
&lt;br /&gt;
Replace &amp;quot;QQ&amp;quot; with the question ID and &amp;quot;NN&amp;quot; with the row number that you want to validate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Call the email function with the question ID and the row number&lt;br /&gt;
&lt;br /&gt;
       emailTest(QQ, NN);&lt;br /&gt;
&lt;br /&gt;
       function emailTest(qID, inputNum) {&lt;br /&gt;
&lt;br /&gt;
           // Interrupt next/submit function&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#movenextbtn, #movesubmitbtn&#039;).click(function(){&lt;br /&gt;
&lt;br /&gt;
               // Some vars - modify as required&lt;br /&gt;
&lt;br /&gt;
               var emailMatch = /^[a-zA-Z0-9\_\-]+[a-zA-Z0-9\.\_\-]*@([a-zA-Z0-9\_\-]+\.)+([a-zA-Z]{2,4}|travel|museum)$/;&lt;br /&gt;
&lt;br /&gt;
               var msg1 = &#039;Please enter a valid email address.&#039;;&lt;br /&gt;
&lt;br /&gt;
               // Test the input&lt;br /&gt;
&lt;br /&gt;
               var emailInput = $(&#039;#question&#039;+qID+&#039; li:eq(&#039;+(inputNum-1)+&#039;) input.text&#039;).val();&lt;br /&gt;
&lt;br /&gt;
               if(emailInput != &#039;&#039; &amp;amp;&amp;amp; !emailMatch.test(emailInput)) {&lt;br /&gt;
&lt;br /&gt;
                   alert(msg1);&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;#question&#039;+qID+&#039; li:eq(&#039;+(inputNum-1)+&#039;) input.text&#039;).css({ &#039;background&#039;:&#039;pink&#039; });&lt;br /&gt;
&lt;br /&gt;
                   return false;&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
               else {&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;#question&#039;+qID+&#039; li:eq(&#039;+(inputNum-1)+&#039;) input.text&#039;).css({ &#039;background&#039;:&#039;&#039; });&lt;br /&gt;
&lt;br /&gt;
                   return true;&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The regex is from: [http://www.regexlib.com/REDetails.aspx?regexp_id=1653 regexlib.com blank]&lt;br /&gt;
&lt;br /&gt;
=Hiding the help-text when it&#039;s empty=&lt;br /&gt;
&lt;br /&gt;
Tested with: 1.91+&lt;br /&gt;
&lt;br /&gt;
I had made a style in my template putting a border around my help-text. To avoid empty help-text to show up (and have lines instead of just &#039;nothing&#039; when there was no help text, I used this piece of code in question.pstpl:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
                   var questionhelp=&amp;quot;{QUESTIONHELP}&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
                   if (questionhelp==&amp;quot;&amp;quot;) {&lt;br /&gt;
&lt;br /&gt;
                          document.write(&amp;quot;&amp;quot;);}&lt;br /&gt;
&lt;br /&gt;
                   else {&lt;br /&gt;
&lt;br /&gt;
                   document.write(&#039;&amp;lt;tr&amp;gt;&amp;lt;td class=&amp;quot;survey-question-help&amp;quot;&amp;gt;&#039;+ questionhelp +&#039;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&#039;);}&lt;br /&gt;
&lt;br /&gt;
               &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
it can probably be optimized but it worked for me&lt;br /&gt;
&lt;br /&gt;
=Disable or hide selected fields in a matrix question=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested with: 1.92+, IE 7/8/9, FireFox 12/13&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
TASK&lt;br /&gt;
&lt;br /&gt;
Hide or disable selected fields in a Matrix, so that users cannot make any input.&lt;br /&gt;
&lt;br /&gt;
(See example, where users should not make input into red framed fields)&lt;br /&gt;
&lt;br /&gt;
[[File:snap035.gif]]&lt;br /&gt;
&lt;br /&gt;
Fig. 1: Prevent users from input into first two fields (as an example)&lt;br /&gt;
&lt;br /&gt;
SOLUTION&lt;br /&gt;
&lt;br /&gt;
First find the name of the fields you want to hide / disable. In my case I used Firebug with firefox to figure that out.&lt;br /&gt;
&lt;br /&gt;
[[File:snap037.gif]]&lt;br /&gt;
&lt;br /&gt;
Fig. 2: Figure out the name(s) of the field(s)&lt;br /&gt;
&lt;br /&gt;
Then put the following script-code into the HTML-source code as described above:&lt;br /&gt;
&lt;br /&gt;
Note: you have to change the code to match the names of your fields!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input[name=&amp;quot;69965X2X10SQ001_SQ001&amp;quot;]&#039;).attr(&#039;disabled&#039;, &#039;disabled&#039;);&lt;br /&gt;
&lt;br /&gt;
       $(&#039;input[name=&amp;quot;69965X2X10SQ001_SQ002&amp;quot;]&#039;).attr(&#039;hidden&#039;, &#039;hidden&#039;);&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:snap039.gif]]&lt;br /&gt;
&lt;br /&gt;
Fig. 3: Result: first field is diabled (&amp;quot;greyed out&amp;quot;), second one is completely hidden&lt;br /&gt;
&lt;br /&gt;
I think this way one can apply many other attributes to a field like color etc. But did not try that myself.&lt;br /&gt;
&lt;br /&gt;
Thanks to roB2009 for the input in the forum!&lt;br /&gt;
&lt;br /&gt;
=Add prefix or suffix to question type &amp;quot;Array (Texts)&amp;quot;=&lt;br /&gt;
&lt;br /&gt;
TASK&lt;br /&gt;
&lt;br /&gt;
Add a prefix or suffix to the text fields in questions of the &amp;quot;Array (Texts)&amp;quot; type.&lt;br /&gt;
&lt;br /&gt;
[[File:suffix.png]]&lt;br /&gt;
&lt;br /&gt;
Fig. 1: Suffix&lt;br /&gt;
&lt;br /&gt;
[[File:prefix.png]]&lt;br /&gt;
&lt;br /&gt;
Fig. 1: Prefix&lt;br /&gt;
&lt;br /&gt;
SOLUTION&lt;br /&gt;
*Set up your survey to use JavaScript.&lt;br /&gt;
*Add the following script to the source of the array. Replace &amp;quot;12345&amp;quot; with the array question ID and modify the suffixes/prefixes as required.&lt;br /&gt;
*The function call must consist of a question ID followed by the suffixes for each column. Suffixes/Prefixes must be enclosed in quotes and comma separated.&lt;br /&gt;
*In this example question ID 12345 will get an &amp;quot;in &amp;amp;euro;&amp;quot; suffix in the first column and an &amp;quot;in %&amp;quot; in the next 3 columns.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
       // Call the function with the question ID followed by a comma-separated list of suffixes&lt;br /&gt;
&lt;br /&gt;
       addSuffix(12345, &#039;in &amp;amp;euro;&#039;, &#039;in %&#039;, &#039;in %&#039;, &#039;in %&#039;);&lt;br /&gt;
&lt;br /&gt;
       function addSuffix() {&lt;br /&gt;
&lt;br /&gt;
           var qID = $(arguments)[0];&lt;br /&gt;
&lt;br /&gt;
           // Assign some column-specific classes&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qID+&#039; table.question tbody tr&#039;).each(function(i){&lt;br /&gt;
&lt;br /&gt;
               $(&#039;td&#039;, this).each(function(i){&lt;br /&gt;
&lt;br /&gt;
                   $(this).addClass(&#039;answerCol-&#039;+(i+1)+&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
               });&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Some styling&lt;br /&gt;
&lt;br /&gt;
           $(&#039;#question&#039;+qID+&#039; table.question tbody input[type=&amp;quot;text&amp;quot;]&#039;).css({&lt;br /&gt;
&lt;br /&gt;
               &#039;width&#039;: &#039;50%&#039;&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           // Insert the suffixes&lt;br /&gt;
&lt;br /&gt;
           $(arguments).each(function(i, val){&lt;br /&gt;
&lt;br /&gt;
               if(i &amp;gt; 0) {&lt;br /&gt;
&lt;br /&gt;
                   $(&#039;#question&#039;+qID+&#039; td.answerCol-&#039;+i+&#039; label&#039;).append(val);&lt;br /&gt;
&lt;br /&gt;
               }&lt;br /&gt;
&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For adding a prefix you need to substitute the following line in the code&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;$(&#039;#question&#039;+qID+&#039; td.answerCol-&#039;+i+&#039; label&#039;).append(val);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with this&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;$(&#039;#question&#039;+qID+&#039; td.answerCol-&#039;+i+&#039; label&#039;).prepend(val);&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Holch</name></author>
	</entry>
	<entry>
		<id>https://www.limesurvey.org/manual/index.php?title=Survey_participants&amp;diff=3431</id>
		<title>Survey participants</title>
		<link rel="alternate" type="text/html" href="https://www.limesurvey.org/manual/index.php?title=Survey_participants&amp;diff=3431"/>
		<updated>2012-06-21T15:49:13Z</updated>

		<summary type="html">&lt;p&gt;Holch: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;&#039;&#039;&#039;Note&#039;&#039;&#039;:  Tokens have changed alot in Version 1.85 and later. So if you are using an earlier version there will be differences between your version and the documentation. We recommend to upgrade as soon as possible.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
On many occasions you will want to invite a group of people to participate in your survey, keep track of who has completed the survey, and ensure that each person can only participate once. The tokens feature allows you to do the following:&lt;br /&gt;
*Manually create invitations (name, email address, ...)&lt;br /&gt;
*Import a list of names and email addresses for participants (from a CSV file or an LDAP query)&lt;br /&gt;
*Add/Remove invitations&lt;br /&gt;
*Generate a unique token number for each participant (invitation code)&lt;br /&gt;
*Send an email invitation to each person in your list, by group or individually&lt;br /&gt;
*Send a reminder email to each person in your list who has not yet responded, by group or individually&lt;br /&gt;
*Track who from your list has responded&lt;br /&gt;
*Restrict access against people who have not got a token, and those with a token who have already responded&lt;br /&gt;
*Edit/change any details in your list&lt;br /&gt;
&lt;br /&gt;
Once the survey is switched to Closed-access mode (you have enabled tokens for this survey), then &#039;&#039;&#039;only the people with a valid token code (not already used) can access the survey&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
If you enable &#039;&#039;Auto-registration&#039;&#039; in the survey properties, participants will be able to register for your survey to have their personal token code automatically generated.&lt;br /&gt;
&lt;br /&gt;
==Can a survey using tokens ensure anonymous answers?==&lt;br /&gt;
&lt;br /&gt;
The answer to this question is &#039;&#039;&#039;Yes&#039;&#039;&#039;. Tokens can be used both for anonymous and non-anonymous surveys. This is determined when creating a survey. If a survey is not anonymous (or &#039;tracked&#039;) then the token list can be used to find the responses that an individual has made to the survey. If the survey is anonymous, then no link (technically: foreign key relationship) is available between the tokens table and the responses.&lt;br /&gt;
&lt;br /&gt;
=How to activate tokens?=&lt;br /&gt;
&lt;br /&gt;
There are two ways to activate tokens:&lt;br /&gt;
#After survey activation you will be asked if you want to activate tokens: [[File:Switch-to-closed-access-mode.png]]&lt;br /&gt;
# &#039;&#039;&#039;OR &#039;&#039;&#039;you can click on the tokens symbol [[File:tokens.png]] - even before the survey is activated.&lt;br /&gt;
&lt;br /&gt;
=The token management tools=&lt;br /&gt;
&lt;br /&gt;
[[File:token-menu2.png]]&lt;br /&gt;
&lt;br /&gt;
After creating the tokens table you can click on the tokens icon to get to the token administration. The following is a brief rundown of the menu options in the tokens screen:&lt;br /&gt;
*&#039;&#039;&#039;Admin&#039;&#039;&#039;: Returns to the main survey admin screen&lt;br /&gt;
*&#039;&#039;&#039;Summary&#039;&#039;&#039;: Displays just the brief summary of tokens in the table (number of tokens, how many have been sent an invitation, and how many have responded). Also provides access to the Database Admin functions (see below). This is the default screen.&lt;br /&gt;
*&#039;&#039;&#039;Browse&#039;&#039;&#039;: Displays the complete list of participants in the tokens table. From the browse screen you can edit or delete individual entries in the token table as well as perform a number of other useful functions (see browse section below)&lt;br /&gt;
*&#039;&#039;&#039;Add new token entry&#039;&#039;&#039;: Allows you to add an entry to the tokens table&lt;br /&gt;
*&#039;&#039;&#039;Add dummy token&#039;&#039;&#039;: Allows you to add 1 or more tokens to the token table&lt;br /&gt;
*&#039;&#039;&#039;Manage additional field attributes&#039;&#039;&#039;: Allows you to add additional fields to the tokens table to store custom participant data&lt;br /&gt;
*&#039;&#039;&#039;Import from CSV&#039;&#039;&#039;: Allows you to import information from a csv file&lt;br /&gt;
*&#039;&#039;&#039;Import from LDAP&#039;&#039;&#039;: Allows you to import information from an LDAP query (tested on openLdap but should work in any LDAP compliant directory including ActiveDirectory)&lt;br /&gt;
*&#039;&#039;&#039;Export tokens to CSV file&#039;&#039;&#039;: creates a standard CSV (comma delimited) file with a complete list of participants of your current tokens table&lt;br /&gt;
*&#039;&#039;&#039;Edit email templates&#039;&#039;&#039;: Used to customize the templates used for the invitations, reminders, confirmations, and registration emails&lt;br /&gt;
*&#039;&#039;&#039;Send email invitation&#039;&#039;&#039;: Sends bulk email invitations to all participants in the tokens table who have not already been sent an invitation.&lt;br /&gt;
*&#039;&#039;&#039;Send email reminder&#039;&#039;&#039;: Sends bulk email reminders to all participants in the tokens table who have not yet responded, but have been sent their first invitation.&lt;br /&gt;
*&#039;&#039;&#039;Generate tokens&#039;&#039;&#039;: Creates unique tokens for all individual entries in the tokens table that do not yet have one&lt;br /&gt;
*&#039;&#039;&#039;Drop token table&#039;&#039;&#039;: delete the token table and set the survey to Open-access mode.&lt;br /&gt;
*&#039;&#039;&#039;Bounce settings&#039;&#039;&#039;:  Email bounce back settings.   Bounce back settings can be set at the survey level or at the system level.    This feature was added in version 1.91&lt;br /&gt;
&lt;br /&gt;
=Editing/adding a token=&lt;br /&gt;
&lt;br /&gt;
A typical token entry contains the following fields:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[File:token_editing2.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
*&#039;&#039;&#039;First and last name&#039;&#039;&#039;: .. of the participant (can be used in the emails &amp;amp; survey)&lt;br /&gt;
*&#039;&#039;&#039;Email&#039;&#039;&#039;: the participant&#039;s email address&lt;br /&gt;
*&#039;&#039;&#039;Email status&#039;&#039;&#039;: a field to keep track of bad emails. For instance, if the survey administrator received email error notifications from this email, the he can set this field to anything other than &#039;OK&#039; (for instance &#039;user unknown&#039;, or &#039;mailbox quota exceeded&#039;). Marking this token with an email status other than &#039;OK&#039;, will help skip this entry when sending invitation or reminder emails. Note that this is completely manual, unless you decide to implement a script which does update this field automatically.&lt;br /&gt;
*&#039;&#039;&#039;Token&#039;&#039;&#039;: this is the invitation code. It is usually automatically generated by the &#039;Generate tokens&#039; button&lt;br /&gt;
*&#039;&#039;&#039;Language&#039;&#039;&#039;: if you want to set the default language for this participant&lt;br /&gt;
*&#039;&#039;&#039;Invite sent&#039;&#039;&#039;: defaults to &#039;N&#039;, otherwise would contain the date when the invitation email was sent&lt;br /&gt;
*&#039;&#039;&#039;Reminder sent&#039;&#039;&#039;: defaults to &#039;N&#039;, otherwise would contain the date when the reminder email was sent&lt;br /&gt;
*&#039;&#039;&#039;Completed&#039;&#039;&#039;: defaults to &#039;N&#039;, otherwise would contain the date when the survey was submitted for not anonymous survey, or &#039;Y&#039; for anonymous survey&lt;br /&gt;
*&#039;&#039;&#039;Uses left&#039;&#039;&#039;: A counter of number of times the token can be used. &#039;&#039;Note:&#039;&#039; When increasing this value (default = 1) for a user who has already filled out the survey (which sets uses left to 0), you have to add &amp;quot;N&amp;quot; at the &amp;quot;completed&amp;quot; field.&lt;br /&gt;
*&#039;&#039;&#039;Valid from&#039;&#039;&#039; &amp;amp; &#039;&#039;&#039;Valid until&#039;&#039;&#039; : You can set a date/time range where this token would be allowed to use. You can leave these empty if you don&#039;t want to limit participation time frame for certain users. Note: If the user is answering the survey and the participation time ends then the user is locked out immediately and won&#039;t be able to finish the survey.&lt;br /&gt;
*&#039;&#039;&#039;Attribute1 to Attribute x&#039;&#039;&#039;: These are user-definable attribute fields - see the next paragraph.&lt;br /&gt;
&lt;br /&gt;
=Dummy Tokens=&lt;br /&gt;
&lt;br /&gt;
Dummy Tokens were added in 1.91. Here is a typical screen:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[File:dummyToken.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
*&#039;&#039;&#039;Number of tokens&#039;&#039;&#039;:  Number of tokens to be added.  Default is 100.&lt;br /&gt;
*&#039;&#039;&#039;Token length&#039;&#039;&#039;: Number of characters or length of token.  Default 15&lt;br /&gt;
*&#039;&#039;&#039;First and last name&#039;&#039;&#039;: .. of the participant.&lt;br /&gt;
*&#039;&#039;&#039;Email&#039;&#039;&#039;: the participant&#039;s email address&lt;br /&gt;
*&#039;&#039;&#039;Language&#039;&#039;&#039;: If you want to set the default language for this participant&lt;br /&gt;
*&#039;&#039;&#039;Uses left&#039;&#039;&#039;: A counter of number of times the token can be used.&lt;br /&gt;
*&#039;&#039;&#039;Valid from&#039;&#039;&#039; &amp;amp; &#039;&#039;&#039;Valid until&#039;&#039;&#039; : You can set a date/time range where this token would be allowed to use. You can leave these empty if you don&#039;t want to limit participation time frame for certain users. Note: If the user is answering the survey and the participation time ends then the user is locked out immediately and won&#039;t be able to finish the survey.&lt;br /&gt;
*&#039;&#039;&#039;Attribute1 to Attribute x&#039;&#039;&#039;: These are user-definable attribute fields - see the next paragraph.&lt;br /&gt;
&lt;br /&gt;
Note that Name, email, language will be set to the same value for all dummy Tokens&lt;br /&gt;
&lt;br /&gt;
=Bounce Settings=&lt;br /&gt;
&lt;br /&gt;
Email bounce back processing was added in 1.91.&lt;br /&gt;
&lt;br /&gt;
[[File:surveyBounseSettings.png]]&lt;br /&gt;
*&#039;&#039;&#039;Survey bounce email&#039;&#039;&#039;:  A valid email address for return mail.   For faster bounce back processing, this email box should be limited to bounce back only.&lt;br /&gt;
*&#039;&#039;&#039;Bounce settings to be used&#039;&#039;&#039;: There are three options:  1) None (default) - no bounce back processing, 2) Use settings below - Will set bounce back processing at the survey level, or 3) Use global settings -- Settings based on the system level.&lt;br /&gt;
*&#039;&#039;&#039;Server type&#039;&#039;&#039;: Three options: 1) Off, 2) IMAP or 3) POP&lt;br /&gt;
*&#039;&#039;&#039;Server name &amp;amp; port&#039;&#039;&#039;:  Host name and port number.   Port number isn&#039;t typically needed unless the email host uses a non-standard port. Example:  mail.example.net:25 or imap.gmail.com:995&lt;br /&gt;
*&#039;&#039;&#039;User name&#039;&#039;&#039;:  User Name or User ID of the email account&lt;br /&gt;
*&#039;&#039;&#039;Password&#039;&#039;&#039;:  password of the email account&lt;br /&gt;
*&#039;&#039;&#039;Encryption type&#039;&#039;&#039;:  Three options:  1) None (default), 2) SSL, or 3) TLS&lt;br /&gt;
&lt;br /&gt;
=User-defined attribute fields=&lt;br /&gt;
&lt;br /&gt;
It is possible to add a number of additional fields to the tokens table to save additional data for a participant. By clicking on the [[File:token_manage.png]] icon you can manage these fields. You can add more attribute fields (by default they have a a length of 255 chars) and also set descriptions for each field - so they look nicer in the administration, when you browse tokens, when creating [[Setting conditions|conditions]] based on attribute fields or even when you export results for non-anonymous surveys.&lt;br /&gt;
&lt;br /&gt;
=Using the browse screen and editing tokens=&lt;br /&gt;
&lt;br /&gt;
[[File:token-browse.png]]&lt;br /&gt;
&lt;br /&gt;
The browse screen will show you a list of all entries in the tokens table, as well as giving you some &#039;action&#039; buttons that can perform specific tasks for that individual entry.&lt;br /&gt;
&lt;br /&gt;
The top row of the table has three columns: The dialogue on the right gives options for displaying a number of records, and a starting point. In the middle is a search bar and the symbols on the left let you move backwards or forwards through your list.&lt;br /&gt;
&lt;br /&gt;
The second row of the table (see image below) includes various criteria to sort the entries and for each a green arrow that - if clicked - will refresh the screen showing the tokens ordered by that criterion.&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Actions&amp;quot; column gives a list of specific tasks that can be performed on that individual entry:&lt;br /&gt;
&lt;br /&gt;
[[File:token-actions.png]]&lt;br /&gt;
*Do the survey using the unique token of this entry&lt;br /&gt;
*Edit this entry&lt;br /&gt;
*Delete this entry&lt;br /&gt;
*Send a invitation/reminder to this individual entry&lt;br /&gt;
*If the survey is a &#039;tracked&#039; (ie: not anonymous) survey, another button will appear, allowing you to view the response from this individual entry.&lt;br /&gt;
&lt;br /&gt;
=Database Admin=&lt;br /&gt;
&lt;br /&gt;
[[File:token-summary.png]][[File:token-db-mgt.png]]&lt;br /&gt;
&lt;br /&gt;
While the summary screen shows a brief summary of tokens in the table, it also provides access to the &amp;quot;Database Admin&amp;quot; features which include:&lt;br /&gt;
*Clear invites: Sets all records that an invitation has been sent out to &#039;N&#039;. Obviously shouldn&#039;t normally be used.&lt;br /&gt;
*Clear tokens: Clears all tokens. Similarly shouldn&#039;t normally be used.&lt;br /&gt;
*Drop tokens: Allows you to remove the tokens feature from your script. Deletes the entire table and all records, and allows the survey to be accessed by anybody who knows the URL.&lt;br /&gt;
&lt;br /&gt;
= Importing/exporting tokens=&lt;br /&gt;
&lt;br /&gt;
== CSV import==&lt;br /&gt;
&lt;br /&gt;
When you click the icon to import tokens you will be presented with the following screen:&lt;br /&gt;
&lt;br /&gt;
[[File:uploadtoken.jpg]]&lt;br /&gt;
&lt;br /&gt;
Your CSV file must be a standard [http://en.wikipedia.org/wiki/Comma-separated_values CSV (Comma Separated Value) file]. The first line of text is always the header information and will be used to identify the field data. Possible data fields are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;firstname,lastname,email,emailstatus,token,language code,tid,attribute_1,attribute_2, attribute_...&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To obtain a full list of token field names, export an existing token table.&lt;br /&gt;
&lt;br /&gt;
The fields can be in any order but &#039;&#039;firstname, lastname and email are mandatory&#039;&#039;, and they must contain at least one character. Empty data (such as &amp;quot;&amp;quot;) is not sufficient. If you would like to import data for attribute fields, you must add the desired attribute fields to the token table prior to importing token data.&lt;br /&gt;
&lt;br /&gt;
A bare minimum CSV file could look like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;firstname,lastname,email&lt;br /&gt;
&lt;br /&gt;
John,Doe,john@doe.net&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Date format for token import&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The date format for the &amp;quot;validfrom&amp;quot; and &amp;quot;validuntil&amp;quot; fields in the CSV token inport file is &amp;quot;YYYY-MM-DD HH:MM&amp;quot;, e.g.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;2012-01-01 00:00&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
--would correspond to 1st January, 2012, at 12:00 AM.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Filtering duplicates&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you activate the option to filter for duplicates you can set which fields are used to identify duplicates. By default First name, Last name &amp;amp; Email-address are pre-selected. If a duplicate is found while importing the related line is omitted.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Troubleshooting the token import&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
A common error when users try to import tokens is an invalid CSV file. This is often caused by Microsoft Excel. Many users have a list of e-mail addresses saved as an XLS document. A file can be saved as CSV in Excel, however, Microsoft uses semi-colon (;) as the comma separator, while a standard CSV file uses comma (,) as the separator. If you try to import an Excel saved CSV file you will get an error message. A simple solution is to save your XLS document as a CSV file in Excel and then open the file in a raw text editor and replace all semi-colon characters with commas.&lt;br /&gt;
&lt;br /&gt;
Recommended free raw text editors are: [http://www.pspad.com/ PSPad], [http://www.flos-freeware.ch/notepad2.html NotePad2] or [http://notepad-plus-plus.org/ Notepad++] for Windows, and [http://www.barebones.com/products/textwrangler/ TextWrangler] for Macintosh.&lt;br /&gt;
&lt;br /&gt;
You can use [http://www.libreoffice.org/features/calc/ LibreOffice Calc] to export import your xls file and export your csv file.&lt;br /&gt;
&lt;br /&gt;
== CSV export==&lt;br /&gt;
&lt;br /&gt;
When you export your tokens the following fieldorder is exported:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;tid,firstname,lastname,email,emailstatus,token,language code,attribute_1,attribute_2,etc..&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== LDAP import==&lt;br /&gt;
&lt;br /&gt;
[[File:token-Ldap-import.png]]&lt;br /&gt;
* Queries are manually defined by the system administrator in the config-ldap.php file&lt;br /&gt;
* Duplicates are identified by First Name, Last Name &amp;amp; Email-Address. If a duplicate is found while importing the related line is omitted, unless you have unchecked the Filter Duplicates checkbox.&lt;br /&gt;
&lt;br /&gt;
== A tip for generating a large number of fake e-mail addresses==&lt;br /&gt;
&lt;br /&gt;
Sometimes you may need a large number of fake e-mail addresses and tokens. You can use functions in a spreadsheet (e.g. OpenOffice Calc) to generate them. Let&#039;s assume you want thousands addresses in a form: 1@test.com, 2@test.com, 3@test.com... Put consecutive numbers in column A: 1 in the A1, then insert function =A1+1 in A2, then copy A2 down as many times as you need. In B1 use concatenation function to join A1 and &amp;quot;@test.com&amp;quot;, which is =CONCATENATE(A1;&amp;quot;@test.com&amp;quot;). Then copy B1 down for each copied A. You may generate fake names in a similar way. Finally, save the file as CSV for import in LS.&lt;br /&gt;
&lt;br /&gt;
With the 1.91, you can use &amp;quot;Generate dummy token&amp;quot; functionnality&lt;br /&gt;
&lt;br /&gt;
== A tip for generating a large number of individual links which include the token already==&lt;br /&gt;
&lt;br /&gt;
The structure of the survey link is the following:&lt;br /&gt;
&lt;br /&gt;
http://url-to-your-limesurvey-installation/index.php?sid=XXXX&amp;amp;lang;=en&amp;amp;token;={TOKEN}&lt;br /&gt;
&lt;br /&gt;
So you proceed similar to the example above for generating email adresses.&lt;br /&gt;
*First column: http://url-to-your-limesurvey-installation/index.php?sid=XXXX&amp;amp;lang;=en&amp;amp;token;= (the same for all, as long as the language is the same!)&lt;br /&gt;
*Second column: {TOKEN} (put your tokens here, of course they must be individual)&lt;br /&gt;
*Third column: use the CONCATENATE funtion to joint the first column with the second column.&lt;br /&gt;
&lt;br /&gt;
= Emailing=&lt;br /&gt;
&lt;br /&gt;
== Email placeholders==&lt;br /&gt;
&lt;br /&gt;
The following field names are allowed in invitation/reminder email templates and must be entered in the survey properties. When sending out the emails these field names will be already replaced in the preview of your invitation/reminder email.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|{ADMINEMAIL}||Email of the Survey admin&lt;br /&gt;
|-&lt;br /&gt;
|{ADMINNAME}||Name of Survey Admin&lt;br /&gt;
|-&lt;br /&gt;
|{SURVEYNAME}||Title of your survey&lt;br /&gt;
|-&lt;br /&gt;
|{SURVEYDESCRIPTION}||Description of your survey&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The following field names are allowed in invitation/reminder emails (subject and/or body) and will be replaced while sending out the mails:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|{EMAIL}||Email of the recipient&lt;br /&gt;
|-&lt;br /&gt;
|{FIRSTNAME}||First Name&lt;br /&gt;
|-&lt;br /&gt;
|{LASTNAME}||Last Name&lt;br /&gt;
|-&lt;br /&gt;
|{SURVEYURL}||The URL pointing to the survey start - if you are sending HTML emails this will be a fully linked HTML version&lt;br /&gt;
|-&lt;br /&gt;
|@@SURVEYURL@@||The URL pointing to the survey start - this is the barebone link. Use this if you want to integrate the link in your custom HTML elements somewhere (available in v1.90 and later)&lt;br /&gt;
|-&lt;br /&gt;
|{OPTOUTURL}||The URL to deactivate sending of mail for this survey  - this will be a fully linked HTML version&lt;br /&gt;
|-&lt;br /&gt;
|{TOKEN}||Token to access the survey&lt;br /&gt;
|-&lt;br /&gt;
|{ATTRIBUTE_1}||Attribute 1&lt;br /&gt;
|-&lt;br /&gt;
|{ATTRIBUTE_2}||Attribute 2 (...and so on for more attribute fields)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If your survey is NOT anonymous, the following field names are available to insert token data in survey text and javascript:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|{TOKEN:EMAIL}||Email of the recipient&lt;br /&gt;
|-&lt;br /&gt;
|{TOKEN:FIRSTNAME}||First Name&lt;br /&gt;
|-&lt;br /&gt;
|{TOKEN:LASTNAME}||Last Name&lt;br /&gt;
|-&lt;br /&gt;
|{TOKEN}||Token to access the survey&lt;br /&gt;
|-&lt;br /&gt;
|{TOKEN:ATTRIBUTE_1}||Attribute 1&lt;br /&gt;
|-&lt;br /&gt;
|{TOKEN:ATTRIBUTE_2}||Attribute 2 (and so on for more attribute fields)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
See examples on using [http://docs.limesurvey.org/tiki-index.php?page=Adding+A+Question+#Information_from_tokens_table information from tokens table].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;simplebox&amp;quot;&amp;gt;Starting in Version 1.92, you can use [[Expression Manager|Expression Manager]] to use expressions for tailoring an email. Please have a look at the [[Expression Manager HowTos|Expression Manager HowTos]] for an example.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Emails settings==&lt;br /&gt;
#&#039;&#039;&#039;Invitation Email Subject&#039;&#039;&#039;: The subject line for the invitation email that gets sent out when tokens are used with your survey.&lt;br /&gt;
#&#039;&#039;&#039;Invitation Email&#039;&#039;&#039;: This is the text for the invitation email that gets sent out when tokens are used with your survey. This is initially filled by the default invitation message (from the language files) but you can modify it to suit yourself. If you are using English as your base language, the default invitation and reminder text can be found in the limesurvey/tokens.php file. Of course if you don&#039;t plan to use tokens on your survey, whatever is in this field is irrelevant.  You can use the following &amp;quot;form&amp;quot; fields to insert individualized information in each email:&lt;br /&gt;
**&#039;&#039;&#039;{FIRSTNAME}&#039;&#039;&#039; - gets replaced with the token table&#039;s &amp;quot;firstname&amp;quot; value&lt;br /&gt;
**&#039;&#039;&#039;{LASTNAME}&#039;&#039;&#039; - gets replaced with the token table&#039;s &amp;quot;lastname&amp;quot; value&lt;br /&gt;
**&#039;&#039;&#039;{SURVEYNAME}&#039;&#039;&#039; - gets replaced with your surveys name&lt;br /&gt;
**&#039;&#039;&#039;{SURVEYDESCRIPTION}&#039;&#039;&#039; - gets replaced with your surveys description&lt;br /&gt;
**&#039;&#039;&#039;{ATTRIBUTE_1}&#039;&#039;&#039; - gets replaced with the token table&#039;s &amp;quot;attribute_1&amp;quot; value&lt;br /&gt;
**&#039;&#039;&#039;{ATTRIBUTE_2}&#039;&#039;&#039; - gets replaced with the token table&#039;s &amp;quot;attribute_2&amp;quot; value and so on&lt;br /&gt;
**&#039;&#039;&#039;{SURVEYURL}&#039;&#039;&#039; - gets replaced with the fully qualified URL to this particular survey - in HTML emails this is a fully linked HTML link&lt;br /&gt;
**&#039;&#039;&#039;@@SURVEYURL@@&#039;&#039;&#039; - Gets replaced with the survey barebone link. Use this if you want to integrate the link in your custom email HTML (available in v1.90 and later)&lt;br /&gt;
**&#039;&#039;&#039;{OPTOUTURL}&#039;&#039;&#039; - gets replaced with the URL for a respondent to opt-out of this particular survey&lt;br /&gt;
&lt;br /&gt;
Note that these &amp;quot;form fields&amp;quot; apply to the following email fields.&lt;br /&gt;
#&#039;&#039;&#039;Email Reminder Subject&#039;&#039;&#039;: The subject line for the reminder email that gets sent out from the tokens tool&lt;br /&gt;
#&#039;&#039;&#039;Email Reminder&#039;&#039;&#039;: This is the text for the reminder email that gets sent out when tokens are used with your survey. See &amp;quot;invitation email&amp;quot; for specific details on how this field is used.&lt;br /&gt;
#&#039;&#039;&#039;Confirmation Email Subject&#039;&#039;&#039;: When tokens are used, this is the subject line of the email that gets automatically sent to participants after completion of the survey&lt;br /&gt;
#&#039;&#039;&#039;Confirmation Email&#039;&#039;&#039;: This is the text of the email that gets sent to users after completion of the survey. Delete/blank this text remove the confirmation email sending.&lt;br /&gt;
#&#039;&#039;&#039;Public Registration Email Subject&#039;&#039;&#039;: This is the subject line for the invitation email sent to members of the public who register for a survey.&lt;br /&gt;
#&#039;&#039;&#039;Public Registration Email&#039;&#039;&#039;: This is the text for the invitation email sent to members of the public who register for a survey. The same &amp;quot;form fields&amp;quot; apply in this email as in the earlier ones.&lt;br /&gt;
&lt;br /&gt;
==Sending emails==&lt;br /&gt;
&lt;br /&gt;
=== Send invitations===&lt;br /&gt;
&lt;br /&gt;
[[File:token-invite.png]]&lt;br /&gt;
&lt;br /&gt;
You can skip tokens for which the email status field is different from &#039;OK&#039;, by choosing the &#039;Bypass token with failing email addresses&#039; option.&lt;br /&gt;
&lt;br /&gt;
==== Resending invitations====&lt;br /&gt;
&lt;br /&gt;
Sometimes you might want to send invitations again to certain token entries / persons. When you use the &#039;&#039;&#039;send invitations&#039;&#039;&#039;-function only e-mail addresses that &#039;&#039;has not previously received an invitation&#039;&#039; will get one. This means that if you add new addresses to the token list after the first time you sent invitations, only these new addresses will receive an invitation the second time you send invitations.&lt;br /&gt;
&lt;br /&gt;
This means that you can also edit/change an e-mail in a particular token entry that you got a bounce from and then send to only this edited address. Just substitute the date &#039;&#039;&#039;Invite sent?&#039;&#039;&#039; for a capital &#039;&#039;&#039;N&#039;&#039;&#039; (no) and click &#039;&#039;&#039;send invitations&#039;&#039;&#039; again.&lt;br /&gt;
&lt;br /&gt;
==== Participant opt-out====&lt;br /&gt;
&lt;br /&gt;
When you use the {OPTOUTURL} tag in your invitation/reminder email, your participants have the possibility to opt out of this particular survey by just clicking on the related URL in the email - so you don&#039;t harrass them with reminder emails. A participant that opted out of your survey will have the email status &#039;OptOut&#039; set in the token.&lt;br /&gt;
&lt;br /&gt;
=== Send reminders===&lt;br /&gt;
&lt;br /&gt;
[[File:token-remind.png]]&lt;br /&gt;
&lt;br /&gt;
When sending reminders you can:&lt;br /&gt;
* bypass tokens with failing email addresses&lt;br /&gt;
* skip tokens for which an email has been &#039;recently&#039; sent&lt;br /&gt;
* skip tokens for which a given number of emails have already been sent&lt;br /&gt;
&lt;br /&gt;
Note: A reminder will only be send to tokens where the &amp;quot;completed&amp;quot; field is not &amp;quot;N&amp;quot; (this means the respondent has either not taken or has not completed the survey).&lt;br /&gt;
&lt;br /&gt;
=== Sending emails by batch===&lt;br /&gt;
&lt;br /&gt;
When you have to send a lot of emails at the same time, LimeSurvey will only send a first batch of N emails (this threshold is set by the administrator in the Global Settings).&lt;br /&gt;
&lt;br /&gt;
You&#039;ll then need to click &amp;quot;Next&amp;quot; to send the next batch, and so on untill all emails have been sent.&lt;br /&gt;
&lt;br /&gt;
=== Confirmation email===&lt;br /&gt;
&lt;br /&gt;
If you are using tokens and a participant fills out the survey, a confirmation email is sent to his/her email address.&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t want this message to be sent, remove all content from the &amp;quot;Confirmation email subject&amp;quot; and &amp;quot;Confirmation email&amp;quot; fields -  [http://docs.limesurvey.org/tiki-index.php?page=General+FAQ#How_can_I_stop_the_system_from_sending_confirmation_emails see these instructions].&lt;br /&gt;
&lt;br /&gt;
=== Spam problems===&lt;br /&gt;
&lt;br /&gt;
Often users complain not having received an invitation/reminder email because the user&amp;amp;rsquo;s spam filter treated the email as spam.&lt;br /&gt;
&lt;br /&gt;
If an email is treated as spam mostly depends on the spam filter being used and its settings. A spam filter usually checks the sender address and the email subject and content, so there are ways and means to influence how they treat your Limesurvey invitation and reminder emails.&lt;br /&gt;
&lt;br /&gt;
At [http://www.limesurvey-consulting.com/how-to-prevent-limesurvey-email-invitations-or-reminders-being-treated-as-spam/ this blog post] on limesurvey-consulting.com a lot of possible issues and solutions are listed.&lt;br /&gt;
&lt;br /&gt;
= Public registration=&lt;br /&gt;
&lt;br /&gt;
==Allowing public registration==&lt;br /&gt;
&lt;br /&gt;
You may want to open your survey to the public, but utilize the sort of respondent control available when using tokens. This is possible: If you initialize your tokens table, and have chosen to Allow Public Registration in the main survey setup, people who visit your survey&#039;s URL without a token, will be given the opportunity to register. If they provide an email address that is not already in the current survey&#039;s tokens table, an entry in the tokens table will be created, and they will be emailed an invitation containing their unique Token. All tokens provided to &amp;quot;registering&amp;quot; visitors will begin with the letter &amp;quot;R&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Captchas in public registration==&lt;br /&gt;
&lt;br /&gt;
To protect your survey from robot registration there is a captcha feature on all Registration, Save and Load forms. (starting from version 1.48) This feature is only available if you have GD-support activated in your PHP configuration. (see [[Installation|Installation Requirements]])&lt;/div&gt;</summary>
		<author><name>Holch</name></author>
	</entry>
</feed>