ラジオボタンについて10個ほど質問があります。ユーザーが別のレベルに移動する前に、これらすべてをtrueに設定する必要があります。これらの10の質問に真に答えた場合にのみ、フォームの要素の1つを有効にしてさらに編集できるようにしたいと思います。これはサーバー側で実行できますが、JavaScriptで実行する方法がわかりません。何か助けはありますか?とても有難い。ありがとう。
<div>
<label> First Question:</label>
<label>
<input checked="checked" class="radio_buttons optional pull-right allowed" id="is_complete_and_works_true" name="project[person_attributes][is_complete_and_works]" type="radio" value="true" />Yes</label>
<label >
<input class="radio_buttons optional pull-right allowed" id="is_complete_and_works_false" name="project[person_attributes][is_complete_and_works]" type="radio" value="false" />No</label>
</div>
<div>
<label> Second Question:</label>
<label>
<input checked="checked" class="radio_buttons optional pull-right allowed" id="is_complete_and_works_true" name="project[person_attributes][researched]" type="radio" value="true" />Yes</label>
<label >
<input class="radio_buttons optional pull-right allowed" id="is_complete_and_works_false" name="project[person_attributes][researched]" type="radio" value="false" />No</label>
</div>
<div>
<label> Third Question:</label>
<label>
<input checked="checked" class="radio_buttons optional pull-right allowed" id="is_complete_and_works_true" name="project[person_attributes][is_complete_and_works]" type="radio" value="true" />Yes</label>
<label >
<input class="radio_buttons optional pull-right allowed" id="is_complete_and_works_false" name="project[person_attributes][is_complete_and_works]" type="radio" value="false" />No</label>
</div>
このコードは、さらにいくつかの質問に拡張されます。
そうすることでラジオを選択することができました:
var first_ten = $(':radio[name="project[person_attributes][is_complete_and_works]"][value=true], :radio[name="project[person_attributes][researched]"][value=true], etc…);
今、私はそれぞれを繰り返す方法がわかりません。各ラジオをクリックすると、はいかいいえかにかかわらず、要素が有効になる結果を確認したいと思います。どんな考えでも大歓迎です。