Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Revealing/Enabling a text box via PHP commands 1

Status
Not open for further replies.

nedstar1

IS-IT--Management
Mar 2, 2001
127
US
Hi folks,

I've got an extensive site going live in a few days, and I am in the process of cleaning up loose ends. I ran the site past the clients, and they seemed, pleased, asking for slight tweaks here and there. One of the things they asked for is new to me, and search as I might, I can't find a solution.

I have a drop-down box that can be used to add a degree designation, to the end of a Doctor's name, like Bobby McGillicutty, MD PhD FACC etc. You get the point. However, there are a gazillion different degree designations and combinations of designations out there. The vast majority of the doctors will have MD or MD PhD, and I've included RN and RN BSN in case nurses are part of the program.

So what I think would work is one of two things, neither of which is proving feasible at present"

Include an "other" option in the drop-down; when selected, it will either turn the drop-down field into a text box (option a) or reveal a hidden or grayed out text box to the right of the drop-down (option b). Naturally, option a is sexy, and option b is probably a lot more workable. My problem is that I can't find code to disable or enable fields. I know it can be done, becasue I see it in my Plesk installation.

Anyone got a command I can check out? Anyone done this?

TIA folks.

Regards,
Nedstar1
 
Without reloading the page, there is no way to do this using PHP. The actions you describe, such as activating/deactivating a form field, will have to happen in some kind of client-side scripting language.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Thanks for the reply. I think you just answered my next question: since you can set the visibility of a class to hidden, I take it by this that you cannot set the class of a form object without reloading the page as well?

I was thinking of trying to embed an if...else snippet in the class statement based on the selected value in the drop-down, but the only way I think I could make it submit is by having the drop-down in a seperate form . . .

Anyone else have any thoughts?

TIA, folks, and thanks again, sleipnir214.

Regards,
Nedstar1
 
If you want the page to react to a user's actions, but you don't want to or can't reload the page, client-side scripting is the only solution.

You can use PHP to dynamically produce some JavaScript, but that's about as far as it goes. By the time the page is rendered, any connection between your client's browser and the PHP on the engine on the server is long broken.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
I understand. And if I'd thought about it, I'd have realized the bit about the connection between the server and the client. All the PHP is done before the page ever reaches the client, right?

I'll look into javascript. Thanks again.

Regards,
Nedstar1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top