I'm trying to do a form with a get method but I have a problem. I don't know how to get the value `. I do this code but is not working, I don't understand why.
I know this code is very simple, but I want to understand how to use the get method:
document.querySelector("button").addEventListener("click", function() {
console.log('Click détecté ');
var form = document.createElement('form');
form.setAttribute('method', 'GET');
form.setAttribute('action', 'test1.php');
document.body.appendChild(form);
let monSelect = document.createElement('select');
let monOption = document.createElement('option');
monOption.setAttribute('value', 1);
monOption.innerText = 'choice1';
monSelect.appendChild(monOption);
let monOption2 = document.createElement('option');
monOption2.setAttribute('value', 2);
monOption2.innerText = 'choice2';
monSelect.appendChild(monOption2);
form.appendChild(monSelect);
let input = document.createElement('input')
input.setAttribute('type', "submit");
input.setAttribute('value', "submit");
form.appendChild(input);
}
);
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Quelques langages</title>
</head>
<body>
<button id="test">Ajouter un block</button>
<script src="test.js"></script>
<script src="jquery-3.3.1.min.js"></script>
</body>
</html>
<?php
var_dump($_GET['typecolonne']);
?>
`