These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Combo box prompting user input if human

Duniagdra
Registered: Sep 24 2008
Posts: 140

This was originally from this [url=http://www.acrobatusers.com/forums/aucbb/viewtopic.php?id=16884]Thread[/url].

It's been clear to me that my above attempt just simply wont work so here's a new attempt. Having "JavaScript, the Definitive Guide" and searching on here for app.response has given me a new attempt at hacking a means for the user to be prompted for an ability choice if selecting Human. Being as acrobat is accepting the code, I think I'm on the trail and getting somewhere. However, once Human is selected nothing happens. Nothing. Human is the chosen option, but I get no error and no pop up window. I found the code at this [url=http://www.acrobatusers.com/forums/aucbb/viewtopic.php?id=7422]Thread[/url] and modified it slightly; the target field name and the question and title text.

Document Level Function:

function SetRacialBonus() {
 
    if (!event.willCommit) {
 
    if (this.getField("Race").value == "Human")
        {
        var t = this.getField("Ability_" +cResponce + "_Race"); 
//      the target field
        var cResponse = app.response ({ cQuestion: "What Ability is it? Please use ONLY STR, CON, DEX, INT, WIS, or CHA EXACTLY!", cTitle: "Human Ability Bonus",}) ;
//      title of the dialog box
        {
        if (cResponse == null)
        app.alert ("Please complete the question."); 
//      if Cancel is selected
        else
        app.alert("You responded, \" "+cResponse+"\" , is this correct?", 3);
        }
        t. value = cResponse; 
//      places the data from the dialog to the target field
        }
 
 
 
    // Define an object associating a string with an array of six numbers
    var oASRTB = { 
        Dragonborn: [2, "", "", "", "", 2,"Common, Draconic"],
        Dwarf: ["", 2, "", "", 2, "","Common, Dwarven"],
        Eladrin: ["", "", 2, 2, "", "","Common, Elven"],
        Elf: ["", "", 2, "", 2, "","Common, Elven"],
        Half_Elf: ["", 2, "", "", "", 2,"Common, Elven"],
        Halfling: ["", "", 2, "", "", 2,"Common"],
        Human: ["", "", "", "", "", "","Common"],
        Tiefling: ["", "", "", 2, "", 2,"Common"],
    };
 
 
        // Set these field values based on the value of the currently selected item
        // which should be equal to a property name of the oASRTB object defined above,
        // each of which is an array of six numbers
        getField("Ability_STR_Race").value = oASRTB[selExp][0];
        getField("Ability_CON_Race").value = oASRTB[selExp][1];
        getField("Ability_DEX_Race").value = oASRTB[selExp][2];
        getField("Ability_INT_Race").value = oASRTB[selExp][3];
        getField("Ability_WIS_Race").value = oASRTB[selExp][4];
        getField("Ability_CHA_Race").value = oASRTB[selExp][5];
        getField("LangBasrRace").value = oASRTB[selExp][6];
    }
}

This Function is utilized under field properties format custom keystroke script.

Now I originally had the code between "[b]function SetRacialBonus() {[/b]" and "[b]var oASRTB = {[/b]" after the oASRTB variable block and got nothing and tried it in it's current position and still got nothing.

I thought I was being a clever cheat with [b]"var t = this.getField("Ability_" +cResponce + "_Race");"[/b], but I'm wondering if this is part of my problem? Being as Ability_ and _Race are constant I though I could concatenate them right there. Did I do it wrong?

My other dilemma is that the wrong value will end up in the field. As I'm thinking of it now, I'm realizing that there actually is no value being applied to the field. I have absolutely no idea how to get a value of 2 in the field when the user enters STR or CON or DEX, etc.

Am I close, or am I way off target?

I'm also having a new problem. Even after deleting the new code, I can no longer get the bonus for any selected race to show. My hacking capabilities have shown through and through.

Thanks again for any help that can be given,
Jim

Thanks in advance for any help provided,
Jim
The All Time Professional Amateur Hack

My Product Information:
Acrobat Pro 8.1, Windows
Duniagdra
Registered: Sep 24 2008
Posts: 140
Well, I'm proud to say I figured it out on my own. Excuse me while I pat myself on the back because for not knowing what I'm doing - I did it.

However, there is a hitch.

I'm using an invisible button over a text field "Race2".
var oASRTB = {Dragonborn: [2, "", "", "", "", 2,"Common, Draconic"],Dwarf: ["", 2, "", "", 2, "","Common, Dwarven"],Eladrin: ["", "", 2, 2, "", "","Common, Elven"],Elf: ["", "", 2, "", 2, "","Common, Elven"],Half_Elf: ["", 2, "", "", "", 2,"Common, Elven"],Halfling: ["", "", 2, "", "", 2,"Common"],HumanS: [2, "", "", "", "", "","Common"],HumanC: ["", 2, "", "", "", "","Common"],HumanD: ["", "", 2, "", "", "","Common"],HumanI: ["", "", "", 2, "", "","Common"],HumanW: ["", "", "", "", 2, "","Common"],HumanH: ["", "", "", "", "", 2,"Common"],Tiefling: ["", "", "", 2, "", 2,"Common"],};  var strResult = app.popUpMenuEx({cName:"Dragonborn",cReturn:"Dragonborn"},{cName:"Dwarf", cReturn:"Dwarf"},{cName:"Eladrin", cReturn:"Eladrin"},{cName:"Elf", cReturn:"Elf"},{cName:"Half Elf", cReturn:"Half_Elf"},{cName:"Halfling", cReturn:"Halfling"},{cName:"Human",oSubMenu:[{cName:"Strength",cReturn:"HumanS"},{cName:"Constitution", cReturn:"HumanC"},{cName:"Dexterity", cReturn:"HumanD"},{cName:"Intelligence", cReturn:"HumanI"},{cName:"Wisdom", cReturn:"HumanW"},{cName:"Charisma", cReturn:"HumanH"}], }); if(strResult != null){ getField("Race2").value = strResult;getField("Ability_STR_Race2").value = oASRTB[strResult][0];getField("Ability_CON_Race2").value = oASRTB[strResult][1];getField("Ability_DEX_Race2").value = oASRTB[strResult][2];getField("Ability_INT_Race2").value = oASRTB[strResult][3];getField("Ability_WIS_Race2").value = oASRTB[strResult][4];getField("Ability_CHA_Race2").value = oASRTB[strResult][5];getField("LangBasrRace2").value = oASRTB[strResult][6];}

How can I get this to work in a way that allows Human to be the result instead of HumanS in Race2? Is there a way I can do this?

Thanks in advance for any help provided,
Jim
The All Time Professional Amateur Hack