チェックボックスで選択したテーブル選択行の背景色を変える
サンプルソース
<script language="Javascript"> function Click_Sub(ix) { if (document.all.y1[ix].checked==true) { document.all.x1[ix].style.backgroundColor='#cccccc'; } else { document.all.x1[ix].style.backgroundColor='#ffffff'; } } </script> <table border=1 width=100%> <tr name="x1"> <td><input name="y1" type="checkbox" onclick="Click_Sub(0);">チェック1 <td>テキスト1 <tr name="x1"> <td><input name="y1" type="checkbox" onclick="Click_Sub(1);">チェック2 <td>テキスト2 </table> |
実行結果
チェック | テキスト1 |
チェック | テキスト1 |
関連する内容