簡體   English   中英

將數據從頁面上的文本框傳遞到彈出窗口上的文本框

[英]Passing data from textbox on the page to textbox on popup

我的頁面上有一個包含文本框和按鈕的表單。 我有一個包含文本框,驗證碼和按鈕的引導彈出窗口。

問題1.我知道如何處理從彈出窗口提交的數據。 我只需要知道如何將在(頁面的)文本框中輸入的數據傳遞到文本框(在彈出窗口中)。

問題2.單擊頁面上的按鈕並顯示彈出窗口后,它應該清除文本框(在頁面上)。

謝謝

因此,提交時處理頁面中的輸入表單。 您可以在提交表單時調用javascript函數。 在該函數中,將彈出窗口的划分值重新分配給提交的數據,並從頁面中清除表格的划分數據。

有關語法以及如何處理表格,您可以訪問以下鏈接:

  1. https://www.w3schools.com/js/tryit.asp?filename=tryjs_form_elements

  2. https://www.w3schools.com/js/js_input_examples.asp

我曾經有過類似的問題。 您可以使用jquery從文本框中獲取值並將其放置在模式(彈出窗口)文本框中。

 <html> <head> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <!--the JQuery to grab the value and change the textbox--> <script> $(document).ready(function () { $('#page-button').click(function () { $('#modal-text').val($('#textbox').val()); $('#textbox').val(""); }); }); </script> </head> <body> <div class="container"> <!--textbox on main page--> <input id="textbox" type="text" /> <!--the following has been taken and edited from w3schools from Modals--> <!-- Trigger the modal with a button --> <button id="page-button" type="button" data-toggle="modal" data-target="#myModal">Open Modal</button> <!-- Modal --> <div class="modal fade" id="myModal" role="dialog"> <div class="modal-dialog"> <!-- Modal content--> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">&times;</button> <h4 class="modal-title">Modal Header</h4> </div> <div class="modal-body"> <!-- The Modal text box--> <input id="modal-text" type="text" /> </div> <div class="modal-footer"> <button id="close-button" type="button" class="btn btn-default" data-dismiss="modal">Close</button> </div> </div> </div> </div> </div> </body> </html> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM