The function document.getElementsByTagName
is not used to search by attributes, I recommend that you read the documentation, the use is totally wrong, this search function by tag name, if you want to pick up elements more easily you can use document.querySelector
, or even document.getElementById
.
Also, as MagicHat mentioned, the tags are incorrect, have a </button>
left, always try to make the marking as correct as possible, you can use tools like:
Note: you do not need to validate 100%, worry about looking at validations on wrong tags and repeated ids (another thing that can cause problems)
See here I've adapted everything to getElementById
:
function calc(){
var myVar = document.getElementById("myCalc").value;
document.getElementById("calcFeito").value = myVar * 2;
document.getElementById("calcFeito").setAttribute("type", "text");
}
<form name="formCalc">
<br>Digite o Valor:<br>
<input type="text" name="myCalc" id="myCalc">
<input type="button" value="botão" onClick="calc()"><br>
</form>
<input type='hidden' id='calcFeito'>
Read the documentation on DOM and learn how each function works before using it: