The goal was to get the textbox to slide up and down when the checkbox was clicked. A rather simple thing. As I don't do jQuery or so much client side coding this took me some time to find out. The solution was not so obvious at the start but after checking the jQuery documentation and doing some testing this was the result.
If you want to get the value of an attribute you should use the ":attribute" convention. In the case of the checkbox I first put the object in a variable and then used the .is keyword to do a boolean check of the value, like so.
<script type="text/javascript">
function toggleTextBox() {
var checkBox = $('#<%=chkMoreInfo.ClientID %>');
var textBox = $('.txtMessageArea');
if (checkBox.typeOf != "undefined") {
if (checkBox.is(":checked")) {
textBox.slideUp("slow");
}
else {
textBox.slideDown("slow");
}
}
}
</script>
So long!
Print |
posted on
Saturday, January 10, 2009 6:30 AM