Skip navigation
alfaista
Currently Being Moderated

how do i autofill textboxes based on the selection from an option group?

Apr 9, 2012 7:17 AM

Tags: #acrobat #acrobat_form #autofill #option_groups #option_buttons

hello!  i have 4 columns of data and i would like to do something like you see when you order something and you fill in the billing address, and then there is a button for the shipping that says "same as billing?".  if you check that, it autofills.

well i need 3 of the columns to be able to autofill if the user selects one of the other three as their "same as" type.  if not, then the users needs to be able to type it in.

i can do it on a single checkbox, but am confused as to how to do this with an option group of 3?

 

any assistance would be appreciated!

 

oh, also, is there a way to have the option group "empty", no selection made if the user does not what to choose anything?  or do i have to have an "NA" type of option button in each group?

 
Replies
  • Currently Being Moderated
    Apr 9, 2012 1:05 PM   in reply to alfaista

    Just apply the same script to all 3 check-boxes...

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 9, 2012 4:20 PM   in reply to Gilad D (try67)

    well, i want to use option buttons.  so, i put the same script on each button?  in the what, mouse down event? 

    with a plain checkbox i had script in the textbox that needed filling, in the custom calculation script, and it worked.  i cannot seem to get any code attached to the option button to work.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 10, 2012 1:24 AM   in reply to alfaista1

    MouseUp is usually a better choice. Are those check-boxes mutually exclusive, though? If not, you'll have to check in your script which ones are checked.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 10, 2012 4:58 AM   in reply to Gilad D (try67)

    the check boxes are actually radio buttons that i made look like check boxes.  yes, they are mutually exclusive.  the group of 3 have the same name, but different values.

    so, do i put the script on the mouseup event of the group, or of each one?  and what exactly would that script look like?  here is what i have (i am a long time programmer, but very new to Java)...

     

    if (this.getField("OwnerSameAs")== 1) {

    (this.getField("OwnerName").value)==(this.getField("RiderName").value)

    }

     

    OwnerSameAs is the name of the group of 3 check boxes.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 10, 2012 5:02 AM   in reply to alfaista1

    On each radio-button, and it will need to be something like this (this is assuming "1" is the export value you entered for that radio-button):

     

    if (this.getField("OwnerSameAs").value == "1") {

         this.getField("OwnerName").value = this.getField("RiderName").value;

    }

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 10, 2012 5:28 AM   in reply to Gilad D (try67)

    i must be doing something really nuts!!  and btw, i do appreciate the help!  THANK YOU!!!

     

    i have this on each button, so maybe i am not handling the buttons correctly?  their "values" are 1,2,3.  I suppose i could have yes, no, yes, or something like that.  it is random when they are created, i just made them each something that made sense to me.  since it is on the actual boxes, i have tried both this.getField("OwnerSameAs"), and event.targetValue, and event.rawValue.  nothing happens.

     

     

    if (this.getField("OwnerSameAs")== "1")

    {

    (this.getField("OwnerName").value)=(this.getField("RiderName").value);

    }

    else if (this.getField("OwnerSameAs")== "2")

    {

    (this.getField("OwnerName").value)=(this.getField("TrainerName").value );

    }

    else if (this.getField("OwnerSameAs")== "3")

    {

    (this.getField("OwnerName").value)=(this.getField("CoachName").value);

    }

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 10, 2012 5:35 AM   in reply to alfaista1

    You're going back to your code, which is not correct. Use the sample code

    from my previous post.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 10, 2012 6:00 AM   in reply to Gilad D (try67)

    oh, sorry!!  i wasn't paying close enough attention!!

     

    thank you!!  that works!!! 

     

    if i may be so bold, can you see why it says "unterminated string literal 6 at line 7 on this code? which is the "OwnerOtherPh" line?  am i doing too much? or are you not supposed to have ";" at the end of each line?

     

    if (this.getField("OwnerSameAs").value=="1")

    {

    this.getField("OwnerName").value=this.getField("RiderName").value;

    this.getField("OwnerAddress").value=this.getField("RiderAddress").valu e;

    this.getField("OwnerCityStZip").value=this.getField("RiderCityStZip"). value;

    this.getField("OwnerCell").value=this.getField("RiderCell”).value;

    this.getField("OwnerOtherPh").value=this.getField("RiderOtherPh").valu e;

    this.getField("OwnerEmail").value=this.getField("RiderEmail").value;

    this.getField("OwnerUSEF").value=this.getField("RiderUSEF").value;

    this.getField("OwnerUSDF").value=this.getField("RiderUSDF").value;

    }

    else if (this.getField("OwnerSameAs").value=="2")

    {

    this.getField("OwnerName").value=this.getField("TrainerName").value;

    this.getField("OwnerAddress").value=this.getField("TrainerAddress").va lue;

    this.getField("OwnerCityStZip").value=this.getField("TrainerCityStZip" ).value;

    this.getField("OwnerCell").value=this.getField("TrainerCell”).value;

    this.getField("OwnerOtherPh").value=this.getField("TrainerOtherPh").va lue;

    this.getField("OwnerEmail").value=this.getField("TrainerEmail").value;

    this.getField("OwnerUSEF").value=this.getField("TrainerUSEF").value;

    }

    else if (this.getField("OwnerSameAs").value=="3")

    {

    this.getField("OwnerName").value=this.getField("CoachName").value;

    this.getField("OwnerAddress").value=this.getField("CoachAddress").valu e;

    this.getField("OwnerCityStZip").value=this.getField("CoachCityStZip"). value;

    this.getField("OwnerCell").value=this.getField("CoachCell”).value;

    this.getField("OwnerOtherPh").value=this.getField("CoachOtherPh").valu e;

    this.getField("OwnerEmail").value=this.getField("CoachEmail").value;

    this.getField("OwnerUSEF").value=this.getField("CoachUSEF").value;

     

    }

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 10, 2012 6:05 AM   in reply to alfaista1

    You're using an invalid character as the last double-quotes in this line:

    this.getField("OwnerCell").value=this.getField("RiderCell”).value;

     

    You must use only plain characters, not any special Unicode ones.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 10, 2012 6:06 AM   in reply to alfaista1

    Also, in this line you've placed a space in the middle of the word "value"

    at the end:

    this.getField("OwnerOtherPh").value=this.getField("RiderOtherPh").valu e;

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 10, 2012 6:21 AM   in reply to Gilad D (try67)

    thank you SO MUCH!!!  (i cannot seem to find a place to mark you answer as helpful or correct, or whatever this forum allows.)  but it was perfect!

     

    thank you!!!

     

    (do you know if i can make all the radio buttons in a group empty until one is chosen?)

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 10, 2012 6:30 AM   in reply to alfaista1

    You're welcome. There should be an option to mark a specific answer as

    correct or "helpful"...

     

    You need to reset the group in order to clear it. Using a script it would

    be something like this:

    this.resetForm(["Group name"]);

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 10, 2012 11:33 AM   in reply to Gilad D (try67)

    hmm, maybe i cannot see the option to mark it as answered because i had to change my login name from alfaista to alfaista1.  there was something messed up with my original one, i could not sign back in, it would not send me a password reset email, or an email of any sort.

     

    anyway, THANK YOU!!!  all is wonderful now!!!!  i GREATLY appreciate it!!

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points