Questions how to get hidden value from specific form?

I tried to get element's value from specific form. I have 100 forms because of FOREACH.. I can get Form name =1 form name =10 but I can't get hidden values from the specific form. Can anyone help me? thanks.

[% FOREACH k_bilgi IN k_bilgiler %]
<form name='[% k_bilgi.i%]'>
<input type="hidden" name="itemnumberi" value="[% k_bilgi.itemnumber %]" />
<input type="hidden" name="returndate" value="[% k_bilgi.returndate %]" />
<input type="hidden" name="title" value="[% k_bilgi.title %]" />
<input type="hidden" id="author" name="author" value="[% k_bilgi.author %]" />
<input type="hidden" name="branchname" value="[% k_bilgi.branchname %]" />
</form>
[% END %]

my javascript code (b will be number 1 or 10 or 40)

function gonderildi(b) {
var div1 = document.forms[i];
alert(div1)     // this works.
var a = document.forms[i].elements['itemnumberi'];
alert(a);  // this is not work..

3 Answers :
Bluety answered

It's more simple and powerful if you use id attribute. The query by ID is faster. You can change your code like so :

[% FOREACH k_bilgi IN k_bilgiler %]
    <form name='[% k_bilgi.i%]'>
        <input type="hidden" id="itemnumberi_[% k_bilgi.i%]" name="itemnumberi" value="[% k_bilgi.itemnumber %]" />
    </form>
[% END %]

function gonderildi(b) {
    var div1 = document.forms[i];
    var a = document.forms[i].getElementById('itemnumberi_' + i);
it works. thanks. I don't need to use "form".. very very thanks;
Sagi answered
document.forms[i].querySelector("input[name='itemnumberi']")
sushilprj answered

I think, you need to pass index.. Try this.

function gonderildi(b) {
var div1 = document.forms[i];
alert(div1)     // this works.
var a = document.forms[i].elements[0];
alert(a);  // It should work ..