Hello -
I need to populate a question (radio) based on a value stored as a token.
The token attribute stores date of birth information. How can i
convert the token value into a date, then based on the answer,
populate the correct radio option?
Here's the javascript code i've tried...
<script>
$(document).ready(function()
{
var dob = '{TOKEN:ATTRIBUTE_1}' ;
var convertDate = new Date(dob);
var now = new Date();
var age = Math.round(((now - convertDate)/86400000)/365);
if (age < 18)
{
$('input#answer24178X48X4832').attr('checked', true);
}
else if (age >=18 && age < 50)
{
$('input#answer24178X48X4831').attr('checked', true);
}
else if (age > 49)
{
$('input#answer24178X48X4833').attr('checked', true);
}
}
</script>