- Posts: 31
- Thank you received: 1
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Array num with radio in last column
- MikeConom
- Topic Author
- Offline
- Junior Member
Less
More
10 years 4 months ago #102751
by MikeConom
Array num with radio in last column was created by MikeConom
Good evening
i have create an array with numbers and in the end a radio button
i am looking to find how can i do the following
1) When choosing radio button numeric fields to be 0
2) when I write in numeric fields the radio buttons to be not check
Thanks
i have create an array with numbers and in the end a radio button
i am looking to find how can i do the following
1) When choosing radio button numeric fields to be 0
2) when I write in numeric fields the radio buttons to be not check
Thanks
Attachments:
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10108
- Thank you received: 3593
10 years 4 months ago - 10 years 4 months ago #102754
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Array num with radio in last column
This should do the trick. Note that this code must be placed after your code that inserts the radios.
Here is the survey back with the amended code.
.
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ // Identify this question var thisQuestion = $('#question{QID}'); // Listener on the radios $('tr.subquestions-list input[type="radio"]', thisQuestion).click(function(event) { var thisRow = $(this).closest('tr.subquestions-list'); $('input[type="text"]', thisRow).val(''); }); // Keyup listener on the text inputs $('tr.subquestions-list input[type="text"]', thisQuestion).keyup(function(event) { if($(this).val() != ''){ var thisRow = $(this).closest('tr.subquestions-list'); $('input[type="radio"]', thisRow).attr('checked', false); } }); // Paste listener on the text inputs $('tr.subquestions-list input[type="text"]', thisQuestion).bind('paste', function () { var thisInput = $(this); setTimeout(function() { // Little timeout so the val() is available if($(thisInput).val() != ''){ var thisRow = $(thisInput).closest('tr.subquestions-list'); $('input[type="radio"]', thisRow).attr('checked', false); } }, 100); }); }); </script>
Here is the survey back with the amended code.
.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
Last edit: 10 years 4 months ago by tpartner.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10108
- Thank you received: 3593
10 years 4 months ago #102756
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Array num with radio in last column
I should point out that I assumed you are using LS 2.0.
If using 2.05,the code would be slightly different:
If using 2.05,the code would be slightly different:
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ // Identify this question var thisQuestion = $('#question{QID}'); // Listener on the radois $('tr.subquestions-list input[type="radio"]', thisQuestion).click(function(event) { var thisRow = $(this).closest('tr.subquestions-list'); $('input[type="text"]', thisRow).val(''); }); // Keyup listener on the text inputs $('tr.subquestions-list input[type="text"]', thisQuestion).keyup(function(event) { if($(this).val() != ''){ var thisRow = $(this).closest('tr.subquestions-list'); $('input[type="radio"]', thisRow).prop('checked', false); } }); // Paste listener on the text inputs $('tr.subquestions-list input[type="text"]', thisQuestion).bind('paste', function () { var thisInput = $(this); setTimeout(function() { // Little timeout so the val() is available if($(thisInput).val() != ''){ var thisRow = $(thisInput).closest('tr.subquestions-list'); $('input[type="radio"]', thisRow).prop('checked', false); } }, 100); }); }); </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: MikeConom
The topic has been locked.
- MikeConom
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 31
- Thank you received: 1
10 years 4 months ago #102763
by MikeConom
Replied by MikeConom on topic Array num with radio in last column
Partner thanks for your support.
As i see the different betwwen LS 2.0 and 2.5 is the .prop and .attr
That means when i have to change version i have to take care for this different.
Thanks
Mike Conom
As i see the different betwwen LS 2.0 and 2.5 is the .prop and .attr
That means when i have to change version i have to take care for this different.
Thanks
Mike Conom
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10108
- Thank you received: 3593
10 years 4 months ago #102764
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Array num with radio in last column
Yes, in jQuery 1.6.1 the .prop() method was introduced and replaced several uses of the .attr() method (and pissed off LOTS of developers) -
blog.jquery.com/2011/05/12/jquery-1-6-1-released/
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- MikeConom
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 31
- Thank you received: 1
10 years 4 months ago #102770
by MikeConom
Replied by MikeConom on topic Array num with radio in last column
Partner good morning
I have a hidden question and depence from the days.
when the days are Greater than 3 then the hidden question appear.
When i press the radio button and the days is empty, the question is still visible.
i tried with many methods like focus in days and press backspace or put number less than 3
but i cant find solution.
have you a solution for this?
Thanks
I have a hidden question and depence from the days.
when the days are Greater than 3 then the hidden question appear.
When i press the radio button and the days is empty, the question is still visible.
i tried with many methods like focus in days and press backspace or put number less than 3
but i cant find solution.
have you a solution for this?
Thanks
Attachments:
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10108
- Thank you received: 3593
10 years 4 months ago - 10 years 4 months ago #102779
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Array num with radio in last column
In that case, you will need to fire the fixnum_checkconditions() function for all text inputs in a row when a radio is clicked.
.
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ // Identify this question var thisQuestion = $('#question{QID}'); // Listener on the radois $('tr.subquestions-list input[type="radio"]', thisQuestion).click(function(event) { var thisRow = $(this).closest('tr.subquestions-list'); $('input[type="text"]', thisRow).val(''); // Check conditions... $('input[type="text"]', thisRow).each(function(i) { fixnum_checkconditions($(this).attr('value'), $(this).attr('name'), $(this).attr('type')); }); }); // Keyup listener on the text inputs $('tr.subquestions-list input[type="text"]', thisQuestion).keyup(function(event) { if($(this).val() != ''){ var thisRow = $(this).closest('tr.subquestions-list'); $('input[type="radio"]', thisRow).prop('checked', false); } }); // Paste listener on the text inputs $('tr.subquestions-list input[type="text"]', thisQuestion).bind('paste', function () { var thisInput = $(this); setTimeout(function() { // Little timeout so the val() is available if($(thisInput).val() != ''){ var thisRow = $(thisInput).closest('tr.subquestions-list'); $('input[type="radio"]', thisRow).prop('checked', false); } }, 100); }); }); </script>
.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
Last edit: 10 years 4 months ago by tpartner.
The following user(s) said Thank You: MikeConom
The topic has been locked.
- MikeConom
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 31
- Thank you received: 1
10 years 4 months ago #102796
by MikeConom
Replied by MikeConom on topic Array num with radio in last column
It was my first step when i was looking for the solution, but i forgot to execute each(function(i)
Have a nice evening
Thanks
Have a nice evening
Thanks
The topic has been locked.
- MikeConom
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 31
- Thank you received: 1
10 years 3 months ago #103161
by MikeConom
Replied by MikeConom on topic Array num with radio in last column
Tony
My best wishes for a happy new year.
Is it possible to check the radio button for the next question?
I have try with many conditions but i cant find the solution.
Thanks
My best wishes for a happy new year.
Is it possible to check the radio button for the next question?
I have try with many conditions but i cant find the solution.
Thanks
Attachments:
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10108
- Thank you received: 3593
10 years 3 months ago #103169
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Array num with radio in last column
Sorry, I don't understand the question.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- MikeConom
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 31
- Thank you received: 1
10 years 3 months ago #103172
by MikeConom
Replied by MikeConom on topic Array num with radio in last column
When i choose the r1 (radio button) then the next question to be visible
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10108
- Thank you received: 3593
10 years 3 months ago #103204
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Array num with radio in last column
Okay, the way that I would handle that would be to supplement the listener on the radios to load their value into the hidden text inputs when clicked (I suspect you want that anyway). Then you can fire the fixnum_checkconditions() function as discussed previously.
Code:
<script type="text/javascript" charset="utf-8">$(document).ready(function() { // Identify this question var qID = {QID}; var thisQuestion = $('#question'+qID); // Define the select element (radio) var select1 = '<div id="insertedRadio"> \ <input type="radio" title="ans_1" value="1" name="Radio1" /> \ </div>'; var select2 = '<div id="insertedRadio"> \ <input type="radio" title="ans_2" value="2" name="Radio1" /> \ </div>'; // Hide the text inputs $('#question'+qID+' .answer_cell_005 input[type="text"]').addClass('hidden').hide(); $('#question'+qID+' .answer_cell_006 input[type="text"]').addClass('hidden').hide(); // Insert the select elements $('#question'+qID+' .answer_cell_005').append(select1); $('#question'+qID+' .answer_cell_006').append(select2); // Listener on the radios $('tr.subquestions-list input[type="radio"]', thisQuestion).click(function(event) { var thisRow = $(this).closest('tr.subquestions-list'); var thisCell = $(this).closest('td.question-item'); var thisTextInput = $('input[type="text"]', thisCell); $('input[type="text"]', thisRow).val(''); $('input[type="text"]', thisCell).val($(this).attr('value')); // Check conditions... checkThisRowConditions(thisRow) }); // Keyup listener on the text inputs $('tr.subquestions-list input[type="text"]', thisQuestion).keyup(function(event) { if($(this).val() != ''){ var thisRow = $(this).closest('tr.subquestions-list'); $('input[type="radio"]', thisRow).attr('checked', false); $('input[type="text"].hidden', thisRow).val(''); // Check conditions... checkThisRowConditions(thisRow) } }); // Paste listener on the text inputs $('tr.subquestions-list input[type="text"]', thisQuestion).bind('paste', function () { var thisInput = $(this); setTimeout(function() { // Little timeout so the val() is available if($(thisInput).val() != ''){ var thisRow = $(thisInput).closest('tr.subquestions-list'); $('input[type="radio"]', thisRow).attr('checked', false); $('input[type="text"].hidden', thisRow).val(''); // Check conditions... checkThisRowConditions(thisRow) } }, 100); }); function checkThisRowConditions(thisRow) { $('input[type="text"]', thisRow).each(function(i) { fixnum_checkconditions($(this).attr('value'), $(this).attr('name'), $(this).attr('type')); }); } }); </script>
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The following user(s) said Thank You: MikeConom
The topic has been locked.