Sign in to follow this  
Guest Tarcisio Corte

Como Passar Valor De Um Inpu Text Para Outro Input Text Usando Getelem

Recommended Posts

Guest Tarcisio Corte

meu codigo é o seguinte :

<div id="teste" style="background-color:#ededed; color:Blue; font-size:16px; height:25px; text-align:center;">

<input type="text" id="txt" />

<input type=button id="btn" value="press" />

</div>

<br/>

<div id="teste1" style="height:25px; font-size:16px; text-align:center; background-color:#dddccc;">

<input type="text" id="txt2" value="dsfasdfasdf" />

</div>

Como é que eu passo o valor da input text "txt2" que tem value="dsfasdfasdf" para a input text "text" que é de outra div !

Eu gostaria de fazer isso usando o comando getElementById .

Share this post


Link to post
Share on other sites
<script>

    function PassaValor() {
    
        valor = document.getElementById("txt2").value;
        
            document.getElementById("txt").value = valor;
            
            }
            
</script>
<div id="teste" style="background-color:#ededed; color:Blue; font-size:16px; height:25px; text-align:center;">
<input type="text" id="txt" />
<input type="button" id="btn" value="press" onclick="PassaValor();" />

</div>
<br/>

<div id="teste1" style="height:25px; font-size:16px; text-align:center; background-color:#dddccc;">
<input type="text" id="txt2" value="dsfasdfasdf" />
</div>

Share this post


Link to post
Share on other sites

Join the conversation

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

Guest
Reply to this topic...

×   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.

Sign in to follow this