【问题标题】:how to select multiple values from two drop down and display it in text-area on the click of submit如何从两个下拉列表中选择多个值并在单击提交时将其显示在文本区域中
【发布时间】:2014-11-03 14:06:08
【问题描述】:

我想从两个下拉列表中选择多个值,然后单击提交按钮将其显示在文本区域中。我不知道如何从两个不同的下拉列表中获取值并将其显示在单个文本区域中,以及如何在控制器中编写函数以获取两个下拉列表中的值并将其分配给单个变量,以便我可以使用它在文本区域中。

【问题讨论】:

  • 发布你的dropdowntextarea,你有没有尝试过?
  • 我已经尝试了一个下拉菜单..ii dnt 知道如何为多个下拉菜单执行此操作.. 即使是一个下拉菜单也无法正常工作..

标签: angularjs drop-down-menu


【解决方案1】:

您可以使用 ng-model 将选定的下拉数据绑定到控制器。这些是 angularjs 的基础知识。 请检查此示例小提琴http://jsfiddle.net/6V66F/83/

$scope.containers = [{
    id: 1,
    name: 'Box1'
}, {
    id: 2,
    name: 'Box2'
}, {
    id: 3,
    name: 'Box3'
}];

$scope.select = function(container) {
    $scope.selectedItem = container;        
};
  $scope.submit = function() {
   alert($scope.selectedItem.name +$scope.selectedItem2.name);     
};

【讨论】:

  • 我需要选择多个值..例如,如果我想从第一个下拉列表中选择(多个值)box1 和 box2,从第二个下拉列表中选择 box2 和 box3...并以文本形式显示区..谢谢回复
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-08-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-08-16
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多