Highlighted

dynamic superscript for values in TextField

muraliv29958402

30-11-2017

Hello,

I wanted to add a superscript dynamically to the values comes in sample xml. I cannot hard code the superscript in textfield because the values populated from sample xml. is there a way to achieve this?

I have see few posts about super script but they did not really help my requirement. I am attaching the screenshot how I need the output to be.

All the data (product name, category, code ..) comes from sample xml. I need to add superscript to Product based on some logic.

I tried something like making the textfield as Richtext and append the superscript but no luck.

Textfield.rawvalue = xfa.resolveNode("xfa.record.main.Productname").value + <sup>1</sup>

Any help please?LC.png

Thanks

Krish

Replies

Highlighted

radzmar

MVP

30-11-2017

You can do so. You'll need at least an invisible plain text field which gets populated by the XML and a RichText field, which will display values plus superscripted numbers for endnotes etc. With a few lines of JavaScript you'll get you result.

var cSourceText = PlainTextField.rawValue,

    cSuperScript = "1",

    xHTML = "<body xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:xfa=\"http://www.xfa.org/schema/xfa-data/1.0/\"><p style=\"letter-spacing:0in\">" + cSourceText + "<sup>" + cSuperScript + "</sup></p></body>";

RichTextField.value.exData.loadXML(xHTML, false, true);

Highlighted

muraliv29958402

30-11-2017

Thank you. I just did how you mentioned. But no luck. my rich text fiels is empty. I have written this code in Calculate event of the richtext field. and value for Plain text field is coming from sample xml. Not sure why it is not working for me.

Highlighted

radzmar

MVP

30-11-2017

This is a side effect of the calculate event in the target text field. The value is there but not displayed by the text fields widget.

Add the script in the calculate event of another element like a surrounding subform or a hidden button.

1362292_pastedImage_1.png