I have the following jquery code:
$(document).ready(function(){
var request_text;
request_text = "Hello my name is " + $('#name').val() + ", and I would like to join the birthday surprise for <%= get_current_board.bp_name.capitalize %>.\n\n" +
"Could you please send me an invitation so that I can participate.\n\nThank you very much. \n\n" + $('#name').val();
$('textarea').text(request_text);
$('#name').keyup(function() {
$('textarea').text(request_text);
});
});
It works for the document.ready part but not for the keyup. I thought it was a scope problem but I can't seem to get it to work.
If I do the following it works:
$('#name').keyup(function() {
request_text = "Hello my name is " + $('#name').val() + ", and I would like to join the birthday surprise for <%= get_current_board.bp_name.capitalize %>.\n\n" +
"Could you please send me an invitation so that I can participate.\n\nThank you very much. \n\n" + $('#name').val();
$('textarea').text(request_text);
});
but I don't want to repeat code.
Any ideas?