I need to develop a function display() / print() that will display the name and email of the selected option
// add() = ajouter()
// delete() = supprimer()
// display() = afficher()
function add() {
let fullName = document.getElementById("name").value;
let mail = document.getElementById("email").value;
myList = [];
myList.push({
name: fullName,
email: mail
})
document.getElementById("list").innerHTML += '<option>' + fullName + '</option>' + '<br>';
}
function delete() {
let del = document.getElementById("list");
del.remove(del.selectedIndex);
}
// function display(){
// let show = document.getElementById("list")
// let showName = myList[show.selectedIndex].name,
// showEmail = myList[show.selectedIndex].email;
// alert("Hello " + showName + " Your email is : " + showEmail);
// }
<form action="">
<br><br>
<label for="name">Full name : <input id="name" type="text"></label><br><br>
<label for="email">Email : <input id="email" type="email"></label><br><br><br>
<button type="button" onclick="add()">Add</button>
<button type="button" onclick="delete()">Delete</button>
<button type="button" onclick="display()">Display Address</button>
<br><br>
<select name="names-list" id="list" size="5" style="width: 200px;">
</select>
</form>