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
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>