Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Show / hide text field in cgi.pm application

by dsheroh (Monsignor)
on Jun 22, 2010 at 09:32 UTC ( #845867=note: print w/replies, xml ) Need Help??


in reply to Show / hide text field in cgi.pm application

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.

All client-side dynamic functionality has to be implemented in javascript, since that's the only way to run code natively in the user's browser. (Yes, there are plugins to run other languages in browsers, but javascript is pretty much the only thing you can count on having there. Maybe also flash, if you're only targeting desktops/laptops and not mobile devices.)

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> </div>
This should (untested code) cause the peekaboo div (and its contained field2 text field) to appear when text is entered into field1. From there, you should be able to work out the javascript logic to have it flip peekaboo.style.display back and forth between hidden and block based on the content of field1 using whatever criteria you have in mind.

Replies are listed 'Best First'.
Re^2: Show / hide text field in cgi.pm application
by ady (Deacon) on Jun 22, 2010 at 17:39 UTC
    Thanks dsheroh,

    In hindsight I can see, that javascript is the way to implement client side dynamic functionality in this scenario.
    - I can take it from there :)

    Best regards, - allan

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://845867]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2022-09-29 08:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer my indexes to start at:




    Results (125 votes). Check out past polls.

    Notices?