Hello,
I am creating a custom component, its a moda basically and i want to render a form in side the modal. Can any one help me to achieve it?
Hi Faisal, I just used chat gpt and it gave me the code first time and works fine.
Html for a button to open the modal:
<!-- HTML -->
<button id="open-modal">Open Modal</button>
<div id="modal" class="modal">
<div class="modal-content">
<span class="close">×</span>
<p>This is the modal content. You can add any HTML content here.</p>
</div>
</div>
CSS:
/* CSS */
.modal {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgba(0, 0, 0, 0.4); /* Black w/ opacity */
}
.modal-content {
background-color: #fefefe;
margin: 15% auto; /* 15% from the top and centered */
padding: 20px;
border: 1px solid #888;
width: 80%; /* Could be more or less, depending on screen size */
}
.close {
color: #aaa;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: black;
text-decoration: none;
cursor: pointer;
}
Javascript:
// JavaScript
document.getElementById('open-modal').onclick = function() {
document.getElementById('modal').style.display = 'block';
};
document.getElementsByClassName('close')[0].onclick = function() {
document.getElementById('modal').style.display = 'none';
};
// Close the modal if the user clicks outside of it
window.onclick = function(event) {
if (event.target == document.getElementById('modal')) {
document.getElementById('modal').style.display = 'none';
}
};
You would just replace the text with an iframe link to the page where your form is located (on a page without a layout).