fix id and name to be arrays when submitting POST data
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
document.addEventListener("DOMContentLoaded", function () {
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
// Initialize the select options
|
// Initialize the select options
|
||||||
const select = document.getElementById('phrase_detail_data');
|
const select = document.getElementById('phrase_detail_data[0]');
|
||||||
const grp_rec = document.createElement('optgroup');
|
const grp_rec = document.createElement('optgroup');
|
||||||
const grp_snd = document.createElement('optgroup');
|
const grp_snd = document.createElement('optgroup');
|
||||||
|
|
||||||
@@ -77,11 +77,29 @@ function add_row() {
|
|||||||
const tbody = document.getElementById('structure');
|
const tbody = document.getElementById('structure');
|
||||||
const newRow = document.getElementById('recordings_row').cloneNode(true);
|
const newRow = document.getElementById('recordings_row').cloneNode(true);
|
||||||
|
|
||||||
//set id
|
//reset id
|
||||||
newRow.id = 'row_' + tbody.childElementCount
|
newRow.id = 'row_' + tbody.childElementCount
|
||||||
//set 'name' attribute
|
|
||||||
|
//reset 'name' attribute
|
||||||
newRow.setAttribute('name', 'recording_' + tbody.childElementCount);
|
newRow.setAttribute('name', 'recording_' + tbody.childElementCount);
|
||||||
|
|
||||||
|
//get the select boxes
|
||||||
|
const select_list = newRow.querySelectorAll('td select'); //action and recording select dropdown boxes
|
||||||
|
|
||||||
|
//play, pause, execute select box
|
||||||
|
const select_action = select_list[0];
|
||||||
|
|
||||||
|
//recording select box
|
||||||
|
const select_recording = select_list[1];
|
||||||
|
|
||||||
|
//set the new id and name for action
|
||||||
|
select_action.id = 'phrase_detail_function[' + tbody.childElementCount - 1 + ']'
|
||||||
|
select_action.setAttribute('name', 'phrase_detail_function[' + tbody.childElementCount - 1 + ']');
|
||||||
|
//set the new id and name for recording
|
||||||
|
select_recording.id = 'phrase_detail_data[' + tbody.childElementCount - 1 + ']'
|
||||||
|
select_recording.setAttribute('name', 'phrase_detail_data[' + tbody.childElementCount - 1 + ']');
|
||||||
|
|
||||||
|
|
||||||
//add the row to the table body
|
//add the row to the table body
|
||||||
tbody.appendChild(newRow);
|
tbody.appendChild(newRow);
|
||||||
|
|
||||||
@@ -96,3 +114,7 @@ function remove_row() {
|
|||||||
tbody.lastElementChild.remove();
|
tbody.lastElementChild.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function create_new_name() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user