Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Can you show 2 prices for ACBC summed price attribute

I want to show a monthly price in addition to the regular price. Is there a way to do this? It would need to be done for each component listed on the BYO then carried through to the screener/tournament. The closest thing I found on the forum was this, which I've edited but it doesn't work properly.

asked Mar 28, 2018 by Jackie
The monthly price being one-twelfth the regular price, right?
Probably will be 1/12th not 100% sure if we will use monthly or some other fraction

1 Answer

0 votes
I've updated the code to create a second price, one-twelfth the original price:

    var params = {
        priceRow: 4,
        persons: 12,
        label: 'Price per month:',
        currencySymbol: '$',
        currencySymbolBefore: true
    // BYO
    if ($('.acbc_byo').length) {
        $('.acbc_byo .total_label_cell').html($('.acbc_byo .total_label_cell').html() + '<br/>' + params.label);
        $('.acbc_byo .total_price tbody').append($('.acbc_byo .total_price tbody tr').clone());
        var perPerson = $('.acbc_byo .total_price tbody > tr:last-child input');
        $(perPerson).attr('id', '').attr('name', '');
    // Screener / Choice Task
    if ($('.acbc_screener, .acbc_choicetask').length) {
        // Add per-person row
        var priceRow = $('#[% QuestionName() %]_div .inner_table > tbody > tr:nth-child(' + params.priceRow + ')');
        // Per-person label
        var perPersonRow = $('#[% QuestionName() %]_div .inner_table > tbody > tr:nth-child(' + (params.priceRow + 1) + ')');
        $(perPersonRow).find('.label_text_cell .label_text').text(params.label);
        // Per-person values
        $(perPersonRow).find('.level_text_cell .level_text').each(function(){
            var price = $(this).text().replace(params.currencySymbol, '').replace(',', '');
            price = Number(price) / params.persons;
            price = Math.round(price);
            if (params.currencySymbolBefore) {
                price = params.currencySymbol + price;
            else {
                price += params.currencySymbol;
function SSI_CustomGraphicalRadiobox(graphicalObj, inputObj) {
    var params = {
        persons: 12
    var list = $('input[name=hid_list_[% QuestionName() %]]').val().split(',').map(Number);
    var total = 0;
        var level = SSI_GetValue('[% QuestionName() %]_' + attr);
        if (level) {
            var priceText = $('#[% QuestionName() %]_' + attr + '_' + level).closest('tr').find('.acbc_byo_price_text').text();
            if (priceText) {
                var price = Number(priceText.match(/([0-9]+)/)[0]);
                if (/^\(-/.test(priceText)) {
                    price *= -1;
                total += price;
    $('.acbc_byo .total_price tbody > tr:last-child input').val(Math.round(total / params.persons));

Line 4 should still be updated with which attribute is the summed price.
answered Mar 29, 2018 by Zachary Platinum Sawtooth Software, Inc. (105,350 points)
I'm no longer interested in any spaces as a part of the currency symbol.  I'd be happy to get the symbol to appear after the price correctly.  Below is my code for using the € symbol and having it appear after the price.  In the ACBC settings, the Price symbol is set to "€" (no space).

Line 39
var regex = /\(([+-])([0-9.,]*)€\)$/;

Line 71
var regex = /\(([+-]) ([0-9.,]*)€ or /;

Line 90
var regex = /([0-9.,]*)€\$/;

Line 101
var regex = /^[0-9.,]*€\$/;

Line 101
var regex = /^[0-9.,]*€\$/;

And does line 103 also need a modification?
You've got a good start.

On line 39, you've accidentally removed the space character from my regular expression.  Lighthouse Studio prints out a space between the plus / minus character and the number itself; we need to account for that in the regular expression.

/\(([+-]) ([0-9.,]*)€\)$/

On line 90 and line 101, remove the backslash.  Those are intended as the special regular expression character, not a literal dollar symbol character.


Line 103's regular expression should be this:

That did it, thanks.

In case the client wants the space between the price and the symbol, I tried getting that to work as well.  I realized that the ACBC setting wouldn't save a space, so I set that to be "&nbsp;€".   And for the code, I inserted a space before each € on the regular expressions in lines 39, 71, 90, 101, and 103.  But that didn't work.  I also tried &nbsp; and '', and those didn't work.
Instead of trying to match the "&nbsp;" exactly with your regular expression, you could just use "\s*" like this:

That works, except on the Unacceptables the monthly price is showing as 0. Ex. "489 € or 0 € per month".

Here is what I have for line 90.
var regex = /([0-9.,]*)\s*€$/;