I don't now where to put this question, because its a combination of Javavscript/HTML/PHP.
Anyway, I wanted to make a flexible form, which allows the user to enter multiple events for an online agenda.
The user can enter data in several input fields. These input fields are in a table:
Because I wanted to give the user the possible to enter n entries, I added the 'New Row' button. This button calls a function, which copies the entire row. The input fields are made empty:
This works fine in IE, but when multiple events (no matter how many) are posted in Mozilla, only the first comes through. In other words:
always returns:
Array
(
[calendarList] => Kalender 1
[date] => Array
(
[0] => Test
)
[time] => Array
(
[0] => Test
)
[name] => Array
(
[0] => Test
)
[description] => Array
(
[0] => Test
)
[addEvents] => Ok
)
in Mozilla, whereas in IE it returns arrays with multiple entries.
Is this a bug in Mozilla or in my code?
Anyway, I wanted to make a flexible form, which allows the user to enter multiple events for an online agenda.
The user can enter data in several input fields. These input fields are in a table:
Code:
<form action="/Management/calendar.php" method="post">
<table width="100%" class="sortable" id="inputList">
<tr id="inputRow">
<td><input style="width: 80px" name="date[]" type="text"></td>
<td><input style="width: 80px" name="time[]" type="text"></td>
<td><input style="width: 150px" name="name[]" type="text"></td>
<td><input style="width: 270px" name="description[]" type="text">
</td>
</tr>
</table>
<input style="float:right;" width="30px;" type="button" name="addRow" value="New row" onclick="duplicateCleanRowInTable('inputRow')"><p>
<input type="submit" name="addEvents" value="Ok"></p></fieldset>
</form>
Because I wanted to give the user the possible to enter n entries, I added the 'New Row' button. This button calls a function, which copies the entire row. The input fields are made empty:
Code:
<script>
function duplicateCleanRowInTable(rowId)
{
/*
make copy of row
*/
newRow=document.getElementById(rowId).cloneNode(true);
/*
clean up row
*/
newRow.id='';
//walk through all cells and clear contents in form elements
for (i=0; i<newRow.childNodes.length; i++)
{
newRow.childNodes[i].childNodes[0].value='';
}
/*
add new row to table
*/
document.getElementById('inputList').tBodies[0].appendChild(newRow);
}
This works fine in IE, but when multiple events (no matter how many) are posted in Mozilla, only the first comes through. In other words:
Code:
<?php
print_r($_POST);
?>
always returns:
Array
(
[calendarList] => Kalender 1
[date] => Array
(
[0] => Test
)
[time] => Array
(
[0] => Test
)
[name] => Array
(
[0] => Test
)
[description] => Array
(
[0] => Test
)
[addEvents] => Ok
)
in Mozilla, whereas in IE it returns arrays with multiple entries.
Is this a bug in Mozilla or in my code?