07/07/2015, 11:27
|
| | Fecha de Ingreso: junio-2012 Ubicación: En el Mundo
Mensajes: 766
Antigüedad: 12 años, 7 meses Puntos: 10 | |
Respuesta: duda en poder insertar varios link url aver mira este amigo me gusta mas Cita:
Iniciado por xoceunder ok encontre esto pero tengo problema
Código HTML:
Ver original<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script> <script type="text/javascript"> $(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 // create the new element via clone(), and manipulate it's ID using newNum value var newElem = $('#input' + num).clone().attr('id', 'input' + newNum); // 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 $('#input' + num).after(newElem); // enable the "remove" button $('#btnDel').attr('disabled',''); // business rule: you can only add 5 names if (newNum == 5) $('#btnAdd').attr('disabled','disabled'); }); $('#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').attr('disabled',''); // if only one element remains, disable the "remove" button if (num-1 == 1) $('#btnDel').attr('disabled','disabled'); }); $('#btnDel').attr('disabled','disabled'); }); <div id="input1" style="margin-bottom:4px;" class="clonedInput"> Link: <input type="text" name="name[0]" id="name[0]" /> <input type="button" id="btnAdd" value="add another name" /> <input type="button" id="btnDel" value="remove name" />
en que los campo me salen asi
<input name="cmd[0]" >
<input name="cmd[2]" >
<input name="cmd[3]" >
<input name="cmd[4]">
<input name="cmd[5]">
en vez que salgan asi
<input name="cmd[0]" >
<input name="cmd[1]" >
<input name="cmd[2]" >
<input name="cmd[3]">
<input name="cmd[4]"> |