JSFiddle - React, Tailwind, and code Playground
HTML
<form id="form" >
<div>
<p>Choix 1</p>
<label for="prix">Prix: </label><input onChange="onChoiceChange(event.target.value)" id="prix" type="radio" value="prix" name="choix1">
<label for="description">Description: </label><input onChange="onChoiceChange(event.target.value)" id="description" type="radio" value="description" name="choix1">
<label for="name">Name: </label><input onChange="onChoiceChange(event.target.value)" id="name" type="radio" value="name" name="choix1">
</div>
<br/>
<select onChange="onChoice2Change(event.target.value)">
<option value="+1000"> + 1000</option>
<option value="-1000"> - 1000</option>
</select>
<select onChange="onChoice2Change(event.target.value)">
<option value="description1">description 1</option>
<option value="description2">description 2</option>
</select>
<select onChange="onChoice2Change(event.target.value)">
<option value="name1">name 1</option>
<option value="name2">name 2</option>
</select>
<br/>
<br/>
<button id="btn">Envoyer</button>
</form>
JavaScript
console.clear();
let resultat = {
choix1: '',
choix2: ''
}
function onChoiceChange(choice) {
resultat = Object.assign(resultat, {choix1: choice});
//console.log(resultat);
}
function onChoice2Change(choice) {
resultat = Object.assign(resultat, {choix2: choice});
console.log(resultat);
}
const submitBtn = document.getElementById('btn');
submitBtn.addEventListener('click', function(e) {
const form = document.getElementById('form');
e.preventDefault();
console.log(form);
})