[英]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.