Click here to Skip to main content
15,908,661 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
hi,

i am giving some value in textbox1 (take for example vishal). so, when i give tab, it(vishal) should assign in textbox2.

so, i used the following in aspx and java script:

aspx:
HTML
onchange="getval()"


javaScript
JavaScript
function getval() {
    var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
    document.getElementById("<%=textbox2.ClientID %>").value = document.getElementById("<%=textbox1.ClientID %>").value;
}


It works correctly in chrome . but, not working in firefox. pls help me out.
Posted
v2

Hi,

You mean to say when textbox1 loose focus, value should be bind to textbox2. Right?

If yes then,
JavaScript
<script>
 //if you have add jquery file in your page
 $('#<%= textbox1.ClientID %>').blur(function(){
    $('#<%= textbox2.ClientID %>').val($('#<%= textbox1.ClientID %>').val());
 });
 </script>



JavaScript
  // if you are using only javascript

  add onBlur='copyvalue(this)' in text box
<script>
 function copyvalue(e)
 {
    document.getElementByID('#<%= textbox2.ClientID %>').value = document.getElementByID('#<%= textbox1.ClientID %>').value;
 }
</script>



This should work in all browser.
 
Share this answer
 
You are not using keyCode, please remove it, rest should be working fine.


Thanks,
Ambesha
 
Share this answer
 
Please contact me from mail (842374669@qq.com)
 
Share this answer
 
Comments
[no name] 2-Aug-13 8:06am    
This is not an answer bro. If you can help him then please help him personally not like this. This is a forum not your home to play around.
christhuxavier 2-Aug-13 8:25am    
hi, simple solution.


if we remove var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;

now works fine...
hi, simple solution.


if we remove var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;

now works fine...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900