Good afternoon, help solve the problem, you need to make something like a social questionnaire on the site, the site asks, and the user responds (you just need the string version, no buttons, other fields, etc.), because I just started working with js and tp today, a bunch of questions right away. I started to do with textarea, display the text, but how to count the last one? Tobish, you can like to read like this:

var tex=document.getElementById('tt').value; 

but it will take all. Here is what I told you:

 <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Стили</title> </head> <body> <div class="fixed-textarea"> <textarea name ="tt" id="tt" style="height: 100%;width: 100%;" > </textarea></div> <script language="JavaScript"> var text = '>> Сколько лет земле ? \r\n >> ' var i=0; function type(){ i++; if( i <= text.length ) document.getElementById("tt").innerHTML = text.substr(0, i); setTimeout( type, 50 ); } function one(){ var k= Math.random(); var tex=document.getElementById('tt').value; setTimeout( type, 10 ); } type(); </script> </body> </html> 
  • And what in your understanding will be considered the end of the next entered line? Pressing the "Enter" button? So the respondent can, after each letter Enter, press or by mistake press this key. In general, even though you just started learning JS, but still look for more realistic ways for your task. - Deonis
  • Isn't it easier to style textarea with input? - Jean-Claude
  • @Deonis "Pressing the" Enter "button" yes, "So the respondent can press Enter by mistake or press this key after each letter." forgot to add that you still need to compare the answer, and then you will give an error to him, "look for more realistic ways for your task" can you tell ?, "is it not easier to style with textarea?" can be more ? I do not vkurse at all) if I understand correctly, it will not look very nice and is not convenient, although ... can you tell in more detail? - Lolidze
  • 3
    About the “beauty” and about all the “buns”, at the prepubertal stage of study, it is rather early for you to think - this is my personal opinion. Sketched you the most simple code , which I hope will help you a little bit to move forward in the development of JS. - Deonis

0