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.

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

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 ?

 

=)

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.