Mentions légales du service

Skip to content
Snippets Groups Projects
Commit a91edc79 authored by Léo PASQUEREAU's avatar Léo PASQUEREAU
Browse files

Create noteForm.html

parent e386ea53
No related branches found
No related tags found
7 merge requests!101Taking Cool-in-v2 into test,!100Deploying Cool-in campain,!99Preparing Cool-in campain,!96M2-2022,!95Final merge,!94Merge JS branch into HW,!90Note js
<center>
<h2>Formulaire</h2>
<form name="noteForm">
<fieldset >
<legend>Note the stress level of this todo</legend>
<strong>Not stressful</strong>
<input type="radio" name="stress" id="1" value="1"/>
<label for="1">1</label>
<input type="radio" name="stress" id="2" value="2"/>
<label for="2">2</label>
<input type="radio" name="stress" id="3" value="3"/>
<label for="3">3</label>
<input type="radio" name="stress" id="4" value="4"/>
<label for="4">4</label>
<input type="radio" name="stress" id="5" value="5"/>
<label for="5">5</label>
<input type="radio" name="stress" id="6" value="6"/>
<label for="6">6</label>
<input type="radio" name="stress" id="7" value="7"/>
<label for="7">7</label>
<input type="radio" name="stress" id="8" value="8"/>
<label for="8">8</label>
<input type="radio" name="stress" id="9" value="9"/>
<label for="9">9</label>
<input type="radio" name="stress" id="10" value="10"/>
<label for="10">10</label>
<strong>Extremely stressful</strong>
</fieldset>
</form>
<button>Submit</button>
</center>
<h2>Récupération des données du formulaire</h2>
<div id="json">
<span></span>
</div>
<script type="text/javascript">
/* escape = function (str) {
return str
.replace(/[\\]/g, '\\\\')
.replace(/[\"]/g, '\\\"')
.replace(/[\/]/g, '\\/')
.replace(/[\b]/g, '\\b')
.replace(/[\f]/g, '\\f')
.replace(/[\n]/g, '\\n')
.replace(/[\r]/g, '\\r')
.replace(/[\t]/g, '\\t');
};*/
//Le bouton qui va déclencher le script js
let btnSubmit = document.querySelector("button");
btnSubmit.addEventListener("click", () => {
//check si le formulaire a été correctement rempli
//on crée un formData
let fd = new FormData();
//on réccupère les données du formulaire
let stress = document.querySelectorAll("input[name = 'stress']");
for(i=0; i<stress.length; i++){
if(stress[i].checked){
NiveauStress = stress[i].value;
}
}
//on rempli notre FormData
fd.append("NiveauStress", NiveauStress);
console.log(Array.from(fd));
let JSONString = JSON.stringify(Array.from(fd));
console.log(JSONString);
//let EscapedJSONString = escape(JSONString);
// console.log(EscapedJSONString);
document.querySelector("#json span").textContent = JSONString;
})
</script>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment