I have a pretty simple query, and hopefully someone can help!
I have some javascript that I am sure is one of Tony's, but my coding abilities pretty much stop at the 'educated guesswork' and 'trial and error using examples' stage.
I have an array which is built up from a tickbox gender question (q1), plus a second multiple short comments question for age which is hidden(q2), with the input boxes moved into the preceding array. Currently the text boxes appear first, and then the tick boxes. All I am trying to is swap them over, and I can't seem to be able to do it (i.e. gender first, then age).
I sure it is really simple if you know how - does anyone out there know?
Code:
<span class="qnumber">Q1</span> Please tell us the age and gender of everyone who lives with you in your household. <script type="text/javascript" charset="utf-8">
$(document).ready(function() {
var newHeader = 'Age';
// Identify the questions
var q1ID = '{QID}';
var q1 = $('#question'+q1ID+'');
var q2 = $(q1).nextAll('.multiple-short-txt:eq(0)');
var q2ID = $(q2).attr('id').split('question')[1];
// Hide the second question
$(q2).hide();
// Clean up the array widths imposed by LS
$('.subquestions-list col', q1).css({ 'width':'auto' });
// Insert a new header in the array
$('.subquestions-list thead td', q1).after('<th>'+newHeader+'</th>');
// Move the age inputs into the array
$('.answers-list', q1).each(function(i) {
$('.answertext', this).after('<td class="answer_cell_000"></td>');
});
$('input[type="text"]', q2).each(function(i) {
$('.answer_cell_000:eq('+i+')', q1).append($(this));
});
// Some styles for the array (this could be done in template.css)
$('.subquestions-list th, .subquestions-list td', q1).css({ 'padding':'3px 7px' });
});
</script>