【问题标题】:How to pass javascript variable to velocity template如何将 javascript 变量传递给速度模板
【发布时间】:2014-06-30 15:43:27
【问题描述】:

我使用 jqwidgets 创建了一个下拉列表,并使用速度模板获得了一个表单。在表单操作中,我想获取下拉列表的选定值。我需要控制器页面中的值。如何获取速度模板变量中下拉列表的选定值?我在 $submitUrl.setParameter("filePath", "item") 中传递项目。但是如果我在控制器中打印值,那么我只会得到项目。不是下拉列表的选定值。有什么建议吗?

<script type="text/javascript">

    $(document).ready(function () 
        {

            // Create the countryjqxWidget DropDownList
            $("#countryjqxWidget").jqxDropDownList({source: countryList, selectedIndex: 0, width: '200', height: '25', theme: 'ui-redmond'}); 


            $('#countryjqxWidget').on('change', function (event)
            {     
                var args = event.args;
                if (args) {
                // index represents the item's index.                      
                var index = args.index;
                var item = args.item;
                // get item's label and value.
                var label = item.label;
                var value = item.value;
                alert(value);
               var item = $("#jqxDropDownList").jqxDropDownList('getSelectedItem');

            } 
            });



         });
</script> 

<form id="form" class="form-horizontal"  action="$submitUrl" method="post" >            
            #lr_btn("submit-btn", "Submit", "Submitting...")
    </form>  



#set( $submitUrl = $renderResponse.createActionURL() )
$submitUrl.setParameter("submit", "upload")
$submitUrl.setParameter("filePath", "item")

【问题讨论】:

    标签: spring templates velocity jqwidget


    【解决方案1】:

    您是否尝试过在表单中​​添加“countryjqxWidget”并设置其“name”属性。据我所知,如果您设置“名称”属性,所选值将在表单提交时自动传递。 jQWidgetsDropDownList是从DIV标签创建的没关系,你仍然可以设置它的“name”属性。

    【讨论】:

      猜你喜欢
      • 2018-04-07
      • 2016-09-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-03
      • 1970-01-01
      • 2020-04-24
      • 2020-10-20
      相关资源
      最近更新 更多