Imagine a scenario where you can:
1. Click on one of the divs (1, 2, 3).
2. Trigger a modal window to open.
3. Input text into the modal's text field.
4. Click the save button.
5. Witness that text being displayed in the .item-edit section of the div.
I have various div elements that activate a modal window with an input field. How can I ensure that the text I input gets transferred to the respective div?
I am attempting to send the text to the .item-edit
part of the div for submission.
Here is an illustration featuring multiple interactive divs that trigger a modal with text and submit inputs:
input[type=text], select {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
input[type=submit] {
width: 100%;
background-color: #4CAF50;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
border-radius: 4px;
cursor: pointer;
box-sizing: border-box;
}
<link href="https://www.w3schools.com/w3css/4/w3.css" rel="stylesheet"/>
<div onclick="document.getElementById('id01').style.display='block'" class="grid-item"><div class="box-number">1</div><div class="item-edit"></div><div class="null-object"></div></div>
<div onclick="document.getElementById('id01').style.display='block'" class="grid-item"><div class="box-number">2</div><div class="item-edit"></div><div class="null-object"></div></div>
<div onclick="document.getElementById('id01').style.display='block'" class="grid-item"><div class="box-number">3</div><div class="item-edit"></div><div class="null-object"></div></div>
<div id="id01" class="w3-modal">
<div class="w3-modal-content">
<div class="w3-container">
<span onclick="document.getElementById('id01').style.display='none'" class="w3-button w3-display-topright">×</span>
<p>Name</p>
<input type="text" id="fname" name="firstname" placeholder="Your name..">
<input onclick="document.getElementById('id01').style.display='none'" type="submit" value="SAVE">
</div>
</div>
</div>