フォームの値を取得して計算するClient Scriptの書き方について
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
01-10-2024 07:16 AM - 編集済み 01-10-2024 08:09 AM
表題について、フォーム上のIntegerのタイプのフィールドから値を取得して計算し、
別のIntegerタイプのフィールドに値を設定するClient Scriptを書こうとしています。
私がJavascript初心者であることもあり、うまく動作せずに困っています。
ご協力いただけないでしょうか。
具体的には、フォーム上からIntegerの数値を取得し、消費税を計算させてIntegerのフィールドに格納したいです。
テーブル:Forecast
Type:onChange
フィールド:Planned Amount(Excludint Tax)
入力したいフィールド:Consumption Tax(消費税)
***以下Script***

- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
01-10-2024 08:00 AM
Hi @Toshikazu "u_planned_consumption_tax" field is also decimal type field or integer type field?
Just to add, you wont be able to add decimal value into integer type field. either change the target field as string or decimal then you will be able to set decimal value into target field.
You can use below article that will be useful to handle number methods.
Hope it will help you.
Thanks,
Harsh
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
01-10-2024 08:13 AM
Hi @Harsh Vardhan
Thank you for your reply.
Both "u_planned_consumption_tax" and "Planned Amount(Excludint Tax)" are integer field.
However this Script doesn't work. I cannnot make sure how to modify my script.
I think that "setValue" function is only for Strings field...

- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
01-10-2024 08:28 AM
@Toshikazu Problem is you are multiplying the value 0.1 with integer value, the result will always come in decimal. that's the reason I suggested you wont be able to set decimal value to integer type field.
you need to change u_planned_consumption_tax as string so it can contain decimal number as well.
Thanks,
Harsh
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
01-14-2024 08:35 AM
Thank you for your reply.
I make sense, but we cannnot change field type.
Is there a way to implement it while keeping the field type as Integer?