Add row button operational

This commit is contained in:
2021-04-14 17:32:01 +02:00
parent 4648bd73ad
commit 49fb63561d
4 changed files with 30 additions and 2 deletions

View File

@@ -99,7 +99,7 @@
<tr>
<td><input id="headerKeyInput" placeholder="name"></td>
<td><input id="headerValueInput" placeholder="value"></td>
<td><button class="modification-button btn-add"><i class="icon-plus"></i></button></td>
<td><button id="btn-newRow" class="modification-button btn-add"><i class="icon-plus"></i></button></td>
</tr>
</table>
</div>

View File

@@ -251,6 +251,20 @@ function addRow(key, value){
headerMap.html(headersMapHtml);
}
const newRowInput = function(){
const hName = $('#headerKeyInput').val();
const hValue = $('#headerValueInput').val();
if(checkIfInputValid(hName) && checkIfInputValid(hValue)){
addRow(hName, hValue);
}
}
$('#btn-newRow').click(newRowInput);
function checkIfInputValid(input){
return !(input == '' || input == null || input == undefined);
}
function buildRowHtml(key, value){
return '' +
'<tr>' +

View File

@@ -99,7 +99,7 @@
<tr>
<td><input id="headerKeyInput" placeholder="name"></td>
<td><input id="headerValueInput" placeholder="value"></td>
<td><button class="modification-button btn-add"><i class="icon-plus"></i></button></td>
<td><button id="btn-newRow" class="modification-button btn-add"><i class="icon-plus"></i></button></td>
</tr>
</table>
</div>

View File

@@ -251,6 +251,20 @@ function addRow(key, value){
headerMap.html(headersMapHtml);
}
const newRowInput = function(){
const hName = $('#headerKeyInput').val();
const hValue = $('#headerValueInput').val();
if(checkIfInputValid(hName) && checkIfInputValid(hValue)){
addRow(hName, hValue);
}
}
$('#btn-newRow').click(newRowInput);
function checkIfInputValid(input){
return !(input == '' || input == null || input == undefined);
}
function buildRowHtml(key, value){
return '' +
'<tr>' +