Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    May 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    may i post a question about javascript here?

    it is late and i'm trying to learn new tricks as i run on fumes.

    i believed creating an interactive pdf form would be fairly easy by using the acrobat XI form options after exporting my form design from indesign CC. i have been successful, for the exception, and it FEELS like a HUGE exception right now... of what i believe is needing to apply javascript to a/several radio buttons on the form.

    i'm trying to create a subset of radio buttons (8) within a selection of (2) radio buttons.

    there are 2 radio buttons... let's say are A and B.

    if A is selected, you proceed to select from a subset of radio buttons beneath A that are numbers (33, 34, 12, 31, 32, 82, 81 and other).

    however, if B is selected, the subset of A ((33, 34, 12, 31, 32, 82, 81 and other) should be 'locked' where no selection can be made. i'm having trouble figuring this out. i'm gathering i need to know how to understand and how to write javascript. yikes.

    i have the option of choosing A OR B working fine as independent choices (as radio buttons), but i have no idea how to 'lock down' the subset of A (33, 34, 12, 31, 32, 82, 81 and other) if B is selected.

    again, i'm not sure if this is a question that is allowable here. if not, my sincere apologies, and feel free to delete it. i do have a lynda.com training subscription, but from what i am reading / researching, even with this (seemingly) small javascript need, i may be in over my head. pitiful, i know. i've been doing non-interactive graphic design for 25 years... this code/programming stuff is just cosmic to me.

  • #2
    New to the CF scene
    Join Date
    May 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by narnee View Post
    it is late and i'm trying to learn new tricks as i run on fumes.

    i believed creating an interactive pdf form would be fairly easy by using the acrobat XI form options after exporting my form design from indesign CC. i have been successful, for the exception, and it FEELS like a HUGE exception right now... of what i believe is needing to apply javascript to a/several radio buttons on the form.

    i'm trying to create a subset of radio buttons (8) within a selection of (2) radio buttons.

    there are 2 radio buttons... let's say are A and B.

    if A is selected, you proceed to select from a subset of radio buttons beneath A that are numbers (33, 34, 12, 31, 32, 82, 81 and other).

    however, if B is selected, the subset of A ((33, 34, 12, 31, 32, 82, 81 and other) should be 'locked' where no selection can be made. i'm having trouble figuring this out. i'm gathering i need to know how to understand and how to write javascript. yikes.

    i have the option of choosing A OR B working fine as independent choices (as radio buttons), but i have no idea how to 'lock down' the subset of A (33, 34, 12, 31, 32, 82, 81 and other) if B is selected.

    again, i'm not sure if this is a question that is allowable here. if not, my sincere apologies, and feel free to delete it. i do have a lynda.com training subscription, but from what i am reading / researching, even with this (seemingly) small javascript need, i may be in over my head. pitiful, i know. i've been doing non-interactive graphic design for 25 years... this code/programming stuff is just cosmic to me.
    note: this is what i tried... based on something else i found online, but it doesn't work at all. you all may read this and laugh, but it is completely over my head and i'm giving it my best shot:

    var cAgree = this.getField("Type_of_Bill - Claim_Status").value; if (cAgree == "Yes") {
    // make the following radio boxes read only
    var oField = this.getField("RadioBox 33X");
    oField.readonly = true;
    ofield = this.getField("Admission_Status_Options 34X");
    oField.readonly = true;
    oField = this.getField("Admission_Status_Options 12X");
    oField.readonly = true;
    oField = this.getField("Admission_Status_Options 31X");
    oField.readonly = true;
    oField = this.getField("Admission_Status_Options 32X");
    oField.readonly = true;
    oField = this.getField("Admission_Status_Options 82X");
    oField.readonly = true;
    oField = this.getField("Admission_Status_Options 81X");
    oField.readonly = true;
    oField = this.getField("Admission_Status_Options Other");
    oField.readonly = true;
    } else {
    // make radio buttons RW
    var oField = this.getField("Admission_Status_Options 33X");
    oField.readonly = false;
    oField = this.getField("Admission_Status_Options 34X");
    oField.readonly = false;
    oField = this.getField("Admission_Status_Options 12X");
    oField.readonly = false;
    oField = this.getField("Admission_Status_Options 31X");
    oField.readonly = false;
    oField = this.getField("Admission_Status_Options 32X");
    oField.readonly = false;
    oField = this.getField("Admission_Status_Options 82X");
    oField.readonly = false;
    oField = this.getField("Admission_Status_Options 81X");
    oField.readonly = false;
    oField = this.getField("Admission_Status_Options Other");
    oField.readonly = false;
    } // end process radio buttons

    the radio button, that when selected, needs to turn off a number of button selections above it.

    the properties of that radio button are:

    general: Type of Bill
    radio button choice: Claim Status

    for the buttons (above this button) that need to be 'locked out' if Claim Status is Chosen are:
    general (for all below): Admission Status Options
    radio button choices:
    33X
    34X
    12X
    31X
    32X
    82X
    81X
    Other

    if you have read this far. thank you. if you can help me, a huge thank you. if not and if this needs to be deleted for whatever reason, my apologies.

  • #3
    New to the CF scene
    Join Date
    May 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i see a couple of errors, i think, where i swapped the button properties (general/choice), but after fixing that, still nothing. ):

  • #4
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,077
    Thanks
    38
    Thanked 498 Times in 492 Posts

    Lightbulb

    I'm not exactly sure I understand the desired endpoint logic, so this is just a SWAG at the problem.

    Code:
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8" />
    
    <title> HTML5 page </title>
    <style type="text/css">
    .show { display:block; }
    .hide { display:none; }
    </style>
    
    </head>
    <body>
    
    <input type="radio" name="rGroup" value="rGroupA" onclick="swapClasses('rGroupB','rGroupA','show','hide')"> A 
    <fieldset id="rGroupA" class="hide">
     <input type="radio" name="Agrp" value="33"> 33 
     <input type="radio" name="Agrp" value="34"> 34 
     <input type="radio" name="Agrp" value="12"> 12 
     <input type="radio" name="Agrp" value="31"> 31 
     <input type="radio" name="Agrp" value="32"> 32 
     <input type="radio" name="Agrp" value="82"> 82 
     <input type="radio" name="Agrp" value="81"> 81 
     <input type="radio" name="Agrp" value="OtherA"> Other A
    </fieldset>
    
    <br>
    <input type="radio" name="rGroup" value="rGroupB" onclick="swapClasses('rGroupA','rGroupB','show','hide')"> B 
    <fieldset id="rGroupB" class="hide">
     <input type="radio" name="Bgrp" value="23"> 23 
     <input type="radio" name="Bgrp" value="24"> 24 
     <input type="radio" name="Bgrp" value="20"> 20 
     <input type="radio" name="Bgrp" value="21"> 21 
     <input type="radio" name="Bgrp" value="22"> 22 
     <input type="radio" name="Bgrp" value="27"> 27 
     <input type="radio" name="Bgrp" value="28"> 28 
     <input type="radio" name="Bgrp" value="OtherB"> Other B
    </fieldset>
    
    
    <script type="text/javascript">
    // toggleClass.js
    
    function toggleClass(showHideDiv) { swapClass(showHideDiv,'show','hide');}
    
    // Following modified from: http://www.openjs.com/scripts/dom/class_manipulation.php
    function hasClass(ele,cls) { return document.getElementById(ele).className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)')); }
    
    function addClass(ele,cls) { if (!hasClass(ele,cls)) document.getElementById(ele).className += " "+cls; }
    
    function removeClass(ele,cls) {
      if (hasClass(ele,cls)) {
        var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
        document.getElementById(ele).className=document.getElementById(ele).className.replace(reg,'');  // old was ' '); 
      }
    }
    
    // Following added to functions
    function swapClass(ele,cls1,cls2) {
      if (hasClass(ele,cls1)) { removeClass(ele,cls1); addClass(ele,cls2); }
                         else { removeClass(ele,cls2); addClass(ele,cls1); }
    }
    
    // additional modification:
    function toggleClasses(showHideDiv, shDiv) { // hides both Ques and Resp if Item is reset
      swapClass(showHideDiv,'show','hide');
      if (hasClass(shDiv,'show')) { swapClass(shDiv,'show','hide'); }
    }
    
    function swapClasses(ele1,ele2,cls1,cls2) {
      if (hasClass(ele1,cls1)) { removeClass(ele1,cls1); addClass(ele1,cls2); }
      if (hasClass(ele2,cls2)) { removeClass(ele2,cls2); addClass(ele2,cls1); }
    }
    </script>
    
    </body>
    </html>
    How close did I come?

  • #5
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,631
    Thanks
    0
    Thanked 648 Times in 638 Posts
    Quote Originally Posted by jmrker View Post
    How close did I come?
    None of that code would be relevant since the OP is not dealing with HTML.

    The answer would be that simple if it were HTML but this is one of the situations where JavaScript running in a PDF is different.

    I haven't done enough JavaScript in PDF coding to know what the specific answer would be. I have done a search to see if I could find the answer but only located three or four questions from others asking why the code the OP has already posted doesn't work (although one tried using the hidden property instead of the readonly one).
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #6
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,077
    Thanks
    38
    Thanked 498 Times in 492 Posts

    Unhappy

    Not very close then.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •