i want to detect if the checkbox is set to true and then put some data into a textarea. any examples of this?
+5
A:
$('input[type=checkbox]').change(function(){
setMyTextArea(getMyMessage(this.checked));
});
function setMyTextArea(text){
$('#MyTextArea').val(text);
}
function getMyMessage(checked){
return (checked ? myCheckedMessage : myUncheckedMessage);
}
ChaosPandion
2009-08-19 03:59:54
actually, this seems to work in firefox and chrome but not internet explorer.. any idea?
ooo
2009-08-19 12:07:54
the messsage does eventually get sent to the textareas in IE after about 20 seconds where firefox is instant. any idea? also, IE when you uncheck doesn't seem to do anything
ooo
2009-08-19 12:22:24
+3
A:
Here's a quick and dirty example you could hook into an event handler:
Sample:
if ($("#myCheckbox").attr("checked")) {
$("#myTextarea").text("some text");
}
Assume these controls are rendered:
<input type="checkbox" id="myCheckbox"/>
<textarea id="myTextarea"></textarea>
Kevin
2009-08-19 04:04:50