Javascriptを使ってラジオボタンの表示非表示を行いたいです。
http://5am.jp/javascript/form_change_javascript/
上記サイトを利用して、表示非表示が複数ありましたので、
Classに変えてみたところ、動かなくなってしまいました。
どうしたら動くのでしょうか。
宜しくお願いいたします。
<html> <head> <script type="text/javascript"> function entryChange1(){ radio = document.getElementsByName('entryPlan') if(radio[0].checked) { //フォーム document.getElementsByClassName('firstBox').style.display = ""; document.getElementsByClassName('secondBox').style.display = ""; }else if(radio[1].checked) { document.getElementsByClassName('firstBox').style.display = "none"; document.getElementsByClassName('secondBox').style.display = ""; } } //オンロードさせ、リロード時に選択を保持 window.onload = entryChange1; </script> </head> <body> <form> <table border="1" cellspacing="0" cellpadding="5"> <tr style="background:#EFEFEF;"> <th> <label><input type="radio" name="entryPlan" value="" onclick="entryChange1();" checked="checked" />初期はすべて表示</label> <label><input type="radio" name="entryPlan" value="" onclick="entryChange1();" />EEEE</label> </th> </tr> <tr class="firstBox"> <th style="background:#FFCCCC;">Eを選んだ時 消える</th> </tr> <tr> <td style="background:#FFCCCC;"> >Eを選んだ時 消える </td> </tr> <tr class="secondBox"> <th style="background:#CCCCFF;">Eを選んだ時 表示のまま</th> </tr> <tr> <td style="background:#CCCCFF;"> >Eを選んだ時 表示のまま </td> </tr> <tr class="firstBox"> <th style="background:#FFCCCC;">Eを選んだ時 消える</th> </tr> <tr> <td style="background:#FFCCCC;"> >Eを選んだ時 消える </td> </tr> </table> </body> </html>
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/02/09 08:25
2017/02/09 09:01
2017/02/09 09:03