Richa
Richa

Reputation: 407

Hiding a row through javascript

I have a row which I want to be hidden through javascript. the issue is it is giving me Microsoft JScript runtime error: Object required. Row on aspx:

<tr id="RowCliamMessage">
    <td>
        <asp:Label ID="Label11" runat="server" ForeColor="Red" Visible="false"
            Text="While .....">
        </asp:Label>
    </td>
</tr>

JavaScript:

function CompareDateRange(sender,args)
{
    if ((CheckDate >= RangeDate1))
    {
        args.IsValid = true;

        if (CheckDate <= RangeDate3)
        {
            document.getElementById('ContentPlaceHolder1_RowCliamMessage').style.display="none";
        }
    }
    else
    {
        args.IsValid = false;
    }
}

Where am I going wrong?

Upvotes: 2

Views: 6230

Answers (2)

Nikhil D
Nikhil D

Reputation: 2509

You do like this dont take contentplaceholder ID

You can hide your TR by below code.

document.getElementById('RowCliamMessage').style.visibility = 'hidden';

You can visible your TR by below code.

document.getElementById('RowCliamMessage').style.visibility = "visible"

difference between display: none and visibility: hidden

visibility: hidden hides the element, but it still takes up space in the layout.

display: none removes the element completely from the document. It does not take up any space, even though the HTML for it is still in the source code.*

Upvotes: 1

Talha
Talha

Reputation: 19282

alert(document.getElementById('RowCliamMessage'));
document.getElementById('RowCliamMessage').style.display = 'none';​

Working Demo on jdFiddle

Upvotes: 0

Related Questions