私は2つのグラフを表示し、時間間隔を変更するラジオボタンを含むアプリケーションを開発しています。 私がしようとしているのは、たとえば、私が第2セットのラジオボタンで月を選択した場合、最初のセットにもそのオプションチェックが必要です。Javascriptのさまざまなラジオボタンで複数のチェックを行う
$scope.SetDay= function(){
document.getElementById("SettingMixRadioButtonsGroup1").child[0].checked = true;
document.getElementById("SettingMixRadioButtonsGroup2").child[0].checked = true;
};
をしかし、それは、子要素のチェックを実行しません...私は親を使用している場合、それは正常に動作します:私はJSに次のコードを使用してチェックしてみた
<div class="panel-radio-buttons">
<form id="SettingMixRadioButtonsGroup1">
<label class="radio-inline"><input type="radio" name="radio1" value="1" id="BtnEnrollmentsInpatient"
ng-model="togglePefsBifsTimeFrame" ng-change='SetDay()'>Daily</label>
<label class="radio-inline"><input type="radio" name="radio1" value="2" id="BtnEnrollmentsInpatient2"
ng-model="togglePefsBifsTimeFrame" ng-change='SetWeek()' >Weekly</label>
<label class="radio-inline"><input type="radio" name="radio1" value="3" id="BtnEnrollmentsInpatient3"
ng-model="togglePefsBifsTimeFrame" ng-change='SetMonth()'>Monthly</label>
</form>
</div>
<div class="panel-radio-buttons">
<form id="SettingMixRadioButtonsGroup2">
<label class="radio-inline"><input type="radio" name="radio1" value="1" id="BtnEnrollmentsInpatient4"
ng-model="togglePefsBifsTimeFrame" ng-change='SetDay()'>Daily</label>
<label class="radio-inline"><input type="radio" name="radio1" value="2" id="BtnEnrollmentsInpatient5"
ng-model="togglePefsBifsTimeFrame" ng-change='SetWeek()' ng-checked="togglePefsBifsTimeFrame2" >Weekly</label>
<label class="radio-inline"><input type="radio" name="radio1" value="3" id="BtnEnrollmentsInpatient6"
ng-model="togglePefsBifsTimeFrame" ng-change='SetMonth()'>Monthly</label>
</form>
</div>
非常にスケーラブルなソリューションではありません
.. getElementByIdを(... .prop(真、「確認」);ステータスとどのようなあなたのラジオボタンの関係に来るを取得するには、このリンクはあなたを助けるかもしれませんどのように呼び出され、親がチェックされているかを確認する方法を確認する:https://stackoverflow.com/a/26907052/8703483 –