Another more portable way of handling this may be to use text inputs with the
jQuery autocomplete workaround. The data source for autocomplete (list of states or cities) could be defined depending on the previous answers.
Having said that, here is my suggestion for your particular case. I wouldn't use the workaround you are trying - I think it's overkill for what you need.
Add this script to the source of the "State" question. You will need to use the correct <a href='
www.docs.limesurvey.org/tiki-index.php?p...tions+for+LimeSurvey'>SGQA</a> values for your survey. I think the comments explain it well enough:
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
// Get the countryCode (first character of the country)
var countryCode = '{INSERTANS:47126X993X12555}'.substr(0, 1).toUpperCase();
// Loop through all dropdown options and remove those with codes not starting with the countryCode
$('select[id^="answer"] option').each(function(i){
if($(this).attr('value') && $(this).attr('value').substr(0, 1).toUpperCase() != countryCode) {
$(this).remove();
}
});
});
</script>
Add this to the source of the "City" question. You will need to use the correct <a href='
www.docs.limesurvey.org/tiki-index.php?p...tions+for+LimeSurvey'>SGQA</a> values for your survey:
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
// Get the countryCode (first character of the country)
var countryCode = '{INSERTANS:47126X993X12555}'.substr(0, 1).toUpperCase();
// Get the stateCode (first 2 characters of the state)
var stateCode = '{INSERTANS:47126X993X12556}'.substr(0, 2).toUpperCase();
// Concatenate the two codes
var fullCode = countryCode + stateCode;
// Loop through all dropdown options and remove those with codes not starting with the fullCode
$('select[id^="answer"] option').each(function(i){
if($(this).attr('value') && $(this).attr('value').substr(0, 3).toUpperCase() != fullCode) {
$(this).remove();
}
});
});
</script>
Here is a working sample survey:
La pièce jointe limesurvey_survey_47126_TONY.lss est absente ou indisponible