闪亮 - 如何获得最后一个推动的Radiobutton的价值?

发布于 2025-02-13 23:38:55 字数 775 浏览 2 评论 0原文

我有5个radiobuttons,其中包括“是”和“否”。 我希望只有在RadioButton上选择“否”时,才希望弹出式弹出仪。 我试图用if语句来解决它,但是逻辑不起作用,因为如果“ buttonabluf1”是否,然后将“ buttonabluf2”推到是的,modaldialog弹出了:

    if(isTRUE(input$buttonAbluf1=="No" ||
        input$buttonAbluf2 =="No" ||
        input$buttonAbluf3 =="No" ||
        input$buttonAbluf4 =="No" ||
        input$buttonAbluf5 =="No"))
    {
                         
                         showModal(popup())
                       }
    popup <- function(){
        modalDialog(easyClose = F,
          textAreaInput("com", "Bemerkung:", width = "750px", heigh = "200px"),
          
          size = "l",  
          
        )
        
      }

我如何定义逻辑,那就可以只有选择“否”,无论其他放射线to菜,它都会弹出吗? 我考虑过要获得最后一个按钮的值。如果此值不是该值,则可以显示Modaldialog。

I have 5 radiobuttons with the choices "yes" and "no".
I want a modalDialog to popup only if you select "no" on the radiobutton.
I tried to solve it with a if statement, but the logic doesn't work, because if "buttonAbluf1" is no and after that the "buttonAbluf2" is pushed to yes, the modalDialog pops up:

    if(isTRUE(input$buttonAbluf1=="No" ||
        input$buttonAbluf2 =="No" ||
        input$buttonAbluf3 =="No" ||
        input$buttonAbluf4 =="No" ||
        input$buttonAbluf5 =="No"))
    {
                         
                         showModal(popup())
                       }
    popup <- function(){
        modalDialog(easyClose = F,
          textAreaInput("com", "Bemerkung:", width = "750px", heigh = "200px"),
          
          size = "l",  
          
        )
        
      }

How could I define the logic, that it only pops up if you select "no", regardless the selection on the other radiobuttons?
I thought about getting the value of the last pushed button. If this value is no the modalDialog could be shown.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

带刺的爱情 2025-02-20 23:38:55

这就是观察者的目的:

observeEvent(input$buttonAbluf1,{
        if(input$buttonAbluf1=='No'){
           showModal(popup())
        }
    })

由于您所有的按钮都应相同,因此您也可以将它们全部包裹在一个前面:

for(i in c(1:5)){
    local({
        i=i
        observeEvent(input[[paste0('buttonAbluf',i)]],{
            if(input[[paste0('buttonAbluf',i)]]=='No'){
                showModal(popup())
            }
        })
    })
}

This is what observeEvent is for:

observeEvent(input$buttonAbluf1,{
        if(input$buttonAbluf1=='No'){
           showModal(popup())
        }
    })

As all you buttons should behave the same, you can also wrap them all in one for-loop:

for(i in c(1:5)){
    local({
        i=i
        observeEvent(input[[paste0('buttonAbluf',i)]],{
            if(input[[paste0('buttonAbluf',i)]]=='No'){
                showModal(popup())
            }
        })
    })
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文