There are a few things you need to change in your code. The first function has a local variable accountand url, after which you get access to it in the second function, which, of course, is not included in it.
var account,url;
function genorateCode() {
account = document.getElementById("account").value;
url = document.getElementById("url").value;
sendCode();
}
And in your case, you can use insertAdjacentHTML, as shown below:
function sendCode() {
var str = '<a href="' + url + '">' + '<div class="button"><img src="https://s15.postimg.org/mfpd2ki8r/icon.png" width="16">@' + account + '</div></a>';
document.getElementById('code').insertAdjacentHTML('beforeend', str);
}
Demo
source
share