Array in parameter


I have here code that sends values via ajax. That values includes an array.

<script type = 'text/javascript'>
function insert() {
 xmlhttp = new XMLHttpRequest();
} else {
xmlhtttp = new ActiveXObject('Microsoft.XMLHttp');

xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState ==4 && xmlhttp.status == 200) {
		document.getElementById('message').innerHTML = xmlhttp.responseText;

parameters = 'keyword='+document.getElementById('keyword').value + '&accnum='+document.getElementsByName('accnum[]').value;
/*"parameter1=" + parameter1.value + "&parameter2=" + parameter2.value*/'POST', 'Borrow_2.php', true);
xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');

<script type = 'text/javascript'>
function addRow()
    cell1 = document.createElement("TD");

<form id="test" onsubmit="return false;" autocomplete="off">
 <div class="main">

  <tbody id="inputtable">
     	 <div id="holder">
		 <p>Student ID: <input type="text" id="keyword" tabindex="0" name = 'keyword'></p>
		  <div id="ajax_response"></div>
		 <tr><td>SAccession No: <input type="text" id="accnum" tabindex="0" name = 'accnum[]' >
		 <input type="button" value="Add new" onclick="addRow();" /></td></tr>		
		  <input type="submit" value="submit" onClick="insert();"/>

My problem is I can’t get the value of my accnum.
I think the problem is this line, and I don’t know how to fix it.

parameters = 'keyword='+document.getElementById('keyword').value + '&accnum='+document.getElementsByName('accnum[]').value;

When I used var_dump(); it says that ‘undefined strings’. What’s that mean? thank you.

The getElementsByName method returns an array-like object.

Consider for example if you have multiple radio buttons with the same name. The getElementsByName method gives you an array elements that match the name.
Even if you end up with one element being found, that will still be in the array-like structure, so you need to specify the index of the item you want to use, that being an index of 0.

... + document.getElementsByName('accnum[]')[color="green"][0][/color].value;

Thank you very much for your response.

I’m using an array of textbox, that when the user hit the add new textbox button it will add new row of textbox.
I tried the code below but it only shows the first value of my textbox. I understand now the index value when it is specified.
but I don’t have any idea how to do it in textbox.

parameters = 'keyword='+document.getElementById('keyword').value + '&accnum='+document.getElementsByName('accnum[]')[0].value;