Skip to main content
Inspiring
August 20, 2021
Answered

DROPDOWN CUSTOM KEYSTROKE NO ACCEPTING SCRIPT THAT WOULD DETERMINE VALUE IN ANOTHER DROPDOWN

  • August 20, 2021
  • 4 replies
  • 2394 views

The subject matter i believe is self explanatory. I cant figure out where I'm going wrong. Below is the script.

var Itemlist = this.getField("Van loan list");
if(event.willCommit)
{
switch(event.value) {

case "NORTH":
Itemlist.setItems(["-SELECT-", "PAT-SONNY NIGERIA ENTERPRISES", "EVANS MAC BUSINESS VENTURES LTD", "HAYAT INTERGRATED SERVICES LIMITED (Abuja)", "HAYAT INTERGRATED SERVICES LIMITED (Kaduna)", "HAYAT INTERGRATED SERVICES LIMITED (Nasarawa)", "HAYAT INTERGRATED SERVICES LIMITED (Kogi)", "CELPLANET INTERNATIONAL LIMITED", "AJELIELI AND SONS LIMITED", "ALH AMINU MUHAMMED ACHIDA AND SONS", "BALARABE USMAN ENTERPRISES", "ABDULLAHI MAI SOLAR", "HAMIR INVESTMENT NIG. LTD", "SUFAYE INVESTMENT LIMITED", "MAZAFMINI DEPOT STORES LTD", "SHARUBUTU AND SONS NIGERIA LIMITED", "TABAKO LIMITED", "ALH SANUSI SODANGI & SONS", "ALHAJI ABU ZAMAU ENTERPRISES", "ALH. IBRAHIM USMAN ACHIDA & SONS LIMITED", "NASMAM ENTERPRISES", "ALH ALIYU AHMAD DANFULANI INTERNATIONAL LIMITED", "HAMED BUKAR GLOBAL LTD", "BABAGANA AIMA ENTERPRISES", "NAHEEM HEIGHTS LIMITED", "A. D. BASHARU AND SONS (NIGERIA) LIMITED", "SAN HUSEIN NIG. LTD", "HAMAZ COMMUNICATIONS NIGERIA LIMITED", "A.A. SULEIMAN NIGERIA LIMITED", ]);
Price.value = "";
break;

case "SOUTH":
Itemlist.setItems(["-SELECT-", "ALHAJA KOLAWOLE NIGERIA ENTERPRISES", "DAM-LIZZY VENTURES", "HAPPY PLACE INTERNATIONAL", "ALHAJA KEBE ASIBUNALAU AND COMPANY", "WATERGATE PRODUCTS SERVICES LIMITED", "CHRISLANDBOLU GENERAL TRADING AND ENGINEERING SERVICES LIMITED", "BENEKS PHARMACEUTICAL LIMITED", "LESCENT VENTURES LTD", "TRADEDEPOT LIMITED", "MULTI QUEST", "ABT EPHPHATHA LIMITED", "KPD MERCHANDISE LIMITED", "FAMOUS ECKCCO LIMITED", "W. J. UKAONU & SONS NIG LTD", "DON EKESINO INVESTMENT LIMITED", "FELIX C. UFONDU NIG. ENTS", "ONYESCO INVESTMENT LIMITED", "P. K. ENTERPRISES.", "E. C. ILOABUCHI AND SONS TRADING CO. NIG.", "A. M. OBI & SONS", "CHUDAC BROTHERS NIGERIA", "SUNEST INTEGRATED RESOURCES", "ZITONIA INTEGRATED VENTURES LIMITED", "OTOSI NIGERIA ENTERPRISES", "BUFFALO WORKS LIMITED", "AKUCHI STORES", "REGENT VENTURES", "AUGUSTINE UCHE NIGERIA ENTERPRISES", "ANOKE SJ NIGERIA LTD", "KOJIDAM NIGERIA LIMITED", "ISANGETTE INTERNATIONAL", "MERTESACKER NIG LTD", "HABSOD VENTURES", "ISIAKA AGBOLUAJE NIG ENTERPRISES", "ADESIJI N. VENTURES", "GOF. COMMERCIAL ENTERPRISES.", "OMO-FADE VENTURES", "JOPEEM VENTURES", "MOYIN OLUWA TRADING STORES", "AYOOLAYINKA ENTERPRISES", "FUMBOL GLORY VENTURES" ]);
Price.value = "";
break;

default:
Itemlist.setItems([""]);
Price.value = "";
break;


}

}

 

Someone should kindly help with this ASAP.

Thanks in advance.

    This topic has been closed for replies.
    Correct answer saka5FD5

    If you don't know how to add Document script, read this otherwise skip this part:
    While in 'Prepare form' tool, press SHIFT+D or click on 'More'->Document JavaScript.

    Now to add script:
    Name your script and click 'add' now when new window opens there will be function with name you just added (for this example Il call it droplist),
    script in that window will look like this: function droplist(){}

    put your script (the one you posted in your first post) between those curly brackets:
    function droplist(){put script here}
    Now go to your dropdown field ( the one where you want the script to work) go to format tab->select 'custom' and add your function name to 'Custom keystroke script'
    like this:
    droplist()


    Thanks a lot. it worked.

    4 replies

    try67
    Community Expert
    Community Expert
    August 20, 2021

    Because your script contains the string "AF" Acrobat will hide it after you apply it (as that's used for its internal functions). However, it should still work!

    saka5FD5Author
    Inspiring
    August 20, 2021

    the above suggestion did not work.

    saka5FD5Author
    Inspiring
    August 20, 2021

    An example would really help.

    Thanks

    Nesa Nurani
    Community Expert
    Community Expert
    August 20, 2021

    Where do you call Price variable?

    Add clearItems() to each case so it clears items before setting new ones and set same for default instead of

    Itemlist.setItems([""]);

    use this:

    Itemlist.clearItems();

    saka5FD5Author
    Inspiring
    August 20, 2021

    I'm really a novice to this. I copied this script from some other form that has something to also do with price. What I'm using it don't have field. The drop-down functionality is what I cared about. Meanwhile I did what you adviceme to do  and its still the same result.

    Thanks

    Nesa Nurani
    Community Expert
    Community Expert
    August 20, 2021

    To correct myself, it's not a necessity to set clearItems() on each case but you can still use it at default if you don't want blank choice when you click on field.

    Read try67 post he explained why script disappear, but script should still work.

    The problem is this word "MAZAFMINI" try use it like this MAZA\FMINI line won't show in items and script should be visible.

    You can delete lines that include Price.

    UPDATE:

    You should put script in "Custom Keystroke Script"

    LinSims
    Community Expert
    Community Expert
    August 20, 2021

    Moving.

    Ged_Traynor
    Community Expert
    Community Expert
    August 20, 2021

    Hi

    Can you tell us which Adobe application you're using so we can move the thread to the correct forum

    saka5FD5Author
    Inspiring
    August 20, 2021

    Acrobat DC.

    Thanks a lot.