代码之家  ›  专栏  ›  技术社区  ›  Wayne

如何在Apache Velocity中将下拉列表的选定值用于另一个标签的文本中

  •  0
  • Wayne  · 技术社区  · 9 年前

    我在Apache Velocity中有一个下拉列表,我需要使用下拉列表的选定值作为标签的文本:

    <select name="fruits" id="fruits">
      <option value="apple">Apple</option>
      <option value="watermelon">Watermelon</option>
    </select>
    

    <label id="selectedValue""> //I need value of selected value here </label>
    

    如何使用apache velocity中另一个标签文本下拉列表中的选定值?

    1 回复  |  直到 9 年前
        1
  •  0
  •   starwarswii Georgi Peev    9 年前

    您可以使用jQuery: JSFiddle

    $(document).ready(function() {
        $(function() {
            $('#fruits').on('change', function(){
                var selected_fruits = $(this).find("option:selected").val();
    
                $("#selectedValue").empty();
                $('#selectedValue').append(selected_fruits);
            });
        });
    });