I have been using this script below to select Yes or No to populate text fields. It also works in other ways as well. Well, now I would like to include a tax field using the same script but what it's doing is, it's adding the "1", "2" or "3" inside of the tax rate field. See the script to better understand.
if (event.value.toUpperCase()=="1") event.value = ".08";
if (event.value.toUpperCase()=="2") event.value = ".095";
if (event.value.toUpperCase()=="3") event.value = ".10";
What can I do or modify to have the value be entered into the tax rate field as the tax not the "1", "2" or "3"? It's probably very simple but it's beyond me. Can someone please help me out? Thanks.
So you want the user to be able to enter "1" and have it automatically convert to ".08", for example?
If so, your code should work (although you don't need the toUpperCase() part...). Where did you place it?
I placed the script in the Custom Format. Although, I've tried it in some other places too. You are correct, it does work. It shows the tax rate decimal but it multiplies the "1", "2" or "3" by the Total. Not the tax rate (ex. .0975 etc). I'm a bit confused and don't know what to try.
Use it as a custom calculation or validation script, instead.
Yes, I tried that. But, the number value is what gets calculated. It multiplies the Total field by "1" or by "2". No matter where I place the script. The tax amount doesn't get included in the calculation. The tax amount will show as selected, but it doesn't calculate that amount. When I click on the tax rate field to clear the field I see there's a number 1 or 2 (if that was selected) in the tax rate field.
Can I use a script to push the tax amount to a second text field? Then calculate it from that field? This is beyond me.
That will happen if you use the Format event, as it doesn't change the actual value of the field, but not if you use validation or calculation, which do change it.
I retried it in the Validation. I placed it before any other script that was in there and it worked. Does having the script at the top of the scripts have anything to do with how the script, or if the script will perform? I tried it in the Validation and tried it in the Custom Calc and it did not work. I would hate to think that I would do something wrong or not correct. Hmmm. Thanks, Gilad.
That depends on what the rest of the code does...