PHP Code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
soumya_nht
Forum Newbie
Posts: 1
Joined: Mon Nov 13, 2006 5:34 am

PHP Code

Post by soumya_nht »

How can I make a input field hidden by clicking on a radio button of the same page??
This is bugging me a lot :x
Plz Hlp
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

You can use javascript to set the display attribute of that input field to hidden.
If you want to use php the client has to perform a complete new http request.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Post by califdon »

Since I have seen several similar questions in this forum, maybe it's a good idea to make a point here:

PHP is server side programming. Once the page has been sent to the browser, there's no more PHP in it, so it can't possibly know anything about what the user is doing in the browser!

If you want to detect user interaction and perhaps take some action based on it, you have to use browser side programming that runs after the page is sent to the browser. That calls for Javascript of VBScript.
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

Javascript can also make http requests to PHP scripts without the user experiencing a full page refresh by using the XMLHttpRequest object. It sounds like all you need though is to register a javascript onclick event to a function that sets the input's display property to hidden, as volka suggested.
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Post by impulse() »

You could try

Code: Select all

if ($_GET["<radio button name">] == "<radio button>") {
  echo "<input type = "hidden">";
}
Regards,
Post Reply