Jump to content

[SOLVED] Follow up questions appearing based on answers to previous questions


tqla

Recommended Posts

I'm building a survey in php. I have no code to show. I just want to know if something is possible first.

 

Is it possible to have a question hidden and appear only when a certain question is answered a certain way.

 

For example. If the user answers yes to a question can a follow up question automatically appear. I mean automatically, without clicking a submit button?

 

I think this is what AJAX is all about but I just want to use PHP.

 

Thanks.

This can be done with JavaScript. You can put the "hidden" question between <div> tags, then toggle the visibility depending on what they answered to the previous question.

 

ajax in some form is a must be no matter what language you use

 

How is that? I don't understand how it is a must, I have never used any AJAX (at least not intentionally) on any websites I have done. I am curious to what your reasoning behind this is.

 

 

This can be done with JavaScript. You can put the "hidden" question between <div> tags, then toggle the visibility depending on what they answered to the previous question.

 

ajax in some form is a must be no matter what language you use

 

How is that? I don't understand how it is a must, I have never used any AJAX (at least not intentionally) on any websites I have done. I am curious to what your reasoning behind this is.

 

 

 

=) The reason I stated it is a must, is if he has questions that need to be displayed based on how they are answered, chances are a "hidden" div wouldn't work because you would need every single question with answer on the page. If he has 1,000 questions, well what would the page size be like? As appose to AJAX he can make a request back and pull the new question so the page load is very small and manageable.

 

I can be done with javascript, but as stated above it depends on how many questions etc whether it is feasible. If he only has 10 questions, than great javascript is the answer. Judging by the nature of the question I think he has more than just a handful of questions. That and doing the hidden div, you are already working with javascript, so why not just extent it a bit and use Ajax ?

 

=)

Hi pocobueno and frost110. Thank you both for answering my question.

 

pocobueno, that's a great idea! I've already ran some tests and it works well.  ;D

 

frost110, I'm sure AJAX is awesome too but I don't even know how to get started. :( I wish I did. Hopefully someday. 

 

Thanks again to you both!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.