-
waitz
-
-
OFFLINE
-
Silver Donor
-
- Beiträge: 166
- Dank erhalten: 1
-
Karma: 3
-
|
I have seen it somewhere in the forum, but I cannot find it....
I had a script I could use in a sub-text field in a multiple short text question, that suggests answers based on what I start typing in the text field... The answers came from a list in the script of course.
I cannot find this back in the forum. Do you have an idea of a script like this?
|
Version 1.91+ Build 11232 | PHP 5.3.9 | MySQL 5.1.56 |
|
-
tpartner
-
-
ONLINE
-
LimeSurvey Team
-
- Beiträge: 2941
- Dank erhalten: 448
-
Karma: 254
-
|
|
|
|
-
Mazi
-
-
OFFLINE
-
LimeSurvey Team
-
- Beiträge: 5118
- Dank erhalten: 264
-
Karma: 241
-
|
Rajan, once you have added all these nice workarounds, can you create a copy of that survey so we can have a look at a life version?
|
Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
|
-
waitz
-
-
OFFLINE
-
Silver Donor
-
- Beiträge: 166
- Dank erhalten: 1
-
Karma: 3
-
|
Sure  It is becoming quite advanced, nice for the user, and not so difficult to administer.
|
Version 1.91+ Build 11232 | PHP 5.3.9 | MySQL 5.1.56 |
|
-
waitz
-
-
OFFLINE
-
Silver Donor
-
- Beiträge: 166
- Dank erhalten: 1
-
Karma: 3
-
|
tpartner schrieb:
Hmmm... The text field I want to use this for is one of 5 subquestions in multiple short text. <script type="text/javascript" charset="utf-8">
$(document).ready(function() {
var q1ID = #answer68164X61X1025FAM06;
var states = "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".split(',');
$('#question'+q1ID+' input.text').autocomplete({
source: states
});
});
</script>I tried to put it in the code of the main question and in the code of the subquestion. Where does it actually go, and why won't it work...
|
Version 1.91+ Build 11232 | PHP 5.3.9 | MySQL 5.1.56 |
|
-
tpartner
-
-
ONLINE
-
LimeSurvey Team
-
- Beiträge: 2941
- Dank erhalten: 448
-
Karma: 254
-
|
You can place the script in the source of any question or subquestion. It just need to be present in the page.
To target a specific sub-question field, use something like this: <script type="text/javascript" charset="utf-8">
$(document).ready(function() {
var states = "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".split(',');
$('#answer68164X61X1025FAM06').autocomplete({
source: states
});
});
</script>
|
|
|
-
tpartner
-
-
ONLINE
-
LimeSurvey Team
-
- Beiträge: 2941
- Dank erhalten: 448
-
Karma: 254
-
|
Sure It is becoming quite advanced, nice for the user, and not so difficult to administer.
Soon the survey will complete itself
|
|
|
-
waitz
-
-
OFFLINE
-
Silver Donor
-
- Beiträge: 166
- Dank erhalten: 1
-
Karma: 3
-
|
tpartner schrieb:
Soon the survey will complete itself  Interesting thought
|
Version 1.91+ Build 11232 | PHP 5.3.9 | MySQL 5.1.56 |
|
-
waitz
-
-
OFFLINE
-
Silver Donor
-
- Beiträge: 166
- Dank erhalten: 1
-
Karma: 3
-
|
The script is working, but it is not mandatory that I choose one of the suggested words.
Is it possible to make this mandatory?
|
Version 1.91+ Build 11232 | PHP 5.3.9 | MySQL 5.1.56 |
Letzte Änderung: 1 Jahr 7 Monate her von waitz.
|
-
tpartner
-
-
ONLINE
-
LimeSurvey Team
-
- Beiträge: 2941
- Dank erhalten: 448
-
Karma: 254
-
|
This code will apply the autocomplete plugin to an input and if a value is entered that is not in the data array an alert will be shown and the input will be set to null.
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
var states = "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".split(',');
var msg = 'You must select a value from the list.';
mandatoryAutocomplete('#answer68164X61X1025FAM06', states);
function mandatoryAutocomplete(inputID, data) {
$(inputID).autocomplete({
source: data
});
$(inputID).change(function(){
//$('#answer68164X61X1025FAM06').change(function(){
var okay = 0;
$(states).each(function(){
if($(inputID).val() == this) {
okay = 1;
}
});
if(okay < 1) {
alert (msg);
$(inputID).val('');
}
});
}
});
</script>
|
|
|
|