How To Connect Javascript and HTML Form

That's simple. Every HTML element has a name, accessible from Javascript. Every HTML form element has a value, which you can get or change. And HTML elements has event reaction parameters in their tags. So, see example:

This form gets the value from filed 1 and passes it to the field 2 with a small change:

And here is the code to implement this:

<html> <head><title>How To Connect Javascript and HTML Form (1)</title> <script language="JavaScript"><!-- function pass() { document.a.out0.value = " --- " + document.a.in0.value + " --- "; } //--> </script> </head> <body> ... <form name=a action="x.htm"> <input type=text name=in0> <input type=text name=out0> <input type=button value="Try" onClick="pass();"> </form> ... </body> </html>