Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/468.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 根据单选按钮选择打开下拉列表的步骤_Javascript_Html_Angularjs - Fatal编程技术网

Javascript 根据单选按钮选择打开下拉列表的步骤

Javascript 根据单选按钮选择打开下拉列表的步骤,javascript,html,angularjs,Javascript,Html,Angularjs,我想根据单选按钮选择打开下拉选项。Mu代码是用AngularJS编写的 如果选择了整个公司,则不应显示下拉元素。 如果选择了人口统计,则应显示下拉元素 我的HTML代码是: <div> <label style = "position:relative; left:10px; top:20px">Please Choose One:</label> <div style = "position: relative; left: 200px; top:

我想根据单选按钮选择打开下拉选项。Mu代码是用AngularJS编写的

如果选择了整个公司,则不应显示下拉元素。 如果选择了人口统计,则应显示下拉元素

我的HTML代码是:

<div>
<label style =  "position:relative; left:10px; top:20px">Please Choose One:</label>
<div  style = "position: relative; left: 200px; top:-13px">
<input type="radio" checked="" value="OverallCompany" id="optionsRadios1" name="optionsRadios" ng-model="recom.radio" onclick="show();"> OverallCompany
<div>
<input type="radio" checked="" value="Demographics" id="optionsRadios1" name="optionsRadios" ng-model="recom.radio" onclick="show();">Demographics
</div>
</div>
</div>

<div class="form-group">
<label style="position: relative; left:10px; top: 28px">Demographics:</label>
<div style = "position: relative; left:200px">
<select multiple chosen class="chosen-select" id="demo" ng-model="recom.demo" ng-options = "z as z.demographicName for z in demotype" tabindex="4" style = "width:880px;" required >
</select>
</div>
</div>
请帮助我怎么做


谢谢

您希望show函数中有一个参数,但在模板中您没有传递它

整个公司

人口统计学
不需要功能。只需像这样添加
ng show

 <div class="form-group" ng-show="recom.radio == 'Demographics'">
    <label style="position: relative; left:10px; top: 28px">Demographics:</label>
    <div style="position: relative; left:200px">
      <select multiple chosen class="chosen-select" id="demo" ng-model="recom.demo" ng-options="z as z.demographicName for z in demotype" tabindex="4" style="width:880px;" required>
      </select>
    </div>
  </div>

人口统计学的:
尝试下面的代码


请选择一个:
整体公司
人口统计学的
人口统计学的:
var-app=angular.module('myApp',[]);
应用程序控制器('myCtrl',函数($scope){
$scope.isDemographics=true;
});


我也尝试过同样的方法,但仍然不起作用,给出了一个错误我们喜欢这段代码,并解释了它为什么起作用。我邀请您花点时间阅读本指南“如何写出一个好的答案?”如下:
 <div class="form-group" ng-show="recom.radio == 'Demographics'">
    <label style="position: relative; left:10px; top: 28px">Demographics:</label>
    <div style="position: relative; left:200px">
      <select multiple chosen class="chosen-select" id="demo" ng-model="recom.demo" ng-options="z as z.demographicName for z in demotype" tabindex="4" style="width:880px;" required>
      </select>
    </div>
  </div>
<div ng-app="myApp" ng-controller="myCtrl">

    <div>
        <label style="position:relative; left:10px; top:20px">Please Choose One:</label>
        <div style="position: relative; left: 200px; top:-13px">
            <input type="radio" checked="" ng-value="false" id="optionsRadios1" name="optionsRadios"
                ng-model="isDemographics"> OverallCompany
            <div>
                <input type="radio" checked="" ng-value="true" id="optionsRadios1" name="optionsRadios"
                    ng-model="isDemographics">Demographics
            </div>
        </div>
    </div>

    <div class="form-group" ng-show="isDemographics">
        <label style="position: relative; left:10px; top: 28px">Demographics:</label>
        <div style="position: relative; left:200px">
            <select multiple chosen class="chosen-select" id="demo" ng-model="recom.demo"
                ng-options="z as z.demographicName for z in demotype" tabindex="4" style="width:880px;" required>
            </select>
        </div>
    </div>

</div>

<script>
    var app = angular.module('myApp', []);
    app.controller('myCtrl', function ($scope) {
       $scope.isDemographics=true;
    });
</script>