Setting a field value for a dropdown

Forums General discussion Setting a field value for a dropdown

Viewing 2 reply threads
  • Author
    Posts
    • #30686
      Paul Woodcock
      Participant

      Hi Alexander

      I’m struggling to set the field value of a drop-down field called SlotLength

      
      
      function dffs_PreSaveDuration(){
          var noBaby = getFieldValue("BabyNumber").split(" ", 1);
          var X40 = Math.floor(noBaby*40);
          console.log(X40);
          setFieldValue("SlotLength", "[X40]");

      The BabyNumber field is a drop-down with the following values: 1 baby, 2 babies, 3 or more babies. The SlotLength field is also a drop-down with the following values: 40, 80, 120. When checking the console.log(X40) it shows the expected value. I’m clearly making a mistake setting the field value for SlotLength. But I cannot figure it out.

      Regards

      Paul

    • #30688
      Paul Woodcock
      Participant

      Hi Alexander,

      I’ve just realised I needed to change the number to string:

      
      
      function dffs_PreSaveDuration(){
          var noBaby = getFieldValue("BabyNumber").split(" ", 1);
          var X40 = Math.floor(noBaby*40).toString();
          console.log(X40);
          setFieldValue("SlotLength", X40);
      }

      So all sorted. Thanks anyway!

      Paul

    • #30689
      Alexander Bautz
      Keymaster

      I’m glad you figured it out, but it wasn’t a problem with the numeric value. You didn’t pass the actual variable, but a string “[X40]” to the function.

      Alexander

Viewing 2 reply threads
  • You must be logged in to reply to this topic.