Fixed value for Form Field

Home Forums Classic DFFS Fixed value for Form Field

Viewing 4 reply threads
  • Author
    Posts
    • #26363
      Sanchez
      Participant

        I have three fields I need to displace as no more 4 decimal places in the form. The field names are CurrentResult1moprior, CurrentResult2moprior and CurrentResult3moprior This are text fields due to Cascading Dropdowns so I assume I have to first convert to number. I’m trying may code snippets found on this forum but none have helped. Here is the last one used:

        
        
        function convertresult(){
          var Result2mo = getFieldValue("CurrentResult2moprior");
          if(!isNaN(Result2mo)){
                var resultValueFixed = Number(Result2mo).toFixed(4);
            setFieldValue("CurrentResult2moprior",resultValueFixed);
          }
        }
      • #26383
        Alexander Bautz
        Keymaster

          I’m not sure I understand exactly, but if you want to ensure the user types in the correct format you can use something like this:

          jQuery("#dffs_CurrentResult2moprior input").on("blur",function(e){
              var str = jQuery(this).val().replace(/[^0-9.]/g, '');
              jQuery(this).val(Number(str).toFixed(4));
          });

          Alexander

        • #26400
          Sanchez
          Participant

            OMGeee that is not what I was looking for by I am floored. Wow!!! thank you! I have added this to the form as it will be VERY handy. My original question was for a field that will already have read-only data already pre-populated for them using cascade dropdowns. I just need that pre-populated result to not be longer than 4 decimal places at most.

          • #26404
            Alexander Bautz
            Keymaster

              I see. There is no built in function for manipulating the values in a cascading dropdown – if you use a number column it will by default show 10 decimal because it this this way it is stored in the DB.

              I think the easiest would be to create calculated columns in the source list to set the correct format of the field there – and then use the calculated fields in your cascading dropdown config.

              Alexander

            • #26407
              Sanchez
              Participant

                I will do that. Thanks again Alexander!

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