Radio button

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
raygo22
Forum Newbie
Posts: 5
Joined: Sun Oct 05, 2008 1:48 pm

Radio button

Post by raygo22 »

Hello. I am a newbie in the php world! but this is what I want to accomplish:

Two radio buttons, male and female. If male is pressed some input fields will appear concerning men, and if female is pressed then the input fields that will appear are related to women. Can somebody help me?! thanks!
phppucci
Forum Newbie
Posts: 17
Joined: Fri Oct 03, 2008 2:27 pm

Re: Radio button

Post by phppucci »

if 'some fields' should appear/disappear according to radio button selection without page refreshing, the only way is using javascript or javascript framework, say jquery.com or similar.
raygo22
Forum Newbie
Posts: 5
Joined: Sun Oct 05, 2008 1:48 pm

Re: Radio button

Post by raygo22 »

Thanks for your quick response. How about with page refreshing. How can i do it? Thanks
phppucci
Forum Newbie
Posts: 17
Joined: Fri Oct 03, 2008 2:27 pm

Re: Radio button

Post by phppucci »

Raygo, do it using javascript, read a bit about jquery at jquery.com, it is perfect tool for manipulating html page elements.
raygo22
Forum Newbie
Posts: 5
Joined: Sun Oct 05, 2008 1:48 pm

Re: Radio button

Post by raygo22 »

Hello. I was reading and couldnt find something useful. I dont know if it is that i am too new!! can you please help me with this code? thanks
efortis
Forum Newbie
Posts: 7
Joined: Mon Oct 13, 2008 7:48 pm

Re: Radio button

Post by efortis »

If you don't want to learn js just do 2 different pages, and then use links pointing to each one.

but try learning some: google for onClick event
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: Radio button

Post by omniuni »

If you want, you can either go with a page refresh (a href="?gender=male") or if you object to a refresh, create an iFrame which you can target with the links and load the questions to be answered into the iFrame.

Otherwise, some simple Javascript.... innerHTML.replace or something..... I don't do much javascript.

Good Luck,
OmniUni
Post Reply