[英]How to pass the value of the text box to the disabled text box using javascript
我有一個文本框,我們將在文本框中輸入值,輸入時需要使用javascript將其添加到禁用的文本框中
謝謝,Vara Prasad.M
如果您希望它在輸入文本時更改禁用的輸入,則服務器端解決方案絕對不是正確的選擇,因為實時回發是不可行的。 這是使用jQuery的客戶端:
$("#abledtextbox").live({
keyup: function(){
$("#disabledtextbox").val($(this).val())
}
});
你可以使用jQuery嗎?
$("#idOfSecondTextbox").blur( function() {
$(#idOfSecondTextBox).val( $("#idOfFirstTextBox").val() );
});
由於您不要求使用jQuery,因此這里提供了一個簡單的JavaScript解決方案:
function setValue(inputId, value)
{
document.getElementById(inputId).value = value;
}
和HTML:
<input id="text1"
onkeyup="setValue('text2', this.value)"
onchange="setValue('text2', this.value)" />
<input id="text2" />
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.