如何获取选择框的选定值并将其传递给操作? [英] How to get the selected value of a selectbox and pass it to an action?

查看:69
本文介绍了如何获取选择框的选定值并将其传递给操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将selectbox的值传递给它的小部件的处理函数

I need to pass the value of the selectbox to it's widget's handler function

var payment = CardService.newSelectionInput()
  .setType(CardService.SelectionInputType.DROPDOWN)
  .setTitle("payment mode")
  .setFieldName("payment_mode")
  .addItem("Debit card", "contact", false)
  .addItem("Net banking", "lead", true)
  .setOnChangeAction(CardService.newAction().setFunctionName("onModeChange"));
section.addWidget(payment);

我希望像setFunctionName("onModeChange").setParams(payment.value)

I expect something like setFunctionName("onModeChange").setParams(payment.value)

推荐答案

我认为您的脚本几乎是正确的.稍加修改即可实现所需的功能.对于您的情况,您想在功能onModeChange上检索contactlead.如果我的理解是正确的,那么该修改如何?

I think that your script is almost the correct. You can achieve what you want by modifying a little. In your case, you want to retrieve contact or lead at the function onModeChange. If my understanding is correct, how about this modification?

在脚本中,您可以按以下方式检索选定的值.用户选择时,所选值将立即发送到onModeChange.请在您的脚本中添加此功能.

In your script, you can retrieve the selected values as follows. When an user selects, the selected values are sent to onModeChange, immediately. Please add this function in your script.

function onModeChange(e) {
    console.log(e.formInput.payment_mode)
}

如果用户选择Debit cardNet banking,则可以分别在e.formInput.payment_mode检索contactlead.

If the user selects Debit card and Net banking, you can retrieve contact and lead at e.formInput.payment_mode, respectively.

如果要在用户选择时提供其他值,请进行修改

If you want to give the additional values when the user selects, please modify

.setOnChangeAction(CardService.newAction().setFunctionName("onModeChange"))

到 :

.setOnChangeAction(CardService.newAction().setFunctionName("onModeChange").setParameters({key1: "value1"}))

通过此修改,在onModeChange(e)处,您可以通过e.parameters.key1检索添加的值.

By this modification, at onModeChange(e), you can retrieve the added values by e.parameters.key1.

  • 此示例假定您的脚本都可以工作,并且您可以在gmail插件上看到选择框.如果您的脚本仍无法运行,请告诉我.
  • setFunctionName()
  • setParameters()

如果我误解了你的问题,对不起.

If I misunderstand your question, I'm sorry.

这篇关于如何获取选择框的选定值并将其传递给操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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