Código Javascript:
Ver original
$(document).ready(function() { var MaxInputs = 4; //maximum input boxes allowed var contenedor = $("#discoduro"); //Input boxes wrapper ID var AddButton = $("#agregardiscoduro"); //Add button ID var Marca = '<?php $select ?>'; //var x = contenedor.length; //initlal text box count var x = $("#discoduro div").length + 1; var FieldCount = x-1; //to keep track of text box added $(AddButton).click(function (e) //on add input button click { if(x <= MaxInputs) //max input box allowed { FieldCount++; //text box added increment //add input box $(contenedor).append('<div class="added"><fieldset><legend id="legdiscoduro">Disco Duro</legend><table><tr><td width="144"><select type="text" id="marca'+ FieldCount +'" name="marcadiscoduro[]" value="" ><option value="">Seleccione Marca</option></select><td width="144"><select type="text" id="modelo'+ FieldCount +'" name="modelodiscoduro[]" value="" /><option value="">Seleccione Modelo</option>'+Marca+'</select></td><td width="144"><input type="text" id="tipodiscoduro'+ FieldCount +'" name="tipodiscoduro[]" placeholder="Tipo" /></td><td width="144"><input type="text" id="serialdiscoduro'+ FieldCount +'" name="serialdiscoduro[]" placeholder="Serial"/></td><td width="144"><input type="text" id="obsdiscoduro'+ FieldCount +'" name="obsdiscoduro[]" placeholder="Observaciones" /></td><td width=""><select type="text" id="cantdiscoduro'+ FieldCount +'" name="cantdiscoduro[]"><option>Cantidad</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option></select></td><td></td></tr></table><a href="#" class="eliminar">×</a></fieldset></div>'); x++; //text box increment } return false; }); $("body").on("click",".eliminar", function(e){ //user click on remove text if( x > 1 ) { $(this).parent('fieldset').remove(); //remove text box x--; //decrement textbox } return false; }); });
A la variable "Marca" quiero agregarle el contenido de un script php y luego concatenarlo mas adelante.