I am very new to web development and am trying to create a website that will allow the user to input their favorite website links and then print these links below the text box. After the link is printed, it has to be clickable for the user. However the problem I am running into is that my program will not allow the user to input multiple links, it simply updates the first input.
var urlList = [];
function saveUrl(){
var site = {url};
var i = 0;
var favSite = "";
site.url = document.getElementById('url').value;
var lnk = document.getElementById('lnk');
urlList.push(site);
for(i =0; i<urlList.length;i++){
var thisSite = {url};
thisSite = urlList[i];
lnk.href = "http://" + thisSite.url;
favSite = lnk.href;
favSite+="<br>";
}
lnk.innerHTML = favSite;
}
<!DOCTYPE html>
<html>
<head>
<title>Favorites</title>
<script type="text/javascript" src="attempt4.js"></script>
</head>
<body>
<form>
<input type = "text" id = "url" size = "25">
<input type = "submit" value = "submit" onclick="saveUrl();return false">
</form>
<a target="_blank" href="" id=lnk></a> <br>
</body>
</html>
lnk.innerHTML = favSite;tolnk.innerHTML += favSite;