Your Add() function will create multiple div and inputs with same id
<div id = "credit_unit" name = "myfile">
<input type = "text" id = "unit4" placeholder = "Credit" onkeyup ="mul()">
</div>
<div id = "credit_unit" name = "myfile">
<input type = "text" id = "unit4" placeholder = "Credit" onkeyup ="mul()">
</div>
getElementById will return more value nodes, you need to loop or take the default or create a unique id. Also remove te spaces between the types in your code and use double quotes in your javascript instead of single.
document.getElementById("code4")[0].value;