Solution:
<script type="text/javascript">
function addElement() {
var ni = document.getElementById('myDiv');
var numi = document.getElementById('theValue');
var num = (document.getElementById('theValue').value - 1) + 2;
numi.value = num;
var newdiv = document.createElement('label');
var divIdName = 'my' + num + 'label';
newdiv.setAttribute('id', divIdName);
newdiv.innerHTML = "Element Number ' + num + ' has been added with id = '"+divIdName+"'!";
ni.appendChild(newdiv);
}
</script>
</head>
<body>
<input type="hidden" value="0" id="theValue" />
<p><a href="javascript:;" onclick="addElement();">Add Some Elements</a></p>
<div id="myDiv"> </div>
</body>
</html>