ビジネスロジックに従って現在選択されているラジオボタンに応じて、ラジオボタンのみを有効にするjQueryを作成しようとしています。
基本的に、3 つのラジオ ボタンからなる 3 つのグループがあり、最終的には次のようになります (この例の HTML は冗長で申し訳ありませんが、これが私の言いたいことを示してくれることを願っています)。
<p>
<label for="group_one">Group One</label>
</p>
<p>
<div class="group_one">
<div id="group_one_choice_one">
<label for="group_one_choice_one">Choice One</label>
<br />
<input checked="checked" id="choice_one" type="radio" value="1" />
<br />
</div>
<div id="group_one_choice_two">
<label for="group_one_choice_two">Choice Two</label>
<br />
<input id="group_one_choice_two" type="radio" value="2" />
<br />
</div>
<div id="group_one_choice_three">
<label for="group_one_choice_three">Choice Three</label>
<br />
<input id="choice_three" type="radio" value="3"/ >
<br />
</div>
</div>
</p>
<p>
<label for="group_two">Group Two</label>
</p>
<p>
<div class="group_two">
<div id="group_two_choice_one">
<label for="group_two_choice_one">Choice One</label>
<br />
<input checked="checked" id="choice_one" type="radio" value="1" />
<br />
</div>
<div id="group_two_choice_two">
<label for="group_two_choice_two">Choice Two</label>
<br />
<input id="group_two_choice_two" type="radio" value="2" />
<br />
</div>
<div id="group_two_choice_three">
<label for="group_two_choice_three">Choice Three</label>
<br />
<input id="choice_three" type="radio" value="3"/ >
<br />
</div>
</div>
</p>
<p>
<label for="group_three">Group Three</label>
</p>
<p>
<div class="group_three">
<div id="group_three_choice_one">
<label for="group_three_choice_one">Choice One</label>
<br />
<input checked="checked" id="choice_one" type="radio" value="1" />
<br />
</div>
<div id="group_three_choice_two">
<label for="group_three_choice_two">Choice Two</label>
<br />
<input id="group_three_choice_two" type="radio" value="2" />
<br />
</div>
<div id="group_three_choice_three">
<label for="group_three_choice_three">Choice Three</label>
<br />
<input id="choice_three" type="radio" value="3"/ >
<br />
</div>
</div>
</p>
難しいのは、表示するラジオ ボタンと有効にするラジオ ボタンを決定するために必要なロジックです。ユーザーは各グループから 1 つの選択肢を選択する必要がありますが、あるグループから別のグループに同じ選択肢を繰り返すことはできません。
理想的には、ユーザーがページにアクセスしたときに、すべてのラジオ ボタンが使用可能でありながら選択されていない状態です。
ユーザーが最初に (たとえば) グループ 3 で選択肢 2 を選択した場合、スクリプトはグループ 1 とグループ 2 の両方で選択肢 2 を無効にする必要があります。次に、ユーザーがグループ 2 の選択肢 3 を選択した場合、グループ 1 の選択肢 1 のみを有効にする必要があります。
どんな助けでも大歓迎です。この問題を解決するために書き込もうとしていた jQuery を投稿しますが、これについてはうまく行っていないと思います。ありがとう!