Ver Mensaje Individual
  #3 (permalink)  
Antiguo 23/11/2012, 11:29
misael_winne
 
Fecha de Ingreso: noviembre-2012
Ubicación: Monterrey
Mensajes: 26
Antigüedad: 11 años, 9 meses
Puntos: 0
Respuesta: clonar combobox junto con cajas de texto

tengo este script
<script type="text/javascript">
//cambia los name de los inputs
actualizaName = function ($input)
{
iNombre = '#reporte_medicamento_medicamento_nombre';
iDosis = '#reporte_medicamento_medicamento_dosis';
shora1 = '#reporte_medicamento_medicamento_hora1_hr';
sminutos1 = '#reporte_medicamento_medicamento_hora1_min';
shora2 = '#reporte_medicamento_medicamento_hora2_hr';
sminutos2 = '#reporte_medicamento_medicamento_hora2_min';
shora3 = '#reporte_medicamento_medicamento_hora3_hr';
sminutos3 = '#reporte_medicamento_medicamento_hora3_min';
shora4 = '#reporte_medicamento_medicamento_hora4_hr';
sminutos4 = '#reporte_medicamento_medicamento_hora4_min';

for(var i = 1; i <= $input ; i++)
{
Nombre = 'reporte_medicamento_medicamento';
Dosis = 'reporte_medicamento_medicamento';
hora1 = 'reporte_medicamento_medicamento';
minutos1 = 'reporte_medicamento_medicamento';
hora2 = 'reporte_medicamento_medicamento';
minutos2 = 'reporte_medicamento_medicamento';
hora3 = 'reporte_medicamento_medicamento';
minutos3 = 'reporte_medicamento_medicamento';
hora4 = 'reporte_medicamento_medicamento';
minutos4 = 'reporte_medicamento_medicamento';

Nombre += i + "_nombre";
Dosis += i + "_dosis";
hora1 += i + "_hora1_hr";
minutos1 += i + "_hora1_min";
hora2 += i + "_hora2_hr";
minutos2 += i +"_hora2_min";
hora3 += i +"_hora3_hr";
minutos3 += i +"_hora3_min";
hora4 += i +"_hora4_hr";
minutos4 += i +"_hora4_min";

var input = $('#input'+i);

input.find(iNombre).attr("name",Nombre);
input.find(iDosis).attr("name",Dosis);
input.find(shora1).attr("name",hora1);
input.find(sminutos1).attr("name",minutos1);
input.find(shora2).attr("name",hora2);
input.find(sminutos2).attr("name",minutos2);
input.find(shora3).attr("name",hora3);
input.find(sminutos3).attr("name",minutos3);
input.find(shora4).attr("name",hora4);
input.find(sminutos4).attr("name",minutos4);

}
}
$(document).ready(function() {
/* $('#btnAdd').click(function()
{
var num = $('.clonedInput').length; // how many "duplicatable" input fields we currently have
var newNum = new Number(num + 1); // the numeric ID of the new input field being added
iNombre = '#reporte_medicamento_medicamento_nombre';
iDosis = '#reporte_medicamento_medicamento_dosis';
shora1= '#reporte_medicamento_medicamento1_hora1_hr';
sminutos1='#reporte_medicamento_medicamento1_hora1 _min';
shora2 = '#reporte_medicamento_medicamento_hora2_hr';
sminutos2 = '#reporte_medicamento_medicamento_hora2_min';
shora3 = '#reporte_medicamento_medicamento_hora3_hr';
sminutos3 = '#reporte_medicamento_medicamento_hora3_min';
shora4 = '#reporte_medicamento_medicamento_hora4_hr';
sminutos4 = '#reporte_medicamento_medicamento_hora4_min';


// create the new element via clone(), and manipulate it's ID using newNum value
var newElem = $('#input' + num).clone().attr('id', 'input' + newNum);
var strNewElement = newElem.find('input').text();
// manipulate the name/id values of the input inside the new element
newElem.children(':first').attr('id', 'name' + newNum).attr('name', 'name' + newNum);
// insert the new element after the last "duplicatable" input field
//limpia el texto del nuevo input
$('#input' + num).after(newElem);
$('#input' + newNum).find(iNombre).attr("value","");
$('#input' + newNum).find(iDosis).attr("value","");
$('#input' + newNum).find(shora1).attr("value","");

// enable the "remove" button
$('#btnDel').removeAttr("disabled");
// business rule: you can only add 4 names
if (newNum == 4)
$('#btnAdd').attr('disabled','disabled');

//cambia los nombres de los nuevos inputs y selects
actualizaName(newNum);
});*/

$('#btnDel').click(function() {
var num = $('.clonedInput').length; // how many "duplicatable" input fields we currently have
$('#input' + num).remove(); // remove the last element
// enable the "add" button
$('#btnAdd').removeAttr("disabled");
// if only one element remains, disable the "remove" button
if (num-1 == 1)
$('#btnDel').attr('disabled','disabled');
});
$('#btnDel').attr('disabled','disabled');
});
</script>
pero cuando clona todo no me deja seleccionar las horas quiero saber como puedo hacerle para que el segundo registro que quiero llenar me deje en blanco las horas, puesto el codigo que tengo solo me deja en blanco los campos de texto