DOM || ( Summing Pool Form )

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="style.css">
    <title>Document</title>
</head>
<body>


    <!-- <button class="button" id="btn" onclick="create()">Click to create heading</button>
    <div id="demo"></div> -->


    <div class="container">

        <div class="icon">🏊‍♂️</div>

        <h1 class="heading">Under 18 Swimming Champaionship</h1>
        <p class="desc">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Corrupti, praesentium.</p>

        <div class="flex">
            <input type="text" id="name" placeholder="Enter The Name">
            <input type="text" id="age" placeholder="Enter The Age">
   

        </div>

        <button class="button" onclick="register()">Click To Register</button>

    </div>

    <div id="usercontainer" class="user-container"></div>
   





   
<script src="app.js"></script>






   
</body>
</html>



// JAVA Script File


// let demo=document.getElementById("demo");

// demo.innerHTML="<h2>This is java</h2>"

// function create(){

//     let heading = document.createElement("h1");

//     heading.innerText="This is ne heading created";

//     heading.classList.add("title");

//     demo=document.getElementById("demo");

//     demo.appendChild(heading);

// }
let users =[];
let userContainer=document.getElementById('usercontainer');
function render(){
    userContainer.innerHTML=" ";
    for(let i=0;i<users.length;i++){
        let div=document.createElement('div');
        let name = document.createElement('div');
        let age = document.createElement('div');

        name.innerText=users[i].name;
        age.innerText=users[i].age;
        div.classList="user";

        // userContainer.appendChild(name);
        // userContainer.appendChild(age);

        userContainer.appendChild(div);
        div.appendChild(name);
        div.appendChild(age);


    }




}



function register(){

    let nameinp=document.getElementById('name');
    let ageinp=document.getElementById('age');

    let user = {
        name : nameinp.value,
        age : Number(ageinp.value)

    }
    if(user.age>=16 && user.age<=18){
        users.push(user);
        render();

    }
    else{
        console.log("you are not eligible");
    }
   


}

// CSS File :-
/* .title{

    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    font-size: 32px;
    margin: 20px auto;
    border: 1px solid black;
    width: 400px;
    padding : 10px;
    text-decoration: underline blueviolet;
    border-radius: 5px;

} */

body{

    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
   


}

.container{

    width: 550px;
    margin: 20px auto;
    border: 1px solid black;
    border-radius: 10px;
    padding: 10px;
    text-align: center;
   

}

.icon{

    font-size: 50px;


}
.flex{
    display: flex;
    gap: 10px;


}
input{
    padding: 16px 32px;
    width: 100%;
    /* box-sizing: border-box; */
    border: 1px solid black;
    border-radius: 10px;
    margin-bottom: 10px;
}
input:focus{
    outline: none;
    border-color: blueviolet;



}

.button{

    padding: 16px 32px;
    width: 100%;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 16px;


}

.user-container{

    width: 550px;
    margin: auto;


}


.user{
    display: flex;
    background-color: rgba(255, 255, 173, 0.937);
    border-radius: 5px;
    padding: 16px 32px;
    gap: 50px;
    margin-bottom: 10px;

}

Output :-




Comments

Popular posts from this blog

Array Mapping and Filters Assignment

Rolling Dice

Basics Of Java Script Till DOM Beggining