Jump to content

Text box value automatically change


soona

Recommended Posts

Hi JavaScript Experts,how to change text box value automatically ? when will give text box value from another input box?I gave code below.pls check . where i made mistake.----------------------------------------The javascript code as follows:<script language="javascript" type="text/javascript">function Fn_Add(){var first ="0"var second="0"var third="0"if(document.getElementById ("TextBox1").value!=""){first =document.getElementById ("TextBox1").value}else{document.getElementById("TextBox1").value="0"}if(document.getElementById ("TextBox2").value!=""){second=document.getElementById ("TextBox2").value}else{document.getElementById("TextBox2").value="0"}if(document.getElementById ("TextBox3").value!=""){third=document.getElementById ("TextBox3").value}else{document.getElementById("TextBox3").value="0"}document.getElementById ("TextBox4").value=parseInt(first)+parseInt(second) + parseInt(third)}</script>------------------------------------------Explanation:now i given Three(3) Textbox value add And Result display in TextBox4...suppouse you given TextBox1 & TextBox3 value(ex:100,200) but didn't given TextBox2 values in run time...TextBox2 value built in 0 automaticaly...At that time of running in webpage you make it to change Each & Every single digit value in any Textbox automaticaly change the Result value...With kind regardsNancy

Link to comment
Share on other sites

  • 3 weeks later...

If I understand the question, what's needed is a keydown handler. Add this to the script (not inside a function):document.getElementById("TextBox2").onkeydown = Fn_Add;I couldn't be sure if Nancy wanted such a gizmo for all 3 of the textinputs. If so, just add one like that for the other two.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...