", "answerCount": 1, "upvoteCount": 0, "datePublished": "2020-10-08T00:51:52.000Z", "author": { "@type": "Person", "name": "Kevin Kraver", "url": "https://trailblazers.salesforce.com/profileView?u=0053A00000DYgzKQAT", "affiliation": { "@type": "Organization", "name": "Miller Center for Social Entrepreneurship" } }, "acceptedAnswer": { "@type": "Answer", "text": "yikes - figured it out right after I posted this question. simple javascript error. I had the return statement before setting the radio button so it was not executing. working just fine now with this code:    ", "upvoteCount": 0, "url": "https://trailhead.salesforce.com/trailblazer-community/feed/0D54S00000A8o5JSAR", "datePublished": "2020-10-08T00:55:21.000Z", "author": { "@type": "Person", "name": "Kevin Kraver", "url": "https://trailblazers.salesforce.com/profileView?u=0053A00000DYgzKQAT", "affiliation": { "@type": "Organization", "name": "Miller Center for Social Entrepreneurship" } } }, "suggestedAnswer": [] } } Skip to main content
Anyone familar with FormAssembly custom code using javascript? I have the code below. The function ageMonths(x) is working just fine when called from a calculated field (text input). However, I also want to set a binary radio button. Unfortunately the radio button field can not be setup as a calculated field, so I tried to use javascript to push a value into the field. I have seen some examples online of this working, but I can not seem to get this to work. Any suggestions?

 

<script>

 

function ageMonths(x) {

 

  var d = Date.parse(x);

 

  var n = Date.now();  

 

  var ms = n-d;

 

  var m = ms/1000/60/60/24/365.25*12;

 

  return m;

 

  document.getElementById("tfa_1892").checked = true;

 

}  

 

</script>
1 个回答
  1. 2020年10月8日 00:55
    yikes - figured it out right after I posted this question. simple javascript error. I had the return statement before setting the radio button so it was not executing. working just fine now with this code: 

     

    <script>

     

    function ageMonths(x) {

     

      var d = Date.parse(x);

     

      var n = Date.now();  

     

      var ms = n-d;

     

      var m = ms/1000/60/60/24/365.25*12;

     

      document.getElementById("tfa_1892").checked = true;

     

      return m;

     

    }  

     

    </script>
0/9000