To fetch the value of the text input box in the newly added tab of the image dialog box in CKEditor, you can use the following code:
// Get the dialog object
var dialog = CKEDITOR.dialog.getCurrent();
// Get the input element by its ID
var inputElement = dialog.getContentElement('uploadTab', 'uploadField');
// Get the value of the input element
var inputValue = inputElement.getValue();
To show images below the text box based on the value of the text box using AJAX, you can use the XMLHttpRequest object to make an AJAX request to the server and get the images based on the input value. Here's an example code:
// Get the dialog object
var dialog = CKEDITOR.dialog.getCurrent();
// Get the input element by its ID
var inputElement = dialog.getContentElement('uploadTab', 'uploadField');
// Get the value of the input element
var inputValue = inputElement.getValue();
// Make an AJAX request to the server
var xhr = new XMLHttpRequest();
xhr.open('GET', '/get-images?value=' + inputValue);
xhr.onload = function() {
if (xhr.status === 200) {
// Parse the response and show the images below the text box
var images = JSON.parse(xhr.responseText);
// ...
} else {
console.log('Request failed. Returned status of ' + xhr.status);
}
};
xhr.send();
Note that you need to replace /get-images with the URL of your server-side script that returns the images based on the input value. Also, you need to replace the // ... comment with the code that shows the images below the text box.