簡體   English   中英

根據復選框選擇顯示和隱藏表格不起作用

[英]Show and hide table based on checkbox selection not working

我有一個測試代碼塊,我試圖通過它來顯示基於復選框選擇的表格。 該操作正在運行,並且正在顯示該表。 唯一的問題是 - 沒有邊界。 你能給我一些關於我在這里做錯的建議嗎?

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <table border="1">
                    <tr>
                    <td style=min-width:50px></td>
                    <td style=min-width:50px>Retrofit</td>
                    <td style=min-width:50px><input style=min-width:50px id="retrofit" name="retrofit" type="checkbox" value="1" onchange="javascript:toggleOtherTextboxVisible()" /></td>

       </tr>
        </table>
        <table style="display:none" name="table" id ='table' border="1"/>
        <th>new</th>
        <th>newer</th>
        </table>    
</body>

    <script type="text/javascript">
    function toggleOtherTextboxVisible()
    {
        var check = document.getElementById('retrofit');
        if (check.checked) {
            document.getElementById('table').style.display. = 'block';
        }
        else
        {
            document.getElementById('table').style.display = 'none';
        }                
    }
</script>
</html>

我能看到的第一個錯誤是表的顯示值不是“塊”而是“表”。

因此,只需更改此行:

document.getElementById('table').style.display. = 'block';

到 :

document.getElementById('table').style.display. = 'table';

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM