Jump to content
Fórum Script Brasil
  • 0

Problema Com Innerhtml


erickeek
 Share

Question

Esse é meu codigo, so to com dois problemas. <_<

Bom ele num está funcionando direito no IE. no FF funciona que é uma beleza.

O outro problema e que se eu tentar inserir mais uma input depois de já ter escolhido as minhas imagens ee some

alguém tem alguma ideia de como fazer isso.

queria fazer algo tipo o email do google de anexo. poderiam mde ajuda?!

<script type="text/javascript">    
function valida (){
    var f = document.form_foto
    f.submit(); 
}
var n = 2;
function add_input(){
    array = new Array();
    inputs = document.getElementsByTagName('input');
        for(i=0;i<inputs.length;i++){
            if(inputs[i].type == "file"){
                array[i] = inputs[i].value;
            }
        }
        if (n<=20){
            document.getElementById("ft").innerHTML += "<tr><td class='font12BR'>Foto "+n+":</td><td><input type='file' name='file[]' class='borda12'></td></tr>"
            n++;
            for(i=1;i<array.length;i++){
                inputs[i].value = array[i];
            }
        } else {
            alert('Não pode ser criado mais campos');
            document.getElementById("add").innerHTML = "" 
        }
}
</script>
<style type="text/css">
<!-- 
body {
    margin-left: 0px;
    margin-top: 0px;
}
-->
</style>
<form method="post" action="trata_incluir_fotos.php" name="form_foto" enctype="multipart/form-data">
<input type="hidden" name="cod_imovel" value='<?= $cod ?>'>
    <table width="550" align="center">
        <tr>
            <td class='titulo2' colspan="2">Incluir Fotos</td>
        </tr>
        <tr>
            <td class="font12BR" width="20%">Foto 1:</td>
            <td><input type="file" name='file[]' class="borda12"></td>
        </tr>
        <tr>
            <td colspan="2" width="106"><span id='ft'></span> </td>
        </tr>
        <tr>
            <td align="right"><input type="button" value="OK" class="font12B" onClick="valida()"></td>
            <td><span id='add'><a href='#' onClick="add_input()">Adicionar campo</a></span></td>
        </tr>
    </table>
</form>

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Forum Statistics

    • Total Topics
      151k
    • Total Posts
      649.1k
×
×
  • Create New...