简体   繁体   English

Acrobat JavaScript表单字段检查/取消选中

[英]Acrobat JavaScript form field check/uncheck

i have problem with PDF fillable form. 我在填写PDF表格时遇到问题。

I have three checkboxes (A, B and C) with same name and different value for "radio button" functions. 我有三个复选框(A,B和C),它们的名称相同,而“单选按钮”功能的值不同。 (this mean only one checkbox can be checked). (这意味着只能选中一个复选框)。

Next, I duplicate this three fields to another page on PDF Form, beceause it is 2 copies of form in one PDF document). 接下来,我将这三个字段复制到PDF表单的另一页上,因为它是一个PDF文档中的2个表单副本。

I need another checkbox called "Discount" (also twice in document), but it can be checked only if "C" checkbox is checked. 我需要另一个名为“折扣”的复选框(在文档中也是两次),但是只有选中“ C”复选框时才能选中它。

In cosequence, when "C" checkbox is checked and "Discount" is checked" and user change main checkbox to "B" or "A", discound checkbox must be automaticaly deselected. 因此,当选中“ C”复选框并选中“折扣”时,并且用户将主复选框更改为“ B”或“ A”时,必须自动取消选中disound复选框。

Can you help me ? 你能帮助我吗 ? Thank you. 谢谢。

In order to prevent access to the Discount box, make it visible only when the first checkbox group's C is checked. 为了防止访问“折扣”框,仅当选中第一个复选框组的C时,才使其可见。 Otherwise, hide it and set it to "Off". 否则,将其隐藏并将其设置为“关”。

In a general calculation script (which is considered best practice), you would add the following code snippet (assuming the ABC checkbox field name is abc.ckb). 在一般的计算脚本(这被认为是最佳实践)中,您将添加以下代码片段(假设ABC复选框字段名称为abc.ckb)。

if (this.getField("abc.ckb").value != "C") {
this.getField("Discount").display = display.hidden ;
this.getField("Discount").value = "Off" ;
} else {
this.getField("Discount").display = display.visible 
}

… and that should do it. ……那应该做到的。

Note that the field value for "unchecked" is always "Off" . 注意,“ unchecked”的字段值始终为"Off"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM