@Proculopsis: the years are dynamic and they come from the xsl file. How can I send this dynamic array to the form (the values are not hard coded)? In my javascript code, can I use "get element by id" to get the value of this dynamic array?
function alert{
var year = [document.getElementById('years')];
var y = year.length ;
if (confirm("The year is " + year[1].value+ " you still want to save?")) {
document.getElementById(test').submit();
}
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title> - jsFiddle demo by Proculopsis</title>
<script type='text/javascript' src='http://code.jquery.com/jquery-1.7.1.js'></script>
<script type='text/javascript'>//<
$(function(){
var years = "";
$("#years\\[\\]").each(fun
years += $(this).val();
years += "\r\n";
});
alert(years);
});//]]>
</script>
</head>
<body>
<form method="POST" action="test.jsp" id="tes">
<input type="hidden" name="years[]" id="years[]" value="2005" />
<input type="hidden" name="years[]" id="years[]" value="2006" />
<input type="hidden" name="years[]" id="years[]" value="2007" />
</form>
</body>
</html>