pdf 格式的单选按钮值(javascript 计算)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13166896/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 17:58:21  来源:igfitidea点击:

Radio Button Value in pdf (javascript calculation)

javascriptpdf

提问by user1426583

I have a form which I am creating in Adobe Pro.

我有一个在 Adob​​e Pro 中创建的表单。

The "Grandtotal" field is determined by a variety of radio buttons selected.

“Grandtotal”字段由所选的各种单选按钮决定。

My first step is to give each of the radio buttons a value.

我的第一步是给每个单选按钮一个值。

My set of radio buttons is called "Options" - Radio button 1: "15" Radio button 2: "25"

我的单选按钮集称为“选项” - 单选按钮 1:“15” 单选按钮 2:“25”

What javascript could I use to put the value of the selected radio button (either 15 or 25) into my "Grandtotal" field ?

我可以使用什么 javascript 将所选单选按钮的值(15 或 25)放入我的“Grandtotal”字段中?

I have tried the following:

我尝试了以下方法:

var option1 = this.getField("Options");
var option2 = this.getField("Options");

var total = this.getField("Grandtotal").value;
event.value = option1 or option2

Thank you

谢谢

回答by Ian

I don't know the use of Javascript in PDFs, but what I found online, it looks like you should use something like this:

我不知道在 PDF 中使用 Javascript,但我在网上找到的,看起来你应该使用这样的东西:

var option1 = this.getField("Options1");  // Get first radio button
var option2 = this.getField("Options2");  // Get second radio button
var total = this.getField("Grandtotal");  // Get grand total textbox

if (option1.checked) {
    total.value = option1.value;
} else if (option2.checked) {
    total.value = option2.value;
}

Now, I'm not sure what you mean by my set of radio buttons is called "Options", because that would mean retrieving the radio button fields might be different.

现在,我不确定您的意思是什么my set of radio buttons is called "Options",因为这意味着检索单选按钮字段可能会有所不同。