Auto populate field base on what was entered in another field simultaneously

前端 未结 4 1889
遇见更好的自我
遇见更好的自我 2021-02-10 04:21

I was trying to figure out how to auto-populate the input value base on what was entered in another input field using javascript. Here\'s my code:



        
4条回答
  •  攒了一身酷
    2021-02-10 04:49

    I made a js fiddle based on what you're asking for.

    HTML

    Home Address:
    
    
    Apt or Suite Number:
    City/Town:
    State:
    Zip:

    Select Shipping Address Below:

    JavaScript

    $("#address,#suite,#city,#state,#zip").change(function () {
        var addressArray = [$("#address").val(), $("#suite").val(), $("#city").val(), $("#state").val(), $("#zip").val()];
        $("#shiadd1").text(addressArray.join(' '));
    });
    

提交回复
热议问题