简体   繁体   English

如何使用javascript将文本框的值传递给模式中的另一个文本框?

[英]how to pass value of textbox to another textbox in a modal using javascript?

I have a textbox in my page, what I want is to do some sort of "preview" using a modal, but i cannot display the value of textbox which I put the information i need. 我的页面上有一个文本框,我想要使用模态进行某种“预览”,但是我无法显示文本框的值,而这正是我需要的信息。 Can someone help me? 有人能帮我吗?

I use javascript in doing this, but my modal displays empty textbox. 我在执行此操作时使用了javascript,但我的模式显示为空文本框。

$('#<%= txtDetails.ClientID %>').on('change', function () {
   $('input[id$="txtKBDecription"]').text($(this).val()); 
}); 
$('#<%= txtIssue.ClientID %>').on('keyup', function () {
   $('input[id$="txtKBSummary"]').text($(this).val()); 
}); 
$('#<%= area.ClientID %>').on('change', function () {
   $('input[id$="txtKBResolution"]').text($(this).val()); 
});

Really need more specifics, but essentially you're going to grab the value form one and put it in the other whenver it changes. 确实需要更多细节,但是从本质上讲,您将在任何时候更改它来获取值,然后将其放在另一个中。

this goes in your preview modal 这进入您的预览模式

<input type="text" id="preview" onchange="Copy();">

and this one goes in your final modal 这是你最后的模态

<input type="text" id="final">

and code... 和代码...

<script>
function Copy()
{
    document.getElementById("final").value = document.getElementById("preview").value;
}
</script>

though it should really be something closer to 虽然确实应该更接近

<script>
function Copy()
{
    var previewValue = document.getElementById("preview").value;
    if(previewValue != "" /* Or Other Validation */)
         document.getElementById("final").value = previewValue;
}
</script>

you should also consider checking to make sure the elements exist if you are planning on having other people edit the page and/or to make it more robust. 如果您打算让其他人编辑页面和/或使其更加健壮,则还应考虑检查以确保元素存在。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 获取文本框的值,然后传递给另一个模式 - Get the value of textbox then pass to another modal 如何将文本框值传递给JavaScript? - How to pass textbox value to JavaScript? 使用超链接将值传递到文本框(在另一页上) - Pass value into a textbox (on another page) using a hyperlink 如何将一个页面的文本框值传递到另一个页面的文本框? - How to pass textbox value from a page into a textbox in another page? 使用JavaScript将dropdownlist值传递到文本框 - Pass dropdownlist value to textbox using javascript 如何将文本框(不是文本框的值)传递给Javascript验证功能 - How to pass a textbox (not the value of textbox) to Javascript validate function 如何使用 javascript 将预设值为 0 的数字文本框的值获取到另一个文本框 - How to get the value of a numeric textbox that has a preset value of 0 to another textbox using javascript 如何从一个模态窗口文本框获取值并将其放到另一个模式窗口中的另一个文本框中? - How to get value from one modal window textbox and put it to another textbox in another modal window? 如何将html文本框值传递给javascript函数 - How to pass html textbox value to a javascript function 如何将javascript textBox值作为参数传递给URL - How to pass javascript textBox value to URL as parameter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM