Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: Show / hide text field in application

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

in reply to Show / hide text field in application

CGI (and 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 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 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?

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-23 01:56 GMT
Find Nodes?
    Voting Booth?

    No recent polls found