You are viewing limited content. For full access, please sign in.

Question

Question

How to show percent (%) in a field

asked on January 29, 2021

I'm using a number field to calculate an employee's retirement plan contribution as a percent of annual base salary.  The formula I'm using in the field's Advanced Tab is working fine.  I would like the field to show a % symbol.  Any help would be appreciated.

0 0

Replies

replied on January 31, 2021

You could use the Concatenate function? 

Something like this...

The Number field has the following calculation based on the value from the Number Hidden field...

=CONCATENATE(Number_Hidden," ","%")

You can remove the space too - =CONCATENATE(Number_Hidden,"%")

 

Let me know if you need anything further?

 

Jonathan

1 0
replied on January 31, 2021

Hi Jonathan,

Yes, this worked perfectly.  Thank you so much!  I was really over thinking it and trying to complicate things.

0 0
replied on February 2, 2021

Hi Jonathan,

Is there a way to make a blank field show as a percentage before a number is input.  I have included a field where an employee can enter a number (percentage) to calculate future retirement plan contributions.  This is truly aesthetic but would be nice to have.

0 0
replied on February 2, 2021

Hi Wendy,

This was a little tricky, and I did have some help..

$(document).ready(function () {
  $('.JoinMe').on('focusout',function(){
    var xyz = $('.JoinMe input').val();
    xyz += '%'
    $('.JoinMe input').val(xyz);
  });
});

$(document).ready(function () {
  $('.JoinMe').on('focusin',function(){
    var xyz = $('.JoinMe input').val();
    xyz = xyz.replace ('%', '');
    
    $('.JoinMe input').val(xyz);
  });
});

JoinMe was the class that I set for the Single Line field.

The first part adds the '%' when they go away from that field (focusout).

The second part removes the '%' when they select the field. This is to allow for them to change the number without adding a percent each time. 

 

Jonathan

0 0
replied on February 4, 2021

You should be able to use an IF statement in your formula and avoid all the JavaScript.

=IF(comparison, true_value, false_value)

So your formula could be something like:

=IF(Number_Hidden = "", "0 %", CONCATENATE(Number_Hidden," ","%"))

You compare Number_Hidden with blank.  If it is equal to blank, the value is set to 0 %, otherwise add the % after the Number_Hidden.

replied on February 9, 2021

Hi Jonathan,

I tried your script in a Single Line field and I when I enter a number into the field it only enters a %.  The number doesn't stick. 

I then used your script in a number field and the number sticks but it produces an "Invalid Input" error message the first time I enter a number.  If I enter the same number again the error goes away.  The % does work.  The only parameters I have on the field are range 1-100 and 2 decimal places.  Any ideas?

 

% Invalid Input.JPG
0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.