Skip to main content
Participant
January 21, 2016
Question

strikethrough text field based on radio button status using java script

  • January 21, 2016
  • 1 reply
  • 1572 views

Hello,

I've searched high and low for the answer but nothing I've tried worked. I have a form in which one of the text field, called TotalCreditAmount, calculates total credit based on the amounts from the table's fields. The java script used for this calculation under "Custom calculation script" is as follows (formula derived with help found in this forum...credit given):

(function () {

    // Get the input field values, as strings

    var s1 = getField("Credit AmountRow1").valueAsString;

    var s2 = getField("Credit AmountRow2").valueAsString;

    var s3 = getField("Credit AmountRow3").valueAsString;

    var s4 = getField("Credit AmountRow4").valueAsString;

    // Convert strings to numbers

    var v1 = +s1;

    var v2 = +s2;

    var v3 = +s3;

    var v4 = +s4;

    // If either input field is not blank, calculate the sum...

    if (s1 || s2 || s3 || s4) {

        event.value = (v1 + v2 + v3 + v4);

    } else

event.value = "";  // ...otherwise, set blank the field

})();

I have two radio buttons under name "TypeofReturn" with Radio Button Choice "Choice2" and "Choice3".

QUESTION:

Where and what kind of java script would I need to implement in order to STRIKETHROUGH the total amount calculated in the field "TotalCreditAmount"?


I've tried following:

NOTE: The code was added to the "Custom calculation script" of the "TotalCreditAmount" text field before the calculate function.

1. event.target.required = getField("TypeofReturn").valueAsString === "Choice2"; I know this only changes field to "required" but I though this could somehow also work with strikethrough command..... Also when I added another line with "Choice3" in it it would only activate "required" with only one radio button "Choice3" and the other one would do nothing.


2. I've tried working with examples from Adobe java SDK as follows:

var f = this.getField("TotalCreditAmount");

f.richText = true;

f.textColor = color.blue;

f.strikethrough = true;

I wanted to know if it works at all so I've added color change. It does change the color but it does not strikethrough anything...


...help...


This topic has been closed for replies.

1 reply

Bernd Alheit
Community Expert
Community Expert
January 21, 2016

strikethrough is not a property of text fields.


You can use strikethrough at text spans.

dynaplAuthor
Participant
January 21, 2016

Hi Bernd,

I saw SPANS in the Adobe JavaScript API but was not sure on their usage and implementation. Do you have working example or place I can read more about it...

Bernd Alheit
Community Expert
Community Expert
January 21, 2016

‌Look at the Acrobat Javascript Reference. The is example for the use of the property underline.