Results 1 to 3 of 3

Thread: Complex website form

Hybrid View

  1. #1
    Join Date
    Oct 2013

    Complex website form

    Hi, I'm wondering how I can go about and how difficult it would be to create a form for users which takes them to a specific page based on the combination of answers they give on multiple questions (yes/no answer questions).

    It will be similar to this one, but a lot less complex, with fewer questions: https://debtremedy.stepchange.org/quickassessment.aspx.

    Here is how I want it to work:

    There are 12 different questions, all with the option of yes or no. Once the user has answered all of the questions on the form (which are about personal debt), the website will take them to a page which gives them the appropriate debt advice.

    There are 14 different pieces of Debt Advice. Sometimes, depending on how the user answers, all of these pieces of advice will be appropriate and will need to appear on the page which appears after they finish the form. However, if the user answers yes to question 1, this will rule out Debt Advice piece number 5, 8, and 12, and if they answer yes to question 2 then the program will rule out Debt Advice number 2, 7, and 10 (if they answered no then it would not rule these out).

    So in this way, the answers they give to the questions will determine the information which will appear on the page that results after they have finished the form.

    How would one go about creating/programming such a form?

    Any advice or comments would be much appreciated.


  2. #2
    Join Date
    Mar 2012
    Sounds like a job for PHP. Roughly, it would be something like...

    <meta charset="iso-8859-1">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <title>Form Test</title>
    <link href="style.css" rel="stylesheet" type="text/css">
    <div id="header">
    <h1>Debt questionnaire</h1>
    if(isset($_POST['submit'])) {
    $q1 = $_POST['q1']; 
    $q2 = $_POST['q2']; 
    $q3 = $_POST['q3']; 
    $q4 = $_POST['q4']; 
    <!-- para 1 -->
    &nbsp;(para 1) Blah, blah, blah</p>
    <!-- para 2 -->
    <?php if($q2<>'y') {?>
    &nbsp;(para 2) Blah, blah, blah</p>
    <?php ;} ?>
    <!-- para 3 -->
    &nbsp;(para 3) Blah, blah, blah</p>
    <!-- para 4 -->
    &nbsp;(para 4) Blah, blah, blah</p>
    <?php if($q1<>'y') {?>
    <!-- para 5 -->
    &nbsp;(para 5) Blah, blah, blah</p>
    <?php ;} ?>
    <!-- para 6 -->
    &nbsp;(para 6) Blah, blah, blah</p>
    <form method=POST action="#">
    <input type="submit" value="clear"> 
    <?php ;} else {
    $q1 = ' '; 
    $q2 = ' '; 
    $q3 = ' '; 
    $q4 = ' '; 
    <form method=POST action="#">
    <label>&nbsp; Question 1... <input type="text" name="q1" size="1" maxlength="1" value=" "></label><br>
    <label>&nbsp; Question 2... <input type="text" name="q2" size="1" maxlength="1" value=" "></label><br>
    <label>&nbsp; Question 3... <input type="text" name="q3" size="1" maxlength="1" value=" "></label><br>
    <label>&nbsp; Question 4... <input type="text" name="q4" size="1" maxlength="1" value=" "></label><br>
    <br><input type="submit" name="submit" value="submit"><br>
    <?php ;} ?>
    Note: The example has only four questions and six paragraphs of advice, but it should be sufficient to show the idea. Also, there is no validatiion of the input, and it only recognises "y" not "Y". So an actual site would need some tidying up.

    The page needs to be called something like "debt.php" (not "debt.html") and must be placed on a server that supports PHP code. It may then be called via a shortcut. e.g. If you are testing it on a local host like Wampserver: "target=http://localhost/debt.php".

  3. #3
    Join Date
    Oct 2013
    Thanks a lot for your reply, this is a big help. Much appreciated.


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center