title: How to create multiple text area at the time of edit option using PHP and Javascript
body: <p>I need one help.I am creating multiple text area using <code>+</code> button and i need to do the same operation when edit option is also there using PHP and Javascript.I am explaining my code below.</p>
  
  <pre><code> &lt;div style="width:24%; float:left; padding:10px;"&gt;No of questions : 
       &lt;input name="no_of_question" id="ques" class="form-control" placeholder="no of question" value="&lt;?php if($_REQUEST['edit']) { echo $getcustomerobj-&gt;no_of_question; } else { echo $_REQUEST['no_of_question']; } ?&gt;" type="text" onkeypress="return isNumberKey(event)"&gt;
  
       &lt;div id="err_msg_name" style="font-size:12px; color:#FF0000; text-align: center;"&gt;&lt;/div&gt;
       &lt;/div&gt;
      &lt;div class="clear"&gt;&lt;/div&gt;
       &lt;div style="padding-bottom:10px;"&gt;
      Questions : &lt;input type="button" class="btn btn-success btn-sm" name="plus" id="plus" value="+" onClick="addQuestionField();"&gt;&lt;input type="button" class="btn btn-danger btn-sm" name="minus" id="minus" value="-" onClick="deleteQuestionField();"&gt;
      &lt;/div&gt;
      &lt;div id="container"&gt;
  
       &lt;div&gt;
       &lt;div style="width:24%; float:left; padding:10px;"&gt;
      &lt;textarea class="form-control" name="questions0" id="questions" placeholder="Questions"  style="background:#FFFFFF;"  rows="2"&gt;&lt;?php if($_REQUEST['edit']) { echo $getcustomerobj-&gt;questions; } else { echo $_REQUEST['questions']; } ?&gt;&lt;/textarea&gt;
      &lt;/div&gt;
  
      &lt;div style="float:left;margin-top:37px;"&gt;
      &lt;?php
  $status=array("status"=&gt;'1');
       $feeddata=$db-&gt;kf_answertype-&gt;find($ustatus);
      ?&gt;
      &lt;div style="float:left; margin-right:10px;"&gt;
      &lt;?php
      foreach($feeddata as $v){
      ?&gt;
      &lt;input type="radio" name="answer_type0" id="answer_type0" onClick="selectScale(this.value,'0');" value="&lt;?php echo $v['_id']; ?&gt;"&gt; &lt;?php echo $v['answertype'];  ?&gt; 
      &lt;?php
          }
      ?&gt;
      &lt;/div&gt;
      &lt;div style="float:left; margin-top:-10px;display:none;" id="scaleid0"&gt;&lt;select class="form-control" id="nscale0" name="noofscale0"&gt;
      &lt;option value=""&gt;Select Answer Type&lt;/option&gt;
      &lt;?php
  $status=array("status"=&gt;'1');
       $feeddata=$db-&gt;kf_scale-&gt;find($ustatus);
      foreach($feeddata as $v){
      ?&gt;
      &lt;option value="&lt;?php echo $v['_id']; ?&gt;" &lt;?php if($getcustomerobj-&gt;no_of_scale == $v['_id'] or $_REQUEST['no_of_scale'] == $v['_id']){ print 'selected'; } ?&gt;&gt;&lt;?php echo $v['noofscale']; ?&gt;&lt;/option&gt;                           
       &lt;?php } ?&gt;                 
      &lt;/select&gt;
      &lt;/div&gt;
      &lt;div style="clear:both;"&gt;&lt;/div&gt;                                                 
       &lt;/div&gt;
      &lt;div style="clear:both;"&gt;&lt;/div&gt;
           &lt;/div&gt;
  
       &lt;/div&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>my javascript function is given below.</p>
  
  <pre><code>&lt;script&gt;
   function addQuestionField(){
      var get =$("#ques").val();
      if(get==null || get==''){
          alert('Please add no of questions');
      }else{
          var counter = 0;
          if (counter &gt; 0){
              return;
          }else{
               counter++;
                &lt;?php
                     $status=array("status"=&gt;'1');
                     $feeddata=$db-&gt;kf_answertype-&gt;find($ustatus); 
              ?&gt;
              &lt;?php
                   $status=array("status"=&gt;'1');
                  $feeddatascale=$db-&gt;kf_scale-&gt;find($ustatus);
              ?&gt;
               for(var i=1;i&lt;get;i++){
  
                    $('#container').append('&lt;div&gt;&lt;div style="width:24%; float:left; padding:10px;"&gt; &lt;textarea class="form-control" name="questions'+ i +'" id="questions" placeholder="Questions"  style="background:#FFFFFF;"  rows="2"&gt;&lt;?php if($_REQUEST['edit']) { echo $getcustomerobj-&gt;questions; } else { echo $_REQUEST['questions']; } ?&gt;&lt;/textarea&gt;&lt;/div&gt;&lt;div style="float:left;margin-top:37px;"&gt;&lt;div style="float:left; margin-right:10px;"&gt;&lt;?php foreach($feeddata as $v){?&gt; &lt;input type="radio" name="answer_type'+i+'" id="answer_type0" onClick="selectScale(this.value,'+i+');" value="&lt;?php echo $v['_id']; ?&gt;"&gt; &lt;?php echo $v['answertype']; ?&gt; &lt;?php }?&gt;&lt;/div&gt;&lt;div style="float:left; margin-top:-10px;display:none;" id="scaleid'+i+'"&gt;&lt;select class="form-control" id="nscale'+i+'" name="noofscale'+i+'"&gt;&lt;option value=""&gt;Select Answer Type&lt;/option&gt;&lt;?php foreach($feeddatascale as $v){ ?&gt;&lt;option value="&lt;?php echo $v['_id']; ?&gt;" &lt;?php if($getcustomerobj-&gt;no_of_scale == $v['_id'] or $_REQUEST['no_of_scale'] == $v['_id']){ print 'selected'; } ?&gt;&gt;&lt;?php echo $v['noofscale']; ?&gt;&lt;/option&gt;&lt;?php } ?&gt;&lt;/select&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;/div&gt;');
  
               }
  
          }
      }
  }
  function deleteQuestionField(){
      var get =$("#ques").val();
      var textareas = $('#container textarea');
  
    if (textareas.length !== 0) {
      textareas.last().remove();
  
      $('#ques').val(textareas.length - 1);
    }
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>Here i can create the multiple text-area,radio button using <code>+</code> button which depends on <code>no of questions</code> field value.Here i need to do the same thing when the following condition is true.</p>
  
  <pre><code>if($id!='' &amp;&amp; $_REQUEST['edit']==1){
  }
  </code></pre>
  
  <p>at the time of page reload if the above condition is true then no need to click on <code>+</code> button, the multiple field should also created.Please help me. </p>