By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,751 Members | 1,216 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,751 IT Pros & Developers. It's quick & easy.

how to hide/show a text box using drop downlist in php

P: 1
how to hide/show a text box using drop downlist in php
Feb 29 '08 #1
Share this Question
Share on Google+
2 Replies


hsriat
Expert 100+
P: 1,654
how to hide/show a text box using drop downlist in php
Please give some details?
Feb 29 '08 #2

nathj
Expert 100+
P: 938
how to hide/show a text box using drop downlist in php
Hi,

Define the list box with an onchange event handler that calls the function below. Next to the list box have the text box with the style set to display:none and with a unique ID.

The onchange then calls this JavaScript function:
Expand|Select|Wrap|Line Numbers
  1. function toggleDisplayState(poObjectToDisplay)
  2. {                                                         
  3.  
  4.     var loObject = document.getElementById(poObjectToDisplay);
  5.  
  6.     //test the current state of the object and toggle opposite state.
  7.     if (loObject.style.display != '' && loObject.style.display != 'none') 
  8.     {
  9.         loObject.style.display = 'none';
  10.       }
  11.     else 
  12.     {
  13.         loObject.style.display = 'inline';
  14.       } 
  15. }
  16.  
  17.  
This will toggle the display stae of the object ID you pass in. If you only want to change the ste depending no the value of th list box then you need to adjust the IF accordingly. this sghould be a enough of a basic premise for you.

Cheers
nathj
Feb 29 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.