Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript 2nd Field Input Mirror

johnwboyd

New Coder
Hello.
I found a cool script to mirror a field input to another input but I need it to mirror to TWO inputs below. Here's the code:


Code:
<!DOCTYPE html>
<html lang="en-US" class="no-js no-svg">
<head>
<script type='text/javascript' src='http://www.sapotdisenyo.com/wp-includes/js/jquery/jquery.js?ver=1.12.4-wp' id='jquery-core-js'></script>
</head>

<body >

    <input id="main" class="form-control" placeholder="Enter some text">
 

<label>Mirror</label>
    <span id="mirror"></span>
 
2nd Mirror Would go Here:
 <span id="mirror2"></span>

<script>
jQuery(function () {
  jQuery('[data-toggle="tooltip"]').tooltip();
})
    
    var main = document.getElementById('main');
var mirror = document.getElementById('mirror');

main.addEventListener('input', function(event) {
  mirror.innerText = event.target.value.split('').join('');
});   
    
</script>

</body>
</html>
 
Changed your <span>s to <p>s
Code:
<body >

    <input id="main" class="form-control" placeholder="Enter some text"><br>
 

<label>Mirror</label>
    <p id="mirror"></p>
 
2nd Mirror Would go Here:
 <p id="mirror2"></p>

<script>
jQuery(function () {
  jQuery('[data-toggle="tooltip"]').tooltip();
})
    var main = document.getElementById('main');
    var mirror = document.getElementById('mirror');
    var mirror2 = document.getElementById('mirror2');
main.addEventListener('input', function(event) {
    mirror.innerText = event.target.value.split('').join('');
    mirror2.innerText=mirror.innerText;
});   
</script>
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom