There is such a code, it is necessary that after answering a message another question appears with a field for an answer. Help me please.

<script> $(document).ready(function(){ $("p").append( $("strong") ); }); </script> <p>Привет! Как тебя зовут?</p> </script> <input type="text" id="input" /> <script type="text/javascript"> function sow(){ var a; a=document.getElementById("input").value if (a=='Леонид') { $("p").append("<p>Приятно</p>"); return false; } else{ $("p").append("<p>Приятно</p>" +a); } } </script> <input class="box" type="button" id="sub" name="submit" value="Отправить" onClick="return sow();"> 

    1 answer 1

     <div id="question">Привет как тебя зовут?</div> <input type='hidden' name="answer" id="answer" value='1'> <input type="text" name="message" id="message"> <button id="send">Отправить</button> $('#send').click(function(){ mes = $("#message").val(); ans = $("#answer").val(); switch(ans){ case '1': if(mes=='Леонид') $("#question").html('Очень приятно, а как у тебя дела?'); else $("#question").html('Приятно, а как у тебя дела?'); $("#answer").val('2'); break; case '2': if(mes=='Хорошо') $("#question").html('У меня тоже хорошо'); else $("#question").html('Хочешь покушать?'); $("#answer").val('3'); break; //и т. д. сколько хочешь вопросов } }) 
    • Please try to write more detailed answers. I am sure the author of the question would be grateful for your expert commentary on the code above. - Nicolas Chabanovsky