Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Mancata associazione Provincia/Comune

More
4 years 1 month ago #194525 by diegoboschi
Ciao,
mi permetto di scriverti se potessi aiutarmi... lo script di seguito non va.. lo ha rivisto tu...
la funzione di sicurezza da te consigliata  Filtro HTML per XSS: è disattivata, l'id della mia domanda è 2248 e modificato come hai indicato... ma scelta la provincia carica tutti i comuni... 
Versione Limesurvey Versione 2.72.3+171020
PUOI PER PIACERE AIUTARMI?GRAZIE
<span style="font-size:20px;"><small>Attualmente in quale provincia e comune vive?</small></span><br />
<script type="text/javascript" charset="utf-8">

  $(document).ready(function() {

$('.array-flexible-duel-scale .dropdown-item select').each(function(i) {
if($('option[selected="selected"]', this).length == 0) {
$(this).prepend('<option value="">Please choose...</option>');
$(this).val('');
}
});

selectFilterDualScale({2248});
});


/*
Copyright 2012 Denis Chenu for < www.sondages.pro >
Distributed under MIT licence

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Luciano Fanfoni - lfanfoni@gmail.com
Modifiche per compatibilità versioni 2.7X

*/

/* Function to filter the second part of an Array dual scale (with dropdown attribute) by the first part
var qID : the number of question to filter
*/
function selectFilterDualScale(qID){
$(document).ready(function(){
if($("#question"+qID).hasClass('array-flexible-duel-scale')){
//modifiche Steve
$(this).find("col.ddarrayseparator").attr('width',"2%");
$(this).find("th.th-14").attr('width','50%');
$(this).find("th.th-15").attr('width','50%');

// Fix width of columns - vecchio di Denis
/*answertextwidth=$(this).find("col.answertext").attr('width').replace("%","");
$(this).find("col.ddarrayseparator").attr('width',"2%");
ddarrayseparatorwidth=$(this).find("col.ddarrayseparator").attr('width').replace("%","");
var newwidth=(100-answertextwidth*1-ddarrayseparatorwidth*1)/2;
$(this).find("col.dsheader").attr('width',newwidth+'%');*/

//RIPRENDE IL VECCHIO
/*modifica oreslaS per la versione Versione 3.3.1+180214
$("#question"+qID+" table.questions-list tbody tr").each(function(index){
prima era $("#question"+qID+" table.question tbody tr").each(function(index){*/
$("#question"+qID+" table.questions-list tbody tr").each(function(index){
$(this).find("select").each(function(){
//$(this).attr('id',$(this).attr('id').replace('#',"_"));
});
var idSelectFiltering = jqSelector($(this).find("select").eq(0).attr('id'));
var idSelectFilter = jqSelector($(this).find("select").eq(1).attr('id'));
var idNewSelectFilter = jqSelector('select'+qID+'_'+index);

//NUOVO DI STEVE
var NewSelectElement = "<select id='"+idNewSelectFilter+"' class='form-control'><option value=''>"+$("#"+idSelectFilter+" option[value='']:first").text()+"</option></select>";

/* VECCHIO SCRIPT DI DENIS
var NewSelectElement = "<select id='"+idNewSelectFilter+"'><option value=''>"+$("#"+idSelectFilter+" option[value='']:first").text()+"</option></select>";*/
//RIPRENDE DENIS
$("#"+idSelectFilter).hide();
$("#"+idSelectFilter).after(NewSelectElement);

$("#"+idSelectFiltering).change(function(){
$("#"+idSelectFilter).val('');
$('#'+idNewSelectFilter).val('');
var valuefilter=$(this).val().substring(0, $(this).val().length - 3);
$('#'+idNewSelectFilter+' option').not(':first').remove();
if($(this).val()==""){
$('#'+idNewSelectFilter).hide();
}else{
$('#'+idNewSelectFilter).show();
$("#"+idSelectFilter).find('option').each(function(){
if($(this).attr('value').substring(0, $(this).attr('value').length - 3)==valuefilter){
$(this).clone().appendTo('#'+idNewSelectFilter);
}
});
}

});
$("#"+idNewSelectFilter).change(function(){
$('#'+idSelectFilter).val($(this).val());
saveval=$('#'+idSelectFiltering).val();
$('#'+idSelectFilter).trigger('change');
if($(this).val()==""){
$('#'+idSelectFiltering).val(saveval);
$('#'+idSelectFiltering).trigger('change');
$('#'+idSelectFilter).val($(this).val(""));
}
});

if($("#"+idSelectFiltering).val()!=''){
//if($("#"+idSelectFiltering+' option[selected="selected"]').length != 0){
var valuefilter=$("#"+idSelectFiltering).val().substring(0, $("#"+idSelectFiltering).val().length - 3);
$('#'+idSelectFilter+' option').each(function(){
if($(this).attr('value').substring(0, $(this).attr('value').length - 3)==valuefilter){
$(this).clone().appendTo('#'+idNewSelectFilter);
}
});

if($("#"+idSelectFilter).val()!=''){
$('#'+idNewSelectFilter).val($("#"+idSelectFilter).val());
}
}else{
$('#'+idNewSelectFilter).hide();
}
});
}
});
}
function jqSelector(str) {
return str.replace(/([;&,\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g, '\\$1');
}
</script>

--
Boschi Diegodiegoboschi@gmail.comskype boschi.diego
+39.391.37.98.604
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 1 month ago #194527 by Joffm
Buongiorno
ecco un esempio nella versione 2.73.






File Attachment:

File Name: limesurvey...3168.lss
File Size:22 KB



Non modificare questo codice
selectFilterDualScale({QID});

{QID} è un segnaposto di sistema; sarà sostituito automaticamente

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: diegoboschi
The topic has been locked.
More
4 years 1 month ago #194549 by diegoboschi
Numero 1!!! ti posso inviare la domanda in lsq in modo che potessi correggerla pulendo il codice? lasciando ovviamente i tag dei tuoi riferimenti :-)

Se mi lasci una mail perchè è 2,8 Mb

GRANDE!!!
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 1 month ago - 4 years 1 month ago #194550 by Joffm
È solo necessario copiare il javascript dal mio esempio (senza modifiche).

E nota i codici delle opzioni di risposta.


L'invio di una domanda di queste dimensioni non ha senso.
Sono sufficienti solo alcune opzioni di esempio.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 4 years 1 month ago by Joffm.
The following user(s) said Thank You: lfanfoni, diegoboschi
The topic has been locked.
More
4 years 1 month ago #194562 by diegoboschi
Ciao,
allora... ho copiato il codice (infatti importanto restituiva un errore per la lingua), ma...
La tua survey di esempio allegata importata funziona perfettamente.... mentre la mia domanda no.....

le province le ho inserite così



mentre così i comuni... mi sembrava di rispettare la tua logica... che dici? puoi aiutarmi? GRAZIE


The topic has been locked.
More
4 years 1 month ago #194568 by diegoboschi
risolto pertendo da una nuova survey funzionante e importando i vecchi gruppi di domande grazie a
Luciano Fanfoni
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 1 month ago #194571 by Joffm
Ecco un esempio in italiano.

E anche un altro suggerimento per questa domanda







File Attachment:

File Name: limesurvey...6362.lss
File Size:233 KB


Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: lfanfoni, diegoboschi
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose