1

I am trying to have the "values" of radio buttons change, dependent on the selection of other radio buttons. (This is for a PDF Form in Adobe Pro (not designer)

The code which I have tried (inserted on the SingleTotal field) is as follows: however it is not calculating:

// Custom Calculate script
(function(){


//declare vars


var oFldSec1 = this.getField("A");
var oFldSec2 = this.getField("B");
var oFldSec3 = this.getField("C");
var oFldSel = this.getField("Options Single");
var oFldSub = this.getField("SingleTotal");

if(oFldSec1.checked) {

     switch(oFldSel.value)
   {
      case "boy":
        event.value = 30;
        break;
      case "girl":
        event.value = 35;
        break;
        default:
        event.value = 0;
        break;
   }
}
else if(oFldSec2.checked) {

switch(oFldSel.value)
   {
      case "boy":
        event.value = 40;
        break;
      case "girl":
        event.value = 45;
        break;
        default:
        event.value = 0;
        break;
   }
}

})

Any help will be greatly appreciated. Thank you :)

4

2 回答 2

1

从文档,radiogroups and checkgroups do not use the value property to store their current state所以你在那里不走运。

尝试:

(function() {

    //declare vars
    var oFldSub = getField("SingleTotal");
    var total = 0;

    var selectedPlan =  getField("PlanOptions").valueAsString;
    var selectedSingle = getField("OptionsSingle").valueAsString;

    if (selectedPlan == "A") {

        switch (selectedSingle) {
        case "boy":
            total = 30;
            break;
        case "girl":
            total = 35;
            break;
        default:
            total = 0;
            break;
        }
    }
    else if (selectedPlan == "B") {

        switch (selectedSingle) {
        case "boy":
            total = 40;
            break;
        case "girl":
            total = 45;
            break;
        default:
            total = 0;
            break;
        }
    }
    event.value = total;
})()
于 2012-11-01T18:12:42.297 回答
0

如果您只是简单地相加或相乘,我会退出 VBA 并尝试“值是以下字段的__ ”。

例如,将字段计划 A 的导出值设为 0,将计划 B 的值设为 10,男孩的值为 30,女孩的值为 35。

然后,无论总数应该去哪里,告诉该字段将其值计算为 PlanA、PlanB、Boy、Girl 的总和

如果选择了 PlanA 并选择了女孩,则值为 35。

于 2013-04-16T12:41:08.473 回答