Jump to content

How to build an interactive text?


Azurues

Recommended Posts

How could I build an interactive text system?

It should work like this:

Text is displayed.

1-3 options (a situational amount of them) to answer displayed.

Example:

Are you male?

Yes

No

 

You choose yes or no and it leads you to another questions based from your previous answer.

Example: (a follow up to the 1st one)

So you're male. Do you like cars then?

Answers.

And it goes on and on.

 

The thing I need help with is the answers. I need to show them based by the previous answer but don't know how, any help?

Link to comment
https://forums.phpfreaks.com/topic/236944-how-to-build-an-interactive-text/
Share on other sites

<div id="tut" style="background-image: url(images/chars/guide.png);"><div id="cwind">
<div id="tname">Guardian Robot</div><div id="sep"></div>
<div id="speech">
<?echo"$ttext[$ptut]";?></div></div><div id="ws"></div><form action="main.php" method="POST">
<button style="font-family: normal; font-size: 14px;" name="choice" value="1"
class="<?echo"$cl1[$ptut]";?>"><?echo"$choice1[$ptut]";?></button><div id="ws"></div>
<button style="font-family: normal; font-size: 14px;" name="choice" value="2"
class="<?echo"$cl2[$ptut]";?>"><?echo"$choice2[$ptut]";?></button><div id="ws"></div>
<button style="font-family: normal; font-size: 14px;" name="choice" value="3"
class="<?echo"$cl3[$ptut]";?>"><?echo"$choice3[$ptut]";?></button>
</form></div>

 

$ttext is a numerical array to display the text (the question). It is wrong since ptut is the number of answers taken (from a database).

$cl1,cl2,cl3 again are a numerical arrays which display a button or don't, it's wrong due to ptut being counted wrongly.

$choice1,2,3 are the choices displayed incorrectly.

 

I can't think of a better code and how to fix that. The problem is that ptut should be counted in some different way and I can't think of any.

<div id="tut" style="background-image: url(images/chars/guide.png);"><div id="cwind">
<div id="tname">Guardian Robot</div><div id="sep"></div>
<div id="speech">
<?echo"$ttext[$ptut]";?></div></div><div id="ws"></div><form action="main.php" method="POST">
<button style="font-family: normal; font-size: 14px;" name="choice" value="1"
class="<?echo"$cl1[$ptut]";?>"><?echo"$choice1[$ptut]";?></button><div id="ws"></div>
<button style="font-family: normal; font-size: 14px;" name="choice" value="2"
class="<?echo"$cl2[$ptut]";?>"><?echo"$choice2[$ptut]";?></button><div id="ws"></div>
<button style="font-family: normal; font-size: 14px;" name="choice" value="3"
class="<?echo"$cl3[$ptut]";?>"><?echo"$choice3[$ptut]";?></button>
</form></div>

 

$ttext is a numerical array to display the text (the question). It is wrong since ptut is the number of answers taken currently working: $ptut+the value of the button.

$cl1,cl2,cl3 again are a numerical arrays which display a button or don't, it's wrong due to ptut being counted wrongly.

$choice1,2,3 are the choices displayed incorrectly.

 

I can't think of a better code and how to fix that. The problem is that ptut should be counted in some different way and I can't think of any.

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.