[Solved] Need to get input text with javascript then add it to a sentence


If I understood the question correctly, you might be looking for something like this:

<script type="text/javascript">
  $(function() {
    $("#pTextInput").html("1"); 
    $("#quantity").on("change keyup", function() {
      $("#pTextInput").html($(this).val());
    });
  });
</script>

 <label for="quantity">Qty: </label> 
 <input min="1" type="number" id="quantity" name="quantity" value="1" />
 <input type="submit" id="add-to-cart" class="btn addtocart" name="add" value="Add to cart" />
 <div class="how-many">You have helped save <span id="pTextInput"></span> people</div>

As you change the input of quantity, the pTextInput value will change with it.

4

solved Need to get input text with javascript then add it to a sentence