Jump to content

Setting the $ Character in Superscript for Prices


Admin1676454018

Recommended Posts

Copy and paste everything below this line:

 

This rule automatically superscript the dollar sign for pricing. Prior to using this rule, you need to set the superscript offset and ratio values in the Global Paragraph Settings dialog box. To do this:

  1. Double-click any text frame and click the Edit Text… button.
  2. In the Variable Text Editor, click the Paragraph button.
  3. In the Paragraph Formatting dialog box, click the Global Settings… button.

Once you have set the values, change the field "Price" in this JavaScript rule to the name of the field in your data.

 

 

// set superscript font size and baseline shift in template:

// Variabe Text Editor --> Paragraph... --> Global Settings...

// Superscript (Ratio and Offset).

// Set price field name here.

priceVariable=Field("Price")

 

/////////

priceVariable=priceVariable.replace("$", ""); //remove dollar sign if entered by user

priceVariable=FormatNumber("##,###.00##", priceVariable); //format as price with two digits after decimal point

var dollarsCentsArray=priceVariable.split("."); //divide up dollars and cents

dollars = dollarsCentsArray[0];

cents = dollarsCentsArray[1];

//format with superscripted dollar sign/cents if dollars are entered

//or with superscripted cent sign if no dollars entered

if (dollars!="")

{

return '<superscript>'+"$"+'</superscript>'+dollars+'<superscript>'+cents+'</superscript>';

}

else

{

return cents+'<superscript>'+"¢"+'</superscript>';

}

Link to comment
Share on other sites

  • 8 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...