如何使 actionButton 仅在 R 中给出所有输入时才起作用? [英] How to make actionButton only work when all inputs are given in R shiny?

查看:32
本文介绍了如何使 actionButton 仅在 R 中给出所有输入时才起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我的 actionButton 正在通过下拉列表接收用户输入,然后当 actionButton 被按下时,它会将其输出到一个 csv 文件.但是,如果用户只输入 5 个下拉列表中的 2 个并按下 actionButton,这仍将转到 csv 文件.如果给出所有输入,我怎样才能使它只接受 actionButton ?我正在使用observeEvent().

Currently my actionButton is taking in user input through drop down lists, and then when the actionButton is pressed it outputs this to a csv file. However, if the user only inputs 2 out of the 5 drop down lists and presses the actionButton this will still go to the csv file. How can I make it so it only accepts the actionButton if all inputs are given? I am using observeEvent().

推荐答案

如果您使用 shinyjs 包,您可以在并非所有输入都带有类似内容时停用按钮.

if you use the packages shinyjs you can deactivate the button when not all inputs are given with something like this.

observe(
    {
     if(input$one!=""&&input$two!=""&&!is.na(input$three))
       {
        enable("SubmitButton")
       }
     else
       {
         disable("SubmitButton")
       }
     })

请记住,您必须在 ui 中的某处包含 useShinyjs().

just remeber you have to include useShinyjs() somewhere in your ui.

希望这会有所帮助!

这篇关于如何使 actionButton 仅在 R 中给出所有输入时才起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆