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
However, there is a hitch.
I'm using an invisible button over a text field "Race2".
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