Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Biel.

Buscar imagem no 1º input type file e carregar automaticamente a mesma

Recommended Posts

Buscar imagem no 1º input type file e carregar automaticamente a mesma imagem no 2º input type file


Boa noite a todos. Pessoal gostaria muito de fazer o seguinte


Faz de conta que no 1º input type="file" busquei no meu pc esta imagem tete.jpg

Gostaria que esta imagem tete.jpg carregasse automaticamente no input type="file" sem eu precisar clicar no 2º input type="file" para buscar a imagem tete.jpg




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

1º <input type="file" name="imgA" required value="" /><br /><br />

2º <input type="file" name="imgB" required value="" />

</body>
</html>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Angelorubin. Estou iniciando agora meus estudos com javascript a passos lentos devido ao tempo. Queria muito até saber como começar.

<script>

</script>

Compartilhar este post


Link para o post
Compartilhar em outros sites
angelorubin, tentei fazer dessa forma no script que william fez não consegui


1º <input type="file" name="imagem1" size="30" required value="dd" /><br /><br />


2º <input type="file" name="imagem2" size="30" required value="ddd" /><br /><br />




<script>
(function(document){
'use strict';
var $imagem1 = document.querySelector('select[name="imagem1"]');
var $imagem2 = document.querySelector('select[name="imagem2"]');

var mapA = {
'dd': 'ddd'

};


function selected($select, value) {
var $options = $select.getElementsByTagName('option');


for(var i=0; i < $options.length; i++) {
if ($options[i].value === value) {
return $options[i].selected = true;
}
}
}

$imagem1.addEventListener('change', function(){
var v = this.value;
selected($imagem2, mapA[this.value]);
});

}(document));
</script>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Qual real necessidade disso?

 

Uma vez enviado uma unica imagem, você pode efetuar um clone com php, ou criar várias a partir original.

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.