It’s been 1 weeks i able not to find the solution, i have a web that create from Flask and javascript.
I have a table on my index.html like this :
<form class="testform" method="post" action="/">
<table class="table">
<thead>
<tr>
<th>Number</th>
<th>Detail</th>
<th>Keterangan</th>
</tr>
</thead>
<tbody class="tbody">
<!-- <tr>
<td>01</td>
<td>Mesin printer</td>
<td>
<button
type="submit"
class="btn--action"
data-id="312324"
name="submit-button"
value="true">
Unduh
</button>
</td>
</tr>
<tr>
<td>02</td>
<td>Layar</td>
<td>
<button
type="submit"
class="btn--action"
data-id="312324"
name="submit-button"
value="true">
Unduh
</button>
</td>
</tr> -->
</tbody>
</table>
</form>
everytime i click the button with “submit-button” as name attribute, my goal is to read or passing the value attribute in Flask,
However, i also have create this table in use insertadjacentHTML in javascript like this :
const html = `<tbody class="tbody">
<tr>
<td>01</td>
<td>Mesin printer</td>
<td>
<button
type="submit"
class="btn--action"
data-id="312323"
name="submit-button"
value="true"
>
Unduh
</button>
</td>
</tr>
<tr>
<td>Divisi</td>
<td>Divisi</td>
<td>
<button
type="submit"
class="btn--action"
data-id="312324"
name="submit-button"
value="true"
>
Unduh
</button>
</td>
</tr>
</tbody>`
tbody.insertAdjacentHTML("afterbegin", html);
tableContainer.classList.remove("hidden");
document.querySelector(".form").scrollIntoView({ behaviour: "smooth" });
tbody.addEventListener("click", function (e) {
if (e.target.classList.contains("btn--action") && e.target.dataset.id) {
//Some Fetch ?
}
}
This is my python.app
@app.route('/', methods=["POST"])
def donglot():
global tanda
global inventaris_url
print(tanda)
if not tanda:
inventaris_url = request.form.get("inventaris_url")
appData= extractappDatafromUrl(inventaris_url )
tanda = True
return jsonify(data=appData)
i tried put request.form.get(“submit-button”) or put request.form[“submit-button”] the result is None or Error.
Kindly please help.
Thank you