I have been exploring YouTube tutorials in an attempt to learn how to effectively search for specific data entries within an array. Below is an example of a JavaScript array along with the use of console.log.
JavaScript Array Example:
var data = {
username: "john",
email: "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4b79730b0c180f0d0d65080406">[email protected]</a>",
status: true,
id: 25
};
var data = {
username: "jIM",
email: "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="91a3a6d1d6c2d5d7bfd2dedc">[email protected]</a>",
status: false,
id: 23
};
var data = {
username: "Jane",
email: "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="fccec9bcbbafb8bad2bfb3b1">[email protected]</a>",
status: false,
id: 22
};
{
console.log(data);
}
Below is an HTML snippet where I am attempting to create functionality that allows me to search the above JavaScript array and display/print the result in a specific div upon clicking a submit button.
<html>
<head>
<title>Get Value</title>;
<script type="text/javascript">
function getDisplay(){
var username = document.getElementById("username").value;
var email = document.getElementById("email").value;
document.getElementById("display").innerHTML = "Username: " + username + "<br/>Email: " + email;
}
</script>
</head>
<body>
<div id="whole">
Username : <input type="text" name="username" id="username">
Email : <input type="email" name="email" id="email"></br>
<button onclick=getDisplay()>Submit</button>
</div>
<div id="display">
</div>
</body>
</html>
If you have any recommendations on videos or resources that could assist me in my learning process, it would be greatly appreciated.