Reputation: 79
I have a function which reads the text from two TextArea inputs contained in a dialog box and inserts them into a multi-line asp textbox after I click the save button.
What I want is for the text from the variables sReason and sParents to appear with two empty rows between them.. ie:
text from sReason
text from sParents
Here is the code for my jquery function:
<script type="text/javascript">
$(function() {
$("#DiagSituation").dialog({
autoOpen: false,
height: 300,
width: 350,
modal: true,
buttons: {
"Save": function() {
var sReason = "The reason I am informing/referring to you is " + $('#SitReason').val()
var sParents = "Parent/s presented " + $('#SitParents').val()
$('#txbRefConcern').val(sReason + " " + sParents);
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
},
close: function() {
$('#SitReason').val("");
$('#SitParents').val("");
}
});
var txbRefCon = $("#txbRefConcern").val();
if (jQuery.trim(txbRefCon).length == 0)
{
$("#txbRefConcern").click(function() { $("#DiagSituation").dialog("open"); });
}
});
</script>
I have tried editing the $('#txbRefConcern').val(sReason + " " + sParents);
line of code and adding \ in the quotes but this hasn't worked. How can I get the additional line breaks? I am still new to coding in jquery/javascript so some example code with be helpful.
Thanks for your help.
Rob
Upvotes: 2
Views: 395
Reputation: 16103
I think you mean something allong these lines:
$('#txbRefConcern').val(sReason + "\n\n\n" + sParents);
\n is the Newline character, \r is the windows variant if im correct (meaning carriage Return)
Upvotes: 1