Skip to content

ThirteeNov

My personal blog about coding and internet

Menu
  • About me
  • About Zofia Kreasi
  • Cart
  • Checkout
  • Making an airplane game from scratch in Unity
  • My account
  • Privacy Policy
  • Privacy Policy – zkLeaderboard
  • Sample Page
  • Shop
  • Tutorials on Learning JavaScript
  • ZKAccounts – Privacy Policy
Menu

HTML5 & JavaScript Contact Manager

Posted on November 1, 2017August 4, 2020 by Habibie

In this video tutorial I’ll demonstrate how to create contact input to submit contact info into JavaScript contact array and how to delete it.

Here is the source code:

<!DOCTYPE html>
<html>
	<head>
		<title>ZK Tutorials</title>
	</head>
	<body>
		<h1>HTML5 & JavaScript Contact Manager</h1>
		<input placeholder="Name" id="name"><br>
		<input placeholder="City" id="city"><br>
		<button onclick="add()">Add</button>
		
		<div id="contacts"></div>
		
		<script>
			var contacts = [];
			
			function add(){
				var name = document.getElementById("name").value;
				var city = document.getElementById("city").value;
				var newContact = {
					newName : name,
					newCity : city
				}
				contacts.push(newContact);
				
				updateDiv();
				
				document.getElementById("name").value = "";
				document.getElementById("city").value = "";
				
			}
			
			function updateDiv(){
				var tempContent = "";
				for(var i = 0; i < contacts.length; i++){
					
					tempContent += "<p>Name : " + contacts[i].newName + "<br>City : " + contacts[i].newCity + "<br><span onclick='del(" + i +")'>[del]</span></p>";
				}
				
				document.getElementById("contacts").innerHTML = tempContent;
			}
			
			function del(i){
				contacts.splice(i, 1);
				updateDiv();
			}
		</script>
	</body>
</html>
Post Views: 349
ciihuy2020

Welcome!

  • My YouTube Channel
  • My GitHub Page
  • About me

Categories

  • 3DVista
  • Android
  • Apache
  • C#
  • Cordova
  • Electron & Node JS
  • HTML5, CSS & JavaScript
  • iOS
  • Let's Make Unity Games
  • Misc
  • Photoshop
  • PHP
  • Python
  • Uncategorized
  • Unity
  • WordPress

Recent Posts

  • Hover Reveal script for Unity to show and hide object on mouse hover
  • How to Prevent UI Clicks in Unity from “Bleeding Through” to 3D Objects Behind Them
  • Make objects like wires and cables easily in Unity using Ciihuy Curved Mesh
  • [SOLVED] Can’t Add Custom Domain to Blogger After Losing CNAME Verification
  • iOS App Icon Generator by CiihuyCom
© 2026 ThirteeNov | Powered by Superbs Personal Blog theme