title: JavaScript function with PHP code not working
body: <p>I have a form with JavaScript and PHP validation. One of the form's features is a JavaScript function that copies a DIV and adds it to the page. The copy function works without any problems and the PHP and Javascript validation work for the initial DIV.</p>
  
  <p><strong>The problem:</strong>
  The PHP validation doesn't work for the newly created DIV's.</p>
  
  <p>In other words, I have a DIV that is copied with a JavaScript function and has some PHP code. The problem is with the PHP code that only works for the initial DIV and not the new created DIV's.</p>
  
  <p>This is the HTML code that is copied:</p>
  
  <pre><code>&lt;div id="addinput"&gt;
  
  &lt;p&gt; lorem 
     &lt;input onBlur="data(this)" type="text"  id="valA" name="valA" 
      value="&lt;?php   echo  ($valA);?&gt;"/&gt; 
     &lt;span&gt;&lt;?php echo $valAErr;?&gt;&lt;/span&gt; 
  
      &lt;select id="valD" name="valD" size="1"&gt;
         &lt;option selected disabled hidden value=''&gt;&lt;/option&gt;
         &lt;option value="valueA"&gt;A&lt;/option&gt;
         &lt;option value="valueB"&gt;B&lt;/option&gt; 
      &lt;/select&gt;
      &lt;span class="error"&gt;&lt;?php echo $valDErr;?&gt;&lt;/span&gt; 
  
      &lt;a href="#" id="addNew"&gt;Add&lt;/a&gt;
  &lt;/p&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>This is the initial JavaScript function that copies the DIV. This was made before I added the PHP code in the Javascript function and the HTML code, and it worked.</p>
  
  <pre><code>$(function() {
  var addDiv = $('#addinput');
  var i = $('#addinput p').size() + 1;
  $('#addNew').live('click', function() {
  $('&lt;p&gt; lorem 
         &lt;input onBlur="data(this)" type="text" id="valA" name="valA' + i +'" 
          value=""/&gt;
  
  
          &lt;select id="valD" name="valD' + i +'" name="tip" size="1"&gt;
             &lt;option selected disabled hidden value=''&gt;&lt;/option&gt;
             &lt;option&gt;A&lt;/option&gt;
             &lt;option&gt;B&lt;/option&gt;
          &lt;/select&gt;
  
          &lt;a href="#" id="remNew"&gt;Delete&lt;/a&gt; 
  &lt;/p&gt;').appendTo(addDiv);
  
  i++;
  
  return false;
  });
  
  $('#remNew').live('click', function() {
  if( i &gt; 2 ) {
  $(this).parents('p').remove();
  i--;
  }
  return false;
  });
  });
  </code></pre>
  
  <p>This is my JavaScript code with PHP and it doesn't work:</p>
  
  <pre><code>$('#addNew').live('click', function() {
  $('&lt;p&gt;lorem
  
        &lt;input onBlur="data(this)" type="text" id="valA" name="valA' + i +'" 
         value="&lt;?php echo ($valA);?&gt;"/&gt;
        &lt;span class="eroareData, error"&gt; &lt;?php echo $valAErr;?&gt; &lt;/span&gt; 
  
        &lt;select id="valD" name="valD' + i +'" name="tip" size="1"&gt;
              &lt;option selected disabled hidden value=''&gt;&lt;/option&gt;
              &lt;option value="A"&gt;A&lt;/option&gt;
              &lt;option value="B"&gt;B&lt;/option&gt;
        &lt;/select&gt; 
        &lt;span class="error"&gt;&lt;?php echo $valCErr;?&gt;&lt;/span&gt;
       &lt;a href="#" id="remNew"&gt;Delete&lt;/a&gt; &lt;/p&gt;').appendTo(addDiv);
  </code></pre>