Foros del Web » Creando para Internet » HTML »

¿Cómo aplicar este elemento? ¿Cuál es su nombre?

Estas en el tema de ¿Cómo aplicar este elemento? ¿Cuál es su nombre? en el foro de HTML en Foros del Web. Sé que se lee super estúpido el titulo del tema, pero es que realmente no sé como se llamen este tipo de elementos y quisiera ...
  #1 (permalink)  
Antiguo 26/07/2016, 16:51
Avatar de Alejandra_Sand  
Fecha de Ingreso: marzo-2016
Mensajes: 22
Antigüedad: 8 años, 1 mes
Puntos: 1
¿Cómo aplicar este elemento? ¿Cuál es su nombre?



Sé que se lee super estúpido el titulo del tema, pero es que realmente no sé como se llamen este tipo de elementos y quisiera implementarlos en los inputs de un formulario.
Esos que al teclear y colocar una "," se encierran en un bloque, pero más allá de los estilos, quisiera saber cual es funcionamiento del "value", por que aparentemente es sólo un input, que contiene varios elementos independientes y no una cadena de texto completa.

Me basta con que me den el nombre del elemento y por mi cuenta investigo como implementarlo, se los agradecería muchísimo.
  #2 (permalink)  
Antiguo 26/07/2016, 22:42
Avatar de AngelKrak  
Fecha de Ingreso: noviembre-2014
Mensajes: 917
Antigüedad: 9 años, 5 meses
Puntos: 91
Respuesta: ¿Cómo aplicar este elemento? ¿Cuál es su nombre?

nose pero talvez son como los Tags o algo asi
  #3 (permalink)  
Antiguo 27/07/2016, 09:55
Avatar de fishdesign  
Fecha de Ingreso: abril-2011
Ubicación: Málaga
Mensajes: 389
Antigüedad: 13 años
Puntos: 95
Respuesta: ¿Cómo aplicar este elemento? ¿Cuál es su nombre?

Basta con buscar en Google "jquery input tags".

http://xoxco.com/projects/code/tagsinput/

y esta para Bootstrap: https://bootstrap-tagsinput.github.i...nput/examples/

Un saludo
__________________
Web Designer.
Themes-Up!, próximamente
  #4 (permalink)  
Antiguo 05/08/2016, 05:55
Avatar de IsaBelM
Colaborador
 
Fecha de Ingreso: junio-2008
Mensajes: 5.032
Antigüedad: 15 años, 10 meses
Puntos: 1012
Respuesta: ¿Cómo aplicar este elemento? ¿Cuál es su nombre?

o puro javascript
Código HTML:
Ver original
  1. <!DOCTYPE html>
  2. <html dir="ltr" lang="es-es">
  3. <meta charset="utf-8">
  4. <meta name="language" content="es">
  5. <meta name="distribution" content="global">
  6. <meta name="rating" content="General">
  7. <meta name="viewport" content="user-scalable=yes, width=device-width, initial-scale=1">
  8. *, *:before, *:after {
  9.     margin: 0;
  10.     padding: 0;
  11.     border: 0;
  12.     position: relative;
  13.     -webkit-tap-highlight-color: rgba(0,0,0,0);
  14.     -webkit-box-sizing: border-box;
  15.     -moz-box-sizing: border-box;
  16.     box-sizing: border-box;
  17. }
  18.  
  19.  
  20.  
  21. html {
  22.     width: 100%;
  23.     height: 100%;
  24.     -ms-touch-action: none;
  25. }
  26.  
  27.  
  28. body {
  29.     font-family: 'Open Sans', Helvetica, Arial, sans-serif;
  30.     -webkit-touch-callout: none;
  31.     -webkit-text-size-adjust: none;
  32.     -webkit-user-select: none;  
  33. }
  34.  
  35.  
  36. ul.cont-input {
  37.     width: 25rem;
  38.     overflow: auto;
  39.     list-style-type: none;
  40.     border: 1px solid rgb(193, 184, 184);
  41.     margin: 0 auto;
  42. }
  43.  
  44.  
  45. ul.cont-input > li {
  46.     float: left;
  47.     padding: .2rem .2rem .2rem 0;
  48. }
  49.  
  50.  
  51. ul.cont-input > li > span {
  52.     background-color: rgb(180, 212, 234);
  53.     border: 1px solid rgb(15, 216, 186);
  54.     border-radius: 3px;
  55.     display: inline-block;
  56.     padding: .1rem .9rem .1rem .1rem;
  57.     margin: 0 .1rem;
  58. }
  59.  
  60.  
  61. ul.cont-input > li > span > i {
  62.     font-size: .9rem;
  63.     position: absolute;
  64.     top: 0;
  65.     right: 3px;
  66.     display: inline;
  67.     font-family: arial, sans-serif;
  68.     line-height: .9rem;
  69.     color: rgb(255, 0, 0);
  70.     cursor: pointer;
  71. }
  72.  
  73.  
  74. input.inputTags {
  75.     min-width: 3rem;
  76.     -moz-box-sizing: border-box;
  77.     -webkit-box-sizing: border-box;
  78.     box-sizing: border-box;
  79.     -moz-box-shadow: none;
  80.     -webkit-box-shadow: none;
  81.     box-shadow: none;
  82.     background-color: inherit;
  83.     outline: none;
  84. }
  85. var inputTagging = {
  86.  
  87.     params : [],
  88.     exp : new RegExp('\\s'), //caracter con el que se creará un nuevo tag
  89.  
  90.     escritura: function() {
  91.  
  92.         Array.prototype.forEach.call(document.querySelectorAll('.inputTags'), function(obj, i) {
  93.  
  94.             inputTagging.params.push(new Array());
  95.  
  96.             obj.addEventListener('keyup', function() {
  97.  
  98.                 if (inputTagging.exp.test(this.value)) inputTagging.nuevoTag(this.value, this, i);
  99.  
  100.             }, false);
  101.  
  102.  
  103.             document.querySelectorAll('.cont-input')[i].addEventListener('click', function() {
  104.  
  105.                 obj.focus();
  106.  
  107.             }, false);
  108.         })
  109.  
  110.     },
  111.  
  112.  
  113.     nuevoTag: function(valTag, control, indice) {
  114.  
  115.         var tagLimpio = valTag.replace(this.exp, ''),  
  116.         lis = document.createElement('li'),
  117.         sp = document.createElement('span'),
  118.         cierre = document.createElement('i'),
  119.         LIcontrol = document.querySelectorAll('.r-input')[indice],
  120.         controlpadre = LIcontrol.parentNode;
  121.  
  122.         sp.textContent = tagLimpio;
  123.         cierre.textContent = 'x';
  124.  
  125.         cierre.addEventListener('click', function() {
  126.             var li = this.parentNode.parentNode,
  127.                 ul = li.parentNode,
  128.                 listaNodos = Array.prototype.slice.call(ul.children),
  129.                 indexLi = listaNodos.indexOf(li);
  130.             ul.removeChild(li);
  131.             control.focus();
  132.             inputTagging.params[indice].splice(indexLi, 1);
  133.             control.nextSibling.value = inputTagging.params[indice];
  134.         }, false);
  135.  
  136.         sp.appendChild(cierre);
  137.         lis.appendChild(sp);
  138.  
  139.         controlpadre.insertBefore(lis, LIcontrol);
  140.         control.value = '';
  141.         control.focus();
  142.  
  143.         this.params[indice].push(tagLimpio);
  144.         control.nextSibling.value = this.params[indice];
  145.     }
  146. }
  147.  
  148.  
  149. document.addEventListener('DOMContentLoaded', function() {
  150.  
  151.     inputTagging.escritura();
  152.  
  153. }, false);
  154. </head>
  155.     <ul class="cont-input">
  156.         <li class="r-input">
  157.             <input type="text" class="inputTags" placeholder="tags con barra espaciadora"><input type="hidden" name="elinput[]">
  158.         </li>
  159.     </ul>
  160.  
  161. <br><br>
  162.  
  163.     <ul class="cont-input">
  164.         <li class="r-input">
  165.             <input type="text" class="inputTags" placeholder="tags con barra espaciadora"><input type="hidden" name="elinput[]">
  166.         </li>
  167.     </ul>
  168.  
  169. </body>
  170. </html>

DEMO
__________________
if(ViolenciaDeGénero) {alert('MUJER ASESINADA');}

Etiquetas: input
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 14:06.