Lookup Field formatting

60 views
Skip to first unread message

Randy Flinn

unread,
Nov 30, 2025, 8:30:04 PM (9 days ago) Nov 30
to mementodatabase
Hello

I have a Lookup field retrieving info from a related Library and displaying as shown in the following pic (the yellow and blue values).


Is there a way to format that values to (2) decimal places?  I did use a javascript but now have two fields displayed as the following…


Thanks,
Randy


Graham Wood

unread,
Dec 1, 2025, 12:28:54 AM (9 days ago) Dec 1
to mementodatabase
I did something similar in a travel database I have
I set the lookup field to hidden then added a javascript field that got the value from the hidden field and displayed it with a $ sign and the 2 decimal places. In the sample javascript my lookup field I hid is called Accommodation TTL. I  then added a  Javascript field Accommodation Total and added this code below
Hope this helps

function formatMoney(x) {

    x = Number(x).toFixed(2); // force 2 decimals

    var parts = x.split(".");

    parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ","); // thousands

    return "$" + parts.join(".");

}

formatMoney(field("Accommodation TTL"));

 


Mmm

unread,
Dec 1, 2025, 2:48:17 AM (9 days ago) Dec 1
to mementodatabase
Большое спасибо автору темы, если в своих новых темах, вопросах, сообщениях он будет прикреплять изображения как файлы, а не как картинки.

Браузер Google Chrome на смартфоне.
Страница сообщения (настройка "Версия для ПК" отключена). Читать можно, отвечать нельзя (скриншот 1).
Страница сообщения (настройка "Версия для ПК" включена). Читать нельзя, отвечать можно (скриншот 2).

Масштаб страниц на скриншотах одинаковый – 100%.

Основной способ использования – второй.
Увеличение масштаба страницы (для чтения) пропорционально увеличивают изображения (скриншот 3).

понедельник, 1 декабря 2025 г. в 08:28:54 UTC+3, grahamsc...@gmail.com:
Screenshot_3.png
Screenshot_1.png
Screenshot_2.png
Reply all
Reply to author
Forward
0 new messages