CGI (and CGI.pm) code runs solely on the server, so it has no interaction with what the user sees unless new data or a new document is fetched from the server.
The specific property I tend to use for dynamic control of visibility is the CSS "display" property:
<input type=text name=field1 onChange='document.getElementById("peekab
+oo").style.display = "block"'>
<div id='peekaboo' style='display: hidden'>
<input type=text name=field2>
This should (untested code) cause the peekaboo
div (and its contained field2
text field) to appear when text is entered into field1
back and forth between hidden
based on the content of field1
using whatever criteria you have in mind.