domejercicio2.html 1.34 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
<!DOCTYPE html>

<html lang="en">
<head>

</head>

<body>
    <fieldset>
        <legend>Billing Information</legend>
        <p>
            <label>
                Postal Address:<br>
                <input name="postaladdress" id="postaladdress"></input>
            </label>
        </p>
        <p>
                Home Address:<br>
            <label>
                <input type="checkbox" name="homepostalcheck" id="homepostalcheck">
                Same as above
            </label>
                <br>
                <input name="homeaddress" id="homeaddress"></input>
        </p>
    </fieldset>


</body>

<script>

    function setHomeAdress(){

        var campo1 = document.getElementById('postaladdress');

        cb=document.getElementById('homepostalcheck')

        document.getElementById('postaladdress').addEventListener('change', () => {         
                    alert(campo1.value);      
41 42
            }
          );
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67

           

            document.getElementById('homepostalcheck').addEventListener('click', () => {

            if (cb.checked==true) {      
       
               document.getElementById("homeaddress").disabled = true;

            } else {
                
               document.getElementById("homeaddress").disabled = false;

            }
            });


        }

        setHomeAdress();

</script>


</html>