Adding question text areas

Adding question text areas

I have a button for adding new textarea for questions. My code add the new 6text area alright. The problem is if you enter something into one of the text areas then click on the button to add a new textarea what you have typed into any previous text areas vanishes. I have tried savign the content and addign the values back but that doesn't work. It still vanishes. What do I do please? This is my code - thanks






function add_question() {
           alert(row_count);
            row = row_count - 1
            
            var values = [];
            var i = 0;
            questions = document.getElementsByName("question");

                for (var i = 0; i < questions.length; i++) {

                    values.push(questions[i].value);
                }
            
            
            
            
            $( "#row" + row).after( "<tr id='row" + row_count +  "'><td style='width: 1%''><input name='B3' type='reset' value='Delete'></td><td style='width: 1%'><h3>Question</h3></td><td width='35%'><textarea cols='20' name='question' id='question' rows='5' style='width: 100%; color: #000000; font-family: Arial; font-size: 10pt'></textarea></td></tr>");
            new_questions = document.getElementsByName("question");
            for (var i = 0; i < new_questions.length - 1; i++) {
                alert("cccc");
                
                 new_questions[i].value = values[i];
                alert(new_questions[i].value);
                alert("dddd");
            }
        
            
            
            row_count = row_count + 1;                
        }



    • Topic Participants

    • info