title: jQuery dynamic form, how get the value with dynamic id's?
body: <p>I am new in jQuery and I have to do a dynamic form with two selects, in one select I need to make that if the user choose the option let's say B another select appear but if he choose A then it doesn't show, the problem is that I can get to every element in the form, I do the form with a PHP for and then pass the variable to the id's so it gets something like this:</p>
  
  <pre><code>&lt;select id="edocivil&lt;?php echo $x ?&gt;" class="textbox" name="edocivil&lt;?php print $x; ?&gt;" &gt;
  </code></pre>
  
  <p>$x been the number of the field, I need to get the value of that field so if it B it shows these other select that is in a div, this is how:</p>
  
  <pre><code>&lt;div id="regimen&lt;?php echo "$x"; ?&gt;" style="display:none;"&gt;
  </code></pre>
  
  <p>and what I do is have a hidden field with the value of $x so I can get it with jQuery but I can't do it I need help please, I leave the jQuery script and the hidden field thank you.</p>
  
  <pre><code>$(document).ready(function(){ //asÌ es como se crean las funciones jQuery. solo cree
  
  var id_edo= $(this).next(".numero_id_edo").val();
  alert(id_edo);
  $("#edocivil"+id_edo).change(function(){ //se ejecuta con el evento onChange  
  
  
   var val = $("#edocivil"+id_edo).val()
  
  if(val =="B")
  {
      $("#regimen"+id_edo).show();  
  }
  else
  {
      $("#regimen"+id_edo).hide();  
  }
  
  });//change
  });//ready
  </code></pre>
  
  <p>the hidden field:</p>
  
  <pre><code>&lt;input type="hidden" name="numero_id_edo"  id="numero_id_edo" value="&lt;?php echo $x; ?&gt;" class="numero_id_edo"&gt;
  </code></pre>
  
  <p>I tried to make it the most understandable way, I am really new to this of Stack Overflow</p>