开发者

How to pass the value of the text box to the disabled text box using javascript

I am having the text box where we will enter the value in the text box and while entering the value needs to be added to the disable开发者_JS百科d text box using javascript

Thanks, Vara Prasad.M


If you want it to change the disabled input as you enter text, a server side solution is definitely not the right move because posting back in real time is not feasible. Here's something client side using jQuery:

$("#abledtextbox").live({
    keyup: function(){
        $("#disabledtextbox").val($(this).val())
    }
});


can you use jQuery?

$("#idOfSecondTextbox").blur( function() {
  $(#idOfSecondTextBox).val( $("#idOfFirstTextBox").val() );
});


Since you didn't ask for jQuery, here's a plain JavaScript solution:

function setValue(inputId, value)
{
    document.getElementById(inputId).value = value;
}

And the HTML:

<input id="text1"
    onkeyup="setValue('text2', this.value)"
    onchange="setValue('text2', this.value)" />
<input id="text2" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜