简体   繁体   English

Javascript PDF表格单选按钮显示/隐藏

[英]Javascript PDF form Radio Button Show/Hide

I searched and couldn't find any results pertaining to javascript / PDF form applications so I apologize if there are actual results out there that I may have missed. 我进行了搜索,但找不到与javascript / PDF表单应用程序有关的任何结果,因此,对于是否有可能遗漏的实际结果,我深表歉意。

I have 5 radio buttons, all sycronized for if one is turned on, rest are turned off. 我有5个单选按钮,它们全部同步显示,如果一个打开,其余的都关闭。 I'm trying to enable, based on which is selected, for which form (Cells) to show on a pdf. 我试图根据选择的内容来启用要显示在pdf上的表格(单元格)。

This is currently where I stand. 我现在站在这里。 The radio button for this script is set to mouse-up, and when turned on Text2 shows, but when a separate radio button is selected Text2 still shows. 此脚本的单选按钮设置为鼠标悬停,并在打开时显示Text2,但是当选择单独的单选按钮时,仍显示Text2。 Only when I re-selected the first radio button does the Text2 disappear. 只有当我重新选择第一个单选按钮时,Text2才会消失。

I'm looking to show only particular cells based on what radio button is selected, and the rest are hidden. 我希望根据所选的单选按钮仅显示特定的单元格,其余的单元格则被隐藏。

If someone could help lead me to a small example and I could apply from there. 如果有人可以帮助我举一个小例子,我可以从那里申请。 Thank you 谢谢

if (this.getField("Text2").display == display.hidden)
{
this.getField("Text2").display = display.visible;
}
else
{
    this.getField("Text2").display = display.hidden;
}

edit: grammar update: This is what i'm necessarily trying to accomplish 编辑:语法更新:这是我必须尝试完成的

if (this.SELECTED("Choice4")){
this.getField("Text4").display = display.visible}
else{
this.getField("Text4").display = display.hiddenl}

update2: does not work either update2:也不起作用

if(document.getElementByI("Choice3").checked){
this.getField("Text4").display = display.visible}
else{
this.getField("Text4").display = display.hidden}

The trick is when toggling a button in a set of radio buttons (or checkboxes behaving as radio buttons) is to first hide all fields which could be shown, and then show the ones matching the selection. 诀窍在于,当切换一组单选按钮(或表现为单选按钮的复选框)中的按钮时,首先要隐藏所有可能显示的字段,然后显示与选择匹配的字段。

This can be made a lot easier with hierarchical field names. 使用分层字段名称可以使此操作变得容易得多。 All fields which can be shown or hidden have the same stem in their name, and the second element matches the option, as in 所有可以显示或隐藏的字段的名称都具有相同的词干,并且第二个元素与选项匹配,例如

showfield.option1.myfield

with

this.getField("showfield").display = display.hidden

you make all fields being part of the showfield group hidden, and with 您可以隐藏属于showfield组的所有字段,并使用

this.getField("showfield.option1").display = display.visible

you show all fields in the option1 group within the showfield group. 您可以显示showfield组中option1组中的所有字段。

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

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