Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript">
- function subtractValues(inpt1, inpt2)
- {
- var txt_one = document.getElementById('text1').value;
- var txt_two = document.getElementById('text2').value;
- if(txt_one == ""){txt_one = 0;}
- else{ txt_one = parseFloat(txt_one); }
- if(txt_two == ""){txt_two = 0;}
- else{ txt_two = parseFloat(txt_two); }
- var result = txt_one - txt_two;
- return document.getElementById('text3').value = result;
- }
- </script>
- <form id="form1" name="form1" method="post" action="">
- <p> </p>
- <p> </p>
- <p> </p>
- <p> </p>
- <p>
- <label>Text1
- <input name="text1" type="text" id="text1" value='50' onkeyup="Javascript: subtractValues('text1', 'text2');"/>
- </label>
- </p>
- <p>
- <label>Text2
- <input name="text2" type="text" id="text2" value='0' onkeyup="Javascript: subtractValues('text1', 'text2');"/>
- </label>
- </p>
- <p>
- <label>Text3
- <input name="text3" type="text" id="text3" value="" />
- </label>
- </p>
- <p> </p>
- <p> </p>
- <p> </p>
- <p> </p>
- <p> </p>
- <p> </p>
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement