Ver Mensaje Individual
  #14 (permalink)  
Antiguo 07/07/2015, 11:27
xoceunder
 
Fecha de Ingreso: junio-2012
Ubicación: En el Mundo
Mensajes: 759
Antigüedad: 11 años, 10 meses
Puntos: 10
Respuesta: duda en poder insertar varios link url

aver mira este amigo me gusta mas

Cita:
Iniciado por xoceunder Ver Mensaje
ok encontre esto pero tengo problema

Código HTML:
Ver original
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  2.                    "http://www.w3.org/TR/html4/loose.dtd">
  3.     <title></title>
  4.     <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
  5.  
  6.     <script type="text/javascript">
  7.         $(document).ready(function() {
  8.             $('#btnAdd').click(function() {
  9.                 var num     = $('.clonedInput').length; // how many "duplicatable" input fields we currently have
  10.                 var newNum  = new Number(num + 1);      // the numeric ID of the new input field being added
  11.  
  12.                 // create the new element via clone(), and manipulate it's ID using newNum value
  13.                 var newElem = $('#input' + num).clone().attr('id', 'input' + newNum);
  14.  
  15.                 // manipulate the name/id values of the input inside the new element
  16.                 newElem.children(':first').attr('id', 'name['+ newNum+']').attr('name', 'name['+ newNum+']');
  17.  
  18.                 // insert the new element after the last "duplicatable" input field
  19.                 $('#input' + num).after(newElem);
  20.  
  21.                 // enable the "remove" button
  22.                 $('#btnDel').attr('disabled','');
  23.  
  24.                 // business rule: you can only add 5 names
  25.                 if (newNum == 5)
  26.                     $('#btnAdd').attr('disabled','disabled');
  27.             });
  28.  
  29.             $('#btnDel').click(function() {
  30.                 var num = $('.clonedInput').length; // how many "duplicatable" input fields we currently have
  31.                 $('#input' + num).remove();     // remove the last element
  32.  
  33.                 // enable the "add" button
  34.                 $('#btnAdd').attr('disabled','');
  35.  
  36.                 // if only one element remains, disable the "remove" button
  37.                 if (num-1 == 1)
  38.                     $('#btnDel').attr('disabled','disabled');
  39.             });
  40.  
  41.             $('#btnDel').attr('disabled','disabled');
  42.         });
  43.     </script>
  44. </head>
  45.  
  46.  
  47. <form id="myForm">
  48.     <div id="input1" style="margin-bottom:4px;" class="clonedInput">
  49.         Link: <input type="text" name="name[0]" id="name[0]" />
  50.     </div>
  51.  
  52.     <div>
  53.         <input type="button" id="btnAdd" value="add another name" />
  54.         <input type="button" id="btnDel" value="remove name" />
  55.     </div>
  56. </form>
  57.  
  58. </body>
  59. </html>

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]">