Dynamic form showing value that was not to show

1

Talk, people, beauty? When I create a dynamic form, it defaults to select, an empty Value in the option, which is set to Value="N / A". When I add, for example, two dynamic forms to populate, at the time of showing in the content it shows one that was not requested, such as N / A.

In the image, I filled out only two Dynamic Forms of Interruption, Equipment Unavailability and Test Area (I put the Start and Finish as N / A same). But he added alone at the time of displaying the interrupts an N / A call, as in the first image.

Hereistheform:

Herearethecodes:

$(document).ready(function(){
    //group add limit
    var maxGroup = 10;
    
    //add more fields group
    $(".addMore").click(function(){
    	if($('body').find('.fieldGroup').length < maxGroup){
    		var fieldHTML = '<div class="form-group fieldGroup">'+$(".fieldGroupCopy").html()+'</div>';
    		$('body').find('.fieldGroup:last').after(fieldHTML);
    	}else{
    		alert('Maximum '+maxGroup+' groups are allowed.');
    	}
    });
    
    //remove fields group
    $("body").on("click",".remove",function(){ 
    	$(this).parents(".fieldGroup").remove();
    });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><divclass="panel-heading"><b>Interrupções</b></div>
<div class="intcont">
	<div class="form-group fieldGroup">
		<div class="input-group">
			<select required="" class="form-control" id="interrupcao" name="interrupcao[]">
				<option value="N/A">Motivo</option>
				<option value="Indisponibilidade de equipamentos">Indisponibilidade de equipamentos</option>
				<option value="Indisponibilidade de Área de teste">Indisponibilidade de Área de teste</option>
				<option value="Outros (Descrever em Comentários)">Outros (Descrever em Comentários)</option>
			</select>
			<input required="" value="N/A" type="text" name="inicioint[]" class="form-control" placeholder="Início"/>
			<input required="" value="N/A" type="text" name="terminoint[]" class="form-control" placeholder="Término"/>
			<div class="input-group-addon"> 
				<a href="javascript:void(0)" class="btn btn-primary addMore"><span class="glyphicon glyphicon glyphicon-plus" aria-hidden="true"></span></a>
			</div>
		</div>
	</div>
	
	<!-- Cópia do formulário pra gerar em baixo -->
	<div class="form-group fieldGroupCopy" style="display: none;">
		<div class="input-group">
			<select required="" class="form-control" id="interrupcao" name="interrupcao[]">
				<option value="N/A">Motivo</option>
				<option value="Indisponibilidade de equipamentos">Indisponibilidade de equipamentos</option>
				<option value="Indisponibilidade de Área de teste">Indisponibilidade de Área de teste</option>
				<option value="Outros (Descrever em Comentários)">Outros (Descrever em Comentários)</option>
			</select>
			<input required="" value="N/A" type="text" name="inicioint[]" class="form-control" placeholder="Início"/>
			<input required="" value="N/A" type="text" name="terminoint[]" class="form-control" placeholder="Término"/>
			<div class="input-group-addon"> 
				<a href="javascript:void(0)" class="btn btn-danger remove"><span class="glyphicon glyphicon glyphicon-remove" aria-hidden="true"></span></a>
			</div>
		</div>
	</div>
</div>
<button class="addMore">add</button>

And here is the code that will show in a PDF the interrupts:

  $html .= "<table>";
  $html .= "<tr>";
  $html .= "<th>INTERRUPÇÕES</th>";
  $html .= "<th>Início</th>";
  $html .= "<th>Término</th>";
  $html .= "</tr>";

  for ($i=0; $i < count($_POST['interrupcao']); $i++) {

   $html .="<tr>";
   $html .="<td>{$_POST['interrupcao'][$i]}</td>";
   $html .="<td>{$_POST['inicioint'][$i]}</td>";
   $html .="<td>{$_POST['terminoint'][$i]}</td>";
   $html .= "</tr>";

  }
  $html .= "</table>";
    
asked by anonymous 09.11.2017 / 17:01

0 answers