我正在尝试制作表格。输入中插入的数据应自动填写文本。该表格将包括决策树。每个答案都会显示新问题,依此类推。
我尝试根据选定的单选按钮(jquery)附加div,但是当我尝试升级为越来越多的问题(一个更大,更复杂的决策树)时遇到问题。
我该怎么做,并使其可扩展?您的任何代码或有用的链接都将很棒。
以下是向您展示想法的摘录
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="toadd">
<p>1. Do you have a dog?</p>
<label>Yes</label><input type="radio" class="first" name="something" />
<label>No</label><input type="radio" class="second" name="something" />
<p><b>1.1</b> (* If you have a pet) How did you get it?</p>
<label>It was a gift</label><input type="radio" class="first" name="something1" />
<label>I bought it</label><input type="radio" class="second" name="something1"/>
<p>1.1.1 (* If it was a gift) Who have it yo tou?</p>
<input type="text" class="first" />
<p>1.1.2 (* If you bought it) Where did you buy it?</p>
<input type="text" class="first" />
<p><b>1.2.</b> (* If no pet) Why dont you have a pet?</p>
<input type="text" class="first" />
<p>---</p>
<p>Acordding to options, next text will be completed (preferably appeding p's )</p>
<p>You have a pet / You don't have a pet</p>
<p>It was a gift / You bought it</p>
<p>XXX gave it to you / You bought it at XXX</p>
<p>...</p>
<span class="pet"></span>
</div>