Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialben pines
8,389 PointsI created a diet questionnaire. Can I put the form inside a slider?
http://benpines.todaydiet.co.il/projects/index.php
here's the code of the calculation page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Diet Test</title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
</head>
<body>
<div id="page-wrap">
<h1>Diet Test</h1>
<?php
$answers= array();
$diets=array();
$rice=0;
$medeterenian=0;
$pleo=0;
for ($i = 1; $i <= 4; $i++) {
$current=$answers[$i];
$current=$_POST['question-'.$i.'-answers'];
echo ("value of this: ".$current. "<br />");
switch ($current) {
case 'rice':
$rice++;
break;
case 'med':
$medeterenian++;
break;
case 'pleo':
$pleo++;
break;
}
}
if ($rice>$medeterenian and $rice>$pleo) {echo "rice";}
elseif ($medeterenian>$rice and $medeterenian>$pleo){echo "medeterenian";}
else echo 'pleo';
?>
</div>
</body>
</html>
and the index page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Diet Test</title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
</head>
<body>
<div id="page-wrap">
<h1>Diet Test</h1>
<form action="grade.php" method="post" id="quiz">
<ol>
<li>
<h3>How much money are you willing to spend?</h3>
<div>
<input type="radio" name="question-1-answers" id="question-1-answers-A" value="rice" />
<label for="question-1-answers-A">Not much.</label>
</div>
<div>
<input type="radio" name="question-1-answers" id="question-1-answers-B" value="med" />
<label for="question-1-answers-B">Some money.</label>
</div>
<div>
<input type="radio" name="question-1-answers" id="question-1-answers-C" value="pleo" />
<label for="question-1-answers-C">As much as it takes.</label>
</div>
</li>
<li>
<h3>How much time are you willing to invest in the diet?</h3>
<div>
<input type="radio" name="question-2-answers" id="question-2-answers-A" value="rice" />
<label for="question-2-answers-A">Not much.</label>
</div>
<div>
<input type="radio" name="question-2-answers" id="question-2-answers-B" value="med" />
<label for="question-2-answers-B">Some time.</label>
</div>
<div>
<input type="radio" name="question-2-answers" id="question-2-answers-C" value="pleo" />
<label for="question-2-answers-C">As much as it takes.</label>
</div>
</li>
<li>
<h3>What is the rate of weight loss that you wish to have?</h3>
<div>
<input type="radio" name="question-3-answers" id="question-3-answers-A" value="rice" />
<label for="question-3-answers-A">Fast pace weight loss.</label>
</div>
<div>
<input type="radio" name="question-3-answers" id="question-3-answers-C" value="pleo" />
<label for="question-3-answers-C">A normal rate.</label>
</div>
<div>
<input type="radio" name="question-3-answers" id="question-3-answers-B" value="med" />
<label for="question-3-answers-B">A slow long term diet.</label>
</div>
</li>
<li>
<h3>What concessions are you willing to take for the diet?</h3>
<div>
<input type="radio" name="question-4-answers" id="question-4-answers-B" value="med" />
<label for="question-4-answers-B">No concessions.</label>
</div>
<div>
<input type="radio" name="question-4-answers" id="question-4-answers-C" value="pleo" />
<label for="question-4-answers-C">I'll give up carbs and sugars.</label>
</div>
<div>
<input type="radio" name="question-4-answers" id="question-4-answers-A" value="rice" />
<label for="question-4-answers-A">Whatever it takes.</label>
</div>
</li>
</ol>
<input type="submit" value="Submit Quiz" />
</form>
</div>
</body>
</html>
Can I put this form in a slider, and how?
1 Answer
thomascawthorn
22,986 PointsCan you explain a little more about what you mean by slider?
ben pines
8,389 Pointsben pines
8,389 PointsThe form takes the answer and calculates which of 3 diets gets the most score: rice diet, meddeterenian diet and pleo diet.