将文本框中的数据复制到文本框MVC中的另一个数据。 [英] Copy data from textbox to another data in textbox MVC .
本文介绍了将文本框中的数据复制到文本框MVC中的另一个数据。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好我有两个这样的文本框
hi all I have two textbox like that
@Html.TextBox("Title",null, new { @class = "name_input", @id = "Title" })
@Html.TextBox("LongUrlText", "http://www.darwish.ps/"+ pageID + "/Details/" + Model.ID + (I need here to add the value which come from the textbox Title)"/" + Model.Title.ToSeoUrl(), new { @class = "name_input", @id = "LongUrlText", @readonly =
"readonly" })
我想将来自文本框标题的值添加到已经存在的数据中在文本框中LongUrlText请帮助我解答一下。
我尝试过:
我试图使用这个脚本,但它清除了文本框longurltext中的所有数据,我不想清除数据,我只是想完成从标题文本框到它的数据。
I want to add the value whih come from textbox Title to the data which already existed in textbox LongUrlText help me please to ahcieve that .
What I have tried:
I tried to use use this script but it clear all data from the textbox longurltext and I don't want to clear data I just want to complete the the data which come from Title textbox into it .
@*<script>
document.getElementById("Title").onkeyup = function () {
document.getElementById("LongUrlText2").value = this.value;
};
</script>*@
推荐答案
试试这个
Try this
<script>
var initialValue = document.getElementById("LongUrlText2").value;
document.getElementById("Title").onkeyup = function () {
document.getElementById("LongUrlText2").value = initialValue + this.value;
};
</script>
这篇关于将文本框中的数据复制到文本框MVC中的另一个数据。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文