Welcome to the LimeSurvey Community Forum

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

defual value in array

  • mana
  • mana's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 9 months ago #139130 by mana
defual value in array was created by mana
hi forum
how can i change this code for LimeSurvey Version 2.06+ Build 160129
Default_values_in_array_questions
Code:
<script type="text/javascript" charset="utf-8">
 
  $(document).ready(function() {
 
    var qID = QQ;
 
    $('#question'+qID+' table.question tbody').each(function(i){
      if(i < 3) {
        if($('input.radio:checked', this).length == 0) {
          $('input.radio:last', this).attr('checked', true); 
        }  
      }
    });      
  });
 
</script>
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 9 months ago #139132 by DenisChenu
Replied by DenisChenu on topic defual value in array
Maybe:

('#question'+qID+' table.question tbody tr').each(function(i){

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The following user(s) said Thank You: mana
The topic has been locked.
  • mana
  • mana's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 9 months ago #139135 by mana
Replied by mana on topic defual value in array
Dear denis
thank you
it's work :)
The topic has been locked.
  • mana
  • mana's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 9 months ago #139139 by mana
Replied by mana on topic defual value in array
next problem

how can i select second column ?
this code for first column .
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 9 months ago #139141 by DenisChenu
Replied by DenisChenu on topic defual value in array
$('input.radio:nth-child(2)', this).click(); ?

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
  • mana
  • mana's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 9 months ago #139143 by mana
Replied by mana on topic defual value in array
Is it true ?
don't work :(
Code:
<script type="text/javascript" charset="utf-8">
   $(document).ready(function()
 {
   $('#question'+97718+' table.question tbody tr').each(function(i){
      if(i <15 ) {
    if($('input.radio:checked', this).length == 0) {
        $('input.radio:nth-child(2)', this).click(); 
      }  
      }
    });      
  });
 
</script>
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 9 months ago #139153 by DenisChenu
Replied by DenisChenu on topic defual value in array
A test link ?
Or a survey with only one question and this javascript

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 9 months ago #139160 by tpartner
Replied by tpartner on topic defual value in array
I'm not sure nth-child will work here because the scope of "this" is the table row so the direct children are table cells, not inputs.

Try:

Code:
<script type="text/javascript" charset="utf-8">  
   $(document).ready(function() {
    $('#question{QID} tr.answers-list').each(function(i){
      if(i < 15 ) {
        if($('input.radio:checked', this).length == 0) {
          console.log($('input.radio:checked', this).length);
          $('input.radio:eq(1)', this).click(); 
        }  
      }
    });      
  });
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: DenisChenu
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 9 months ago #139167 by DenisChenu
Replied by DenisChenu on topic defual value in array
Oups, you surely right Tony , thanks :)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose