Announcement

Collapse
No announcement yet.

Javascript: Set check box and text field to read only

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Javascript: Set check box and text field to read only

    I have an activity form I need parents to complete. The opening section has the agreement and limitations, etc.. As a parent, you either have to check the box for no restrictions OR in the text field directly below it, state any limitations. It is either or, not both.

    The purpose of the script below is that once the check box is checked, the text field is now read only, and if the text field has text in it, then the check box is now read only.

    Problem:
    1. In Chrome neither works correctly
    2. In the PDF editor, the check box code is not working, it does not set the text field to read only, it looks like it does, as the color of the text field is changed to white, but you are able to click in the field and add text. The text field does change the check box to read only.

    Question:
    1. Why do neither work in Chrome?
    2. How do I fix the checkbox so that the text field is read only when the box is checked?
      1. Will this also resolve the problem of it not working in Chrome?

    Names
    Check Box: None
    Text Field: participant_restrictions

    Javascript
    Check Box
    On Mouse Up
    if(event.target.value == "Yes")
    {
    this.getField("participant_restrictions").readonly = true;
    }

    Text Field
    On Losing Focus
    f = getField(event.target.name)
    if (f.value.length == 0)
    {
    this.getField("None").readonly = false;
    this.getField("participant_restrictions").readonly = false;
    }
    else
    {
    this.getField("None").readonly = true;
    }
    On Mouse Up
    f = getField(event.target.name)
    if (f.value.length == 0)
    {
    this.getField("None").readonly = false;
    this.getField("participant_restrictions").readonly = false;
    }
    else
    {
    this.getField("None").readonly = true;
    }
    Last edited by mahjohn; 01-19-2019, 05:19 PM.

  • #2
    mahjohn Please check the version number of Chrome. Firefox, Google Chrome and Opera don't support the NPAPI style plugins, so Foxit PDF plug-in will not work in Firefox (version 52 and above), Google Chrome(version 45 and above) or Opera(version 12.17 and above) anymore. So I guess the PDF viewer you used to display is Chrome PDF Viewer. Please check

    Regarding "How do I fix the checkbox so that the text field is read only when the box is checked?", is it possible to provide the form directly to us and let us know which field you'd like to be read only so I could further check it with our JS engineer and better advise? You may upload the form here or email the form to support@foxitsoftware.com, Attn: Cherry.

    Thank you.

    Comment


    • #3
      Thanks for the information, I now check to see if the form is being opened externally (Browser), if so, I pop up a note to say that it will not work correctly in a browser and to please use FoxIT Reader, etc.. Also...have resolved the "Check Box" problem.

      Comment


      • #4
        mahjohn

        Glad to hear that it works for you. Thanks for sharing the update.

        Comment

        Working...
        X