2つの表と2つのボタンを配置し、それぞれのボタン押下に応じて、表内の情報のやり取りを行う機能を実装したいです。
下記に表とボタンの機能を示します。
■表1
・表内の各行にラジオボタンを配置
・ファイル名と日時を表示
■追加ボタン
・追加ボタン押下で、表1のラジオボタンで選択されている行(ラジオボタン以外)の情報を表2に追加
・表2に追加された情報がなければ、表2の1行目に追加。
・表2に追加された情報が1つだけならば、表2の2行目に追加
・表2に追加された情報が2つある場合は、アラートを表示し、追加を行わない。
■表2
・表内の各行にチェックボックスを配置
■削除ボタン
・追加ボタン押下によって、表2に追加された行内の情報を削除する。
⇒チェックボックスで選択された行
・
下記に私がイメージしているコードのサンプルを示します。
class="sample" style="margin-top: 50px" id="test2"> <thead> <tr> <th></th> <th>ファイル名</th> <th>時間</th> </thead> <tbody id="select"> <tr> <td><input type="radio" name="check" value="check"></td> <td>sample1</td> <td>00:00:00</td> </tr> <tr> <td><input type="radio" name="check" value="check"></td> <td>sample2</td> <td>00:00:00</td> </tr> </tbody> </table> <button type="submit" id="aaa" name="bbb" class="cc" style="color: #ffffff; background-color: #40b740; margin-top: 20px;">追加</button <div class="table-responsive cncList"> <table class="sample" id="test"> <thead> <tr> <th></th> <th>ファイル名</th> <th>時間</th> </thead> <tbody id="result"> <tr> <td><input type="checkbox" name="checkbox" value="1"></td> <td></td> <td></td> </tr> <tr> <td><input type="checkbox" name="checkbox" value="2"></td> <td></td> <td></td> </tr> </tbody> </table> <button type="submit" id="aaa" name="bbb" class="cc" style="color: #ffffff; background-color: #40b740; margin-top: 20px;">削除</button>
■ボタン押下時の処理イメージ
■追加ボタン
・選択したラジオボタンの値を取得
・追加表示を行う表(表2)を指定
・表2に追加された情報数を判定、0ならば1列目に、1つならば2列目に追加し、2つならばアラートを表示
■削除ボタン
・選択したチェックボックスの値を取得
・指定した列の情報を削除(クリア)
処理イメージに関しては、この通りでなくも問題ありません。
以上です。分かる方お答えいただけると幸いです。
回答1件
あなたの回答
tips
プレビュー