My objective is to put some information from one field into another field as the user types the characters. But I'm stuck at step one. At the moment I'm just trying to get the information from the first field (and then I'll try and work out how to put it into the second field) but the code below keeps showing a blank message box after I've typed 1 character.
So then I tried (looking for a non-blank field)...Code:<!DOCTYPE html> <html> <head> <title>TRIALJS</title> <script> function myFunction() { var valone = document.getElementById('txtone').value; alert(valone); } </script> </head> <body> <p>Some text.</p> <input type="text" id="txtone" onkeydown="myFunction()"> <br><br> <input type="text" id="txttwo"> </body> </html>
But this doesn't even create a message box. So what can I do to fix this? Thank you.Code:<!DOCTYPE html> <html> <head> <title>TRIALJS</title> <script> function myFunction() { var valone = document.getElementById('txtone').value; if valone != "" alert(valone); } </script> </head> <body> <p>Some text.</p> <input type="text" id="txtone" onkeydown="myFunction()"> <br><br> <input type="text" id="txttwo"> </body> </html>


Reply With Quote

