我有一个文本字段,如果我单击该文本字段,则会显示一个模式弹出窗口,并带有文本字段“ Enter here”。现在,如果在此处输入一些文本,然后单击 '确定',该文本应显示在第一个文本输入字段中。
我尝试过,但是没有用。这是我失败的小提琴。.
<!-- Input field -->
<input type="text" id="address" placeholder="Enter here" class="form-control" name="address" data-toggle="modal" data-target="#narratModal" />
<!-- text popup modal -->
<div class="modal fade" id="narratModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close cash-dismiss" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title modal_head" id="myModalLabel">Narration</h4>
</div>
<div class="modal-body">
<label class="modal_note">Note: Only alphabets A-Z a-z number 0-9 and characters % [] () - _ . , are allowed in text</label>
<textarea class="cash_text">
Enter Here...
</textarea>
<span class="modal_valid">0/200 Characterts entered</span>
</div>
<div class="modal-footer narr_footer">
<button type="button" class="btn btn-primary cashmodal_btn">OK</button>
</div>
</div>
</div>
</div>
答案 0 :(得分:0)
您可以使用Javascript执行此操作。将id
添加到按钮和文本区域。然后,当单击按钮时,在输入中显示文本区域的值。例如:
document.getElementById('ok_button').addEventListener('click', function () {
document.getElementById('address').value = document.getElementById('cash_text').value
})
<input type="text" id="address" placeholder="Enter here" class="form-control" name="address" data-toggle="modal" data-target="#narratModal" />
<div class="modal fade" id="narratModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close cash-dismiss" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title modal_head" id="myModalLabel">Narration</h4>
</div>
<div class="modal-body">
<label class="modal_note">Note: Only alphabets A-Z a-z number 0-9 and characters % [] () - _ . , are allowed in text</label>
<textarea id="cash_text" class="cash_text">Enter Here...</textarea>
<span class="modal_valid">0/200 Characterts entered</span>
</div>
<div class="modal-footer narr_footer">
<button id="ok_button" type="button" class="btn btn-primary cashmodal_btn">OK</button>
</div>
</div>
</div>
</div>