What's new

Java JavaScript, Patulong po

Sanji Ken

Eternal Poster
Joined
Aug 10, 2016
Posts
841
Reaction
140
Points
262
document.getElementByld is not a function daw po sinunod ko naman lahat ng rules (maybe)
Censored ata yung Séx sana maintindihan niyo yung code

JavaScript:
<!DOCTYPE html>
<html>
     <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>Exam</title>
    </head>
    <body>
        <div id="addButton">Add to Storage</div>
        <div id="seeButton">View Storage</div>
        First : <input type="text" id="firstName">
        Last : <input type="text" id="lastName">
        Age : <input type="number" id="age">
        *** : <input type="text" id="***">
        Status : <input type="text" id="status">
    <script>
        document.getElementByld('addButton').addEventListener('click',addToStorage);
        document.getElementById('seeButton').addEventListener('click',viewStorage);
        const people = JSON.parse(localStorage.getItem('tester1')) || {"first":"none","last":"none","age":"none","***":"none","status":"none"}
        console.log(people);
  
        function addToStorage()
        {
            let tempFirst = document.getElementByld('firstName').value;
            let tempLast = document.getElementByld('lastName').value;
            let tempAge = document.getElementByld('age').value;
            let tempSex = document.getElementByld('***').value;
            let tempStatus = document.getElementByld('status').value;
            let myObj = JSON.stringify
            ({
                "first": tempFirst,
                "last": tempLast,
                "age": tempAge,
                "***": tempSex,
                "status": tempStatus
            });
            localStorage.setItem('tester1', myObj);
        }
            function viewStorage()
            {
                let tempHolder = JSON.parse(localStorage.getItem('tester1')) || people; console.log(tempHolder);
            }
        </script>
    </body>
</html>
 
Last edited:
Na mistook mo yung L sa I, Palitan mo yung: letter "L" ng letter "I"
Dapat get element by id yan
Code:
getElementById
 
Na mistook mo yung L sa I, Palitan mo yung: letter "L" ng letter "I"
Dapat get element by id yan
Code:
getElementById
tama nga boss na mislook nga panget kasi editor ko wala recommendation tuwing mag ccode, pagkasulat ko kasi nya copy paste copy paste nalang eh, salamat boss
 

Similar threads

Back
Top