Fixed csv submission javascript

This commit is contained in:
Candifloss 2025-02-10 13:37:36 +05:30
parent 59526aee24
commit ef951cbb91
2 changed files with 7 additions and 4 deletions

View File

@ -1,5 +1,5 @@
function collectEditedData() { function collectEditedData(event) {
const rows = document.querySelectorAll('tbody tr'); const rows = document.querySelectorAll('.table-new-assets tbody tr');
const assets = []; const assets = [];
rows.forEach(row => { rows.forEach(row => {
@ -19,4 +19,7 @@ function collectEditedData() {
input.name = 'assets'; input.name = 'assets';
input.value = JSON.stringify(assets); input.value = JSON.stringify(assets);
document.querySelector('form').appendChild(input); document.querySelector('form').appendChild(input);
event.target.submit(); // Submit the form after attaching data
return true;
} }

View File

@ -12,7 +12,7 @@
<!-- Display CSV data in a table --> <!-- Display CSV data in a table -->
{% if new_assets %} {% if new_assets %}
<p>New assets:</p> <p>New assets:</p>
<table border="1"> <table border="1" class="table-new-assets">
<thead> <thead>
<tr> <tr>
{% for attrib, config in item_attributes.items() %} {% for attrib, config in item_attributes.items() %}
@ -34,7 +34,7 @@
{% if existing %} {% if existing %}
<p>These assets are already in the database:</p> <p>These assets are already in the database:</p>
<table border="1"> <table border="1" class="table-existing-assets">
<thead> <thead>
<tr> <tr>
{% for attrib, config in item_attributes.items() %} {% for attrib, config in item_attributes.items() %}