Josh Josh - 5 months ago 13
HTML Question

Display user's input in 2 different places using PHP

<input id="myID" name="inputName" type="text" placeholder="Placeholder" maxlength="16">

<h3><?php echo $_POST['MCusername']; ?><h3>


What I was really looking for is to display whatever is typed into the input tag, instantly got put into the h3 tag.

Sorry, I'm still new to PHP .

Answer

The below example uses JQuery.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
<script>
    $(function() {
      $( "#myID" ).keyup(function() {
          $("#typedID").html( $(this).val() );
        });
    });
</script>

<input id="myID" name="inputName" type="text" placeholder="Placeholder" maxlength="16">

<h3 id="typedID"><h3>
Comments