Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 72416

add data to array/object via form javascript

$
0
0

I have a form. If you fill in the form, the data must be placed in the constant USERS with (vanilla) javascript. Can somebody help me, please?

It is also intended that the CONST USERS will be shown in the div 'show', but doesn't have to.

My Code:

<!DOCTYPE html>
<head>
    <title>Users</title>
</head>
<body>


<main>
    <form>
        <label for="ordername">Name:</label>
        <input type="text" id="name" name="name"/>

        <label for="age">Age:</label>
        <input type="number" id="age" name="age"/>

        <input type="submit" value="submit" class="submit"/>
    </form>

    <div class="show">

    </div>
</main>

<script>
    const USERS = [
    {
        name: Brit,
        age: 45,

    },
    {
        name: John,
        age: 55,
    }];

</script>
</body>
</html>

Viewing all articles
Browse latest Browse all 72416

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>