Mike Eghtebas
asked on
aps 4... javascript... debug
When chkAddComment = True or false, txtComment show/hide using:
This works fine except when the page first loads. When the page first loads and the default value of chkAddComment is false, txtComment remains visible. But when user checks chkAddComment on and off one round txtComment disapears (as expected).
Question: How can I change my code where the txtComment wouldn't show on first time page load?
I suppose I could set txtComment invisible. If so, then I can I make it vsible via the above javascript code?
This is the partial html for ID="chkAddComment" and ID="txtComment":
<script type="text/javascript">
window.onload = function () {
document.getElementById("<%= chkAddComment.ClientID %>").onchange = function () {
var chkAddComment = document.getElementById("<%= chkAddComment.ClientID %>")
if (this.checked) {
document.getElementById("CommentRow").style.display = "block";
} else {
document.getElementById("CommentRow").style.display = "none";
}
}
}
</script>
This works fine except when the page first loads. When the page first loads and the default value of chkAddComment is false, txtComment remains visible. But when user checks chkAddComment on and off one round txtComment disapears (as expected).
Question: How can I change my code where the txtComment wouldn't show on first time page load?
I suppose I could set txtComment invisible. If so, then I can I make it vsible via the above javascript code?
This is the partial html for ID="chkAddComment" and ID="txtComment":
<tr id="chkcommentRow">
<td class="style10">
</td>
<td class="style7">
<asp:CheckBox ID="chkAddComment" runat="server" Text="Add Comment" />
</td>
<td class="style5">
</td>
</tr>
<tr id="CommentRow" class="style10">
<td class="style10">
Comment:</td>
<td class="style7" colspan="2">
<asp:TextBox ID="txtComment" runat="server" Columns="40" Rows="5" Wrap="True"
TextMode="MultiLine"></asp:TextBox>
</td>
</tr>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
+
ASKER