41 lines
1.3 KiB
PHP
41 lines
1.3 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Link Page</title>
|
|
</head>
|
|
<body>
|
|
<h1>Links</h1>
|
|
<form id="articleForm">
|
|
<label for="article_id">ID Articolo:</label>
|
|
<input type="text" id="article_id" name="id" />
|
|
<br>
|
|
<button type="button" data-action="search">Cerca Articolo</button>
|
|
<button type="button" data-action="checkPrevendita">E' in PreVendita?</button>
|
|
</form>
|
|
<div id="result"></div>
|
|
|
|
<script>
|
|
const form = document.getElementById('articleForm');
|
|
const result = document.getElementById('result');
|
|
|
|
const buttons = form.querySelectorAll('button');
|
|
buttons.forEach(button => button.addEventListener('click', handleButtonClick));
|
|
|
|
function handleButtonClick(event) {
|
|
const action = event.target.dataset.action;
|
|
const id = form.querySelector('input[name="id"]').value;
|
|
|
|
let baseUrl = window.location.href;
|
|
baseUrl = baseUrl.slice(0, baseUrl.lastIndexOf('/'));
|
|
|
|
fetch(`${baseUrl}/handle-article-action-pao/${id}/${action}`)
|
|
.then(response => response.text())
|
|
.then(data => result.innerHTML = data);
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|
|
|