Web Developer's Room
HOME > DHTML サンプル集 > 応用編     

応用編

チェックボックスで選択したテーブル選択行の背景色を変える

<html>
<body>

<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 id="x1"><td><input id="y1" type="checkbox" onclick="Click_Sub(0)">チェック<td>テキスト1
<tr id="x1"><td><input id="y1" type="checkbox" onclick="Click_Sub(1)">チェック<td>テキスト1
</table>

</body>
</html>

 サンプル




スポンサードリンク


(C) Web Developer's Room All rights reserved.