1

I have a test code block through which I am trying to display a table based on a checkbox selection. The action is working and the table is being displayed. The only problem is - there are no borders. Could you please give me suggestions on what I am doing wrong here?

<!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>
0

1 Answer 1

1

The first error I can see is that a table doesn't have a display value of "block" but "table".

Therefore, simply change this line :

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

To :

document.getElementById('table').style.display. = 'table';
Sign up to request clarification or add additional context in comments.

1 Comment

@arindrajit Glad I could help ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.