I am getting issue in Ckeditor I have ckeditor textarea and signature text field when I am trying to update in signature it has to update in ckeditor signature area.
Here is my code
// Function to update subject and body based on start date
function updateSubjectAndBody(startDate) {
const form = $('#formCpiStop');
const fromField = form.find('#from');
const toField = form.find('#to');
const subjectParagraph = form.find('#subjectParagraph');
// Format the selected date as "Full day Month and date, year"
const formattedDate = startDate ? new Date(startDate).toLocaleDateString('en-US', { weekday: 'long', month: 'long', day: 'numeric', year: 'numeric' }) : '';
// Get the values from the fields
const from = fromField.val() || '';
const to = toField.val() || '';
const signature = $('#cpistopsignature').val() || '';
const subjectText = `Request for deployment for ${formattedDate} - Please Acknowledge`;
// Set the updated content to the subject paragraph
subjectParagraph.html(subjectText);
// Body content for CKEditor (excluding From and To)
const bodyContent = `
<p>Dear Team,</p>
<p>This is a request for successfully publish thethe tonight's ${formattedDate} for .
We will inform you once the release is complete.</p>
<p>${signature}</p> <!-- Append signature to body content -->
`;
console.log(bodyContent);
// Update CKEditor content directly
if (CKEDITOR.instances.bodyTextarea) {
CKEDITOR.instances.bodyTextarea.setData(bodyContent);
}
}
Here is the HTML field
<div class="form-group">
<label for="subjectCpiStop"><i class="fas fa-heading"></i> Subject</label>
<p id="subjectParagraph"></p>
</div>
<div class="form-group">
<label for="cpistopsignature"><i class="fas fa-signature"></i> Signature</label>
<input type="text" id="cpistopsignature" class="form-control">
</div>
Please let me know what I am doing wrong why the ckeditor not updating the signature field
Note I am not getting any error but ckeditor field is not updating
Working URL URL
Top comments (0)