Skip to content
Advertisement

Linked Dynamic Radio Buttons HTML Javascript

All,

Have used this site a few times before and had some great replies so hopefully someone can help again. I want a set of radio buttons, so that when you click a button – you get another set below it. Then again, when you click one of the 2nd set of buttons, you’ll get a third etc. Currently I have the following:

JavaScript

So basically, i’m trying to make a little wizard – so something that will ask the user a question, and based on this – it will ask them another. I dont want to use server side applications so am trying something simple like this – but whenever the user selects an option from the 2nd set of buttons, the text which goes with it replaces the 2nd set of buttons. What am i doing wrong?

Please select ‘yes’ and ‘yes’ again to see what i mean. Any help will be appreciated!

Joe

Advertisement

Answer

Your if statement is wrong. You ask again and again this: if (question=="yes") h1.style.display="block"; else h1.style.display="none"; and the second time if is not true, so you set the h1 to be hidden.

here is one solution:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement