Test Foro de elhacker.net SMF 2.1

Programación => Desarrollo Web => Mensaje iniciado por: Crash_RPM en 3 Septiembre 2012, 16:04 PM

Título: Cambiar aspecto de mostrar imagenes con javascript
Publicado por: Crash_RPM en 3 Septiembre 2012, 16:04 PM
Hola estoy haciendo un formulario para subir imagenes, y me gustaria que cuando se seleccionen las fotos las muestre (cosa que hace), el unico problema es que las muestra todas las imagenes seleccionadas juntas, me gustaria que hiciera aunque sea un espaciado para que se diferencien.

No domino mucho javascript, por lo que no entiendo mucho el codigo, ¿Donde tendria que poner el espaciado? y como

<script type="text/javascript">
<!--
num=0;
var files;
function crear(src,name,num) {
  fi = document.getElementById('fiel');
  contenedor = document.createElement('span');
  contenedor.id = 'div'+num;
  fi.appendChild(contenedor);
 
  var newImage = document.createElement("img");
  newImage.src = src;
  newImage.height = 75;
  contenedor.appendChild(newImage);
 
}


function handleFileSelect(evt) {
    document.getElementById('fiel').innerHTML="";
    var num=0;
    files = evt.target.files; // FileList object

    // Loop through the FileList and render image files as thumbnails.
    for (var i = 0, f; f = files[i]; i++) {
               
      // Only process image files.
      if (!f.type.match('image.*')) {
        continue;
      }

      var reader = new FileReader();
      // Closure to capture the file information.
     
      reader.onload = (function(theFile){
          return function(e){
              crear(e.target.result,theFile.name,num);
              num++;
              };
        })(f);

      // Read in the image file as a data URL.
      reader.readAsDataURL(f);
    }
  }

-->
function loading(){
    document.getElementById('files').addEventListener('change', handleFileSelect, false);
}
</script>
Título: Re: Cambiar aspecto de mostrar imagenes con javascript
Publicado por: Crash_RPM en 4 Septiembre 2012, 01:18 AM
Lo he solucionado añadiendo esta linea

newImage.style.paddingRight = '10px';