\вариант с циклом
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript">
function checkEl() {
with(document) var x = [getElementById("a1"), getElementById("a2"), getElementById("a3"), getElementById("a4"), getElementById("a5")];
for(var i = 0; i < x.length; i++) {
if(x[i].id == "a4") { // тут
alert("true");
break;
}
}
}
</script>
</head>
<body onload="checkEl()">
<input type="hidden" id="a1" value="123">
<input type="hidden" id="a2" value="123">
<input type="hidden" id="a3" value="123">
<input type="hidden" id="a4" value="123">
<input type="hidden" id="a5" value="123">
</body>
</html>