I think I narrowed it down a little. What I want to do:
1)Prefill a List (radio) with 3 options from a Token attribute. That works fine with the following code:
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
if('{TOKEN:ATTRIBUTE_3}' == '1') {
$('input#answer46981X97X23101').attr('checked', true);
}
if('{TOKEN:ATTRIBUTE_3}' == '2') {
$('input#answer46981X97X23102').attr('checked', true);
}
if('{TOKEN:ATTRIBUTE_3}' == '3') {
$('input#answer46981X97X23103').attr('checked', true);
} 2) In the code of the same question I added the following so the next 3 questions (List (dropdown)) to hide/show based on the previous prefill.
(if i dont do this form loads and none of the 3 questions shows. Even with conditions)if(document.getElementById('answer46981X97X23101').checked)
{
document.getElementById('question2307').style.display='block';
document.getElementById('question2308').style.display='none';
document.getElementById('question2311').style.display='none';
}
if(document.getElementById('answer46981X97X23102').checked)
{
document.getElementById('question2307').style.display='none';
document.getElementById('question2308').style.display='block';
document.getElementById('question2311').style.display='none';
}
if(document.getElementById('answer46981X97X23103').checked)
{
document.getElementById('question2307').style.display='none';
document.getElementById('question2308').style.display='none';
document.getElementById('question2311').style.display='block';
}
});
</script>3) Those 3 questions should also prefill based on another Token attribute so I used the code in my original post. The other two questions have similar scripts. This also works!
4) Here is where the headache begins. I also want to set a condition for each of the 3 questions based on the selection of the List (radio). The conditional show/hide works fine but when I submit the survey the data of the answer selected is not saved in the database. When it works? If I just click the dropdown even I select the same answer it shows in the database. Also when I remove the conditions.
The whole idea so you understand what I'm trying to do is: Our university has 3 departments (List (radio)) and each department has several sections (List (dropdown)). So I want to prefill the department and the section of each participant but to also give them the option to change those selections if they transferred from one department to another since I uploaded their data in the tokens table.
Sorry for the long post and if I didn't give you all the info in my first post. I would really appreciate you help!