Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6005863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:27:28+00:00 2026-05-23T01:27:28+00:00

I have a web form where users answer questions via dropdowns, and I wish

  • 0

I have a web form where users answer questions via dropdowns, and I wish to make other questions available based on their responses.

e.g. if your business has a premises then ask about opening hours. If they don’t, show the regions they operate in.

With each question I add to the process, the more complex the code becomes. A lot of if/then functions that don’t always have mutually exclusive answers.

Whilst each user may only have to answer 5-10 questions, the number of possible questions can be 100+.

Is there a simple way to generate either Javascript/PHP or at the very least pseudo code which lets you plot a path through all the available answers and it generates the relevant nested if/then statements for you?

Example: Akinator guesses TV characters based on previous answers.

In anticipation of certain responses, of course the page doesn’t have to be coded so that all questions are answered on one page, but I want to know if it’s at least possible.

Thanks in advance. I hope you all enjoy WWDC 😉

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T01:27:29+00:00Added an answer on May 23, 2026 at 1:27 am

    You can set up a json object on the page that contains all of the rules and on each element have an id/attribute that corresponds to the json object. Then on change you check the json object for a “trigger” node that corresponds to the “change” element’s attribute and then find all the elements that should be hidden/shown based upon that value. Note this code is really rough and not an exact answer but enough of an idea to get you started.

    <select id='q1' onchange='handleHideShow(this)'></select>
    <select id='q2' onchange='handleHideShow(this)'></select>
    
    function handleHideShow(el)
    {
        var elValue = el.value;
        if(hsObj[el.id])
        {
           var rules = hsObj[el.id].rules;
           for(var r = 0; r < rules.length; r++)
           {
               var rRule = rules[r];
               for(var t in rRule) 
               { 
                   var showEl = document.getElementById(rRule[t]);
                   if(showEl)
                   {
                        var hideVal = "";
                        if(elValue != t)
                        {
                            hideVal = 'none';
                        }
                        showEl.styles.display = hideVal;
                    }
                }
            }
        }               
    }
    var hsObj = [
       "q1":{"Yes":"q2"}
    ];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have got a setup where users can either use a web-based form or
I have a web form that has multiple ListBoxes, TextBoxes, DropDowns. If I put
I have a web form that users can fill out and that content fills
I have an ASP.NET web form which I am adding a variable number User
I have a web report that uses a Django form (new forms) for fields
I have a simple webform that will allow unauthenticated users to input their information,
I have a web form that binds a DataGrid to a, normally, different data
I have a web form that I am attempting to implement dynamic drop down
Say you have a web form with some fields that you want to validate
I have a basic test web form with a DataList and a DetailsView and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.