Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

Working with Drop-Down: Selection will format a numeric field with different currency formats

Avatar

Level 1

Hello:

I have been trying to figure this out for sometime, I currently have a drop-down field and a few numeric fields. What I am looking to do is when a currency type is chosen in the drop down then those numeric fields will adjust to be in those formats, i.e. if GBP is chosen then when entering a number in the fields will display GBP format. Could someone help with this? I have attached a partial sample of what I am creating.

Another item i am looking to assistance is when a dropdown item is selected then checkboxes will only be in readonly. I have added this to the sample. If someone could provide guidance that would be great. i.e. when fully invoiced is selected then delete order will be readonly.

What I had created for the currency is under calculate function in the numeric fields i entered the following script which doesnt work. I had select the drop-down to have bindings for each item.

if Subform3.Table5.Row1.DropDownList2.value = "EUR"

{

    $.locale = "en_GB_EURO"

}

else Subform3.Table5.Row1.DropDownList2.rawValue = "GBP"

{

    $.locale = "en_GB"

}

else Subform3.Table5.Row1.DropDownList2.rawValue = "NOK"

{

    $.locale = "nb_NO"

}

else Subform3.Table5.Row1.DropDownList2.rawValue = "SEK"

{

    $.locale = "sv_SE"

}

else Subform3.Table5.Row1.DropDownList2.rawValue = "DKK"

{

    $.locale = "da_DK"

}

else Subform3.Table5.Row1.DropDownList2.rawValue = "CHF"

{

    $.locale = "it_CH"

}

Thanks!

2 Replies

Avatar

Level 10

Hi,

Here is a sample. It is not ideal becuase while it changes the locale, it does not take effect until each field is amended. I have changed the default locale to ambient and there is script in the exit event of the dropdown.

Its a start.

N

Avatar

Level 10

OK,

The solution involves a bit of a workaround.

Here is the script in the exit event of the dropdown:

switch(this.rawValue)


{


     case "1":

     form1.locale = "en_GB_EURO";

     form1.page1.NumericField1.locale = "en_GB_EURO";

     form1.page1.NumericField2.locale = "en_GB_EURO";

     break;


     case "2":

     form1.locale = "en_GB";

     form1.page1.NumericField1.locale = "en_GB";

     form1.page1.NumericField2.locale = "en_GB";

     break;


     case "3":

     form1.locale = "nb_NO";

     form1.page1.NumericField1.locale = "nb_NO";

     form1.page1.NumericField2.locale = "nb_NO";

     break;


     case "4":

     form1.locale = "sv_SE";

     form1.page1.NumericField1.locale = "sv_SE";

     form1.page1.NumericField2.locale = "sv_SE";

     break;


     case "5":

     form1.locale = "da_DK";

     form1.page1.NumericField1.locale = "da_DK";

     form1.page1.NumericField2.locale = "da_DK";

     break;


     case "6":

     form1.locale = "it_CH";

     form1.page1.NumericField1.locale = "it_CH";

     form1.page1.NumericField2.locale = "it_CH";

     break;

}


//xfa.layout.relayout();

//xfa.form.recalculate(1);


var vNumber1 = NumericField1.rawValue;

NumericField1.rawValue = null;

NumericField1.rawValue = vNumber1;


var vNumber2 = NumericField2.rawValue;

NumericField2.rawValue = null;

NumericField2.rawValue = vNumber2;

The commented out lines (relayout and recalculate) did not work, so I dumped the values of the fields into variables; nulled the numericFields and then put back the values.

If works, but if you have a lot of fields it may become awkward to script.

Hope that help,

Niall