254 lines
6.6 KiB
HTML
254 lines
6.6 KiB
HTML
|
<!DOCTYPE html>
|
||
|
<html>
|
||
|
|
||
|
<head>
|
||
|
<title> max premier du nom
|
||
|
</title>
|
||
|
<style>
|
||
|
.bouton-c {
|
||
|
width: 50px;
|
||
|
}
|
||
|
|
||
|
.bouton-m {
|
||
|
width: 45px;
|
||
|
}
|
||
|
</style>
|
||
|
</head>
|
||
|
|
||
|
<body>
|
||
|
<div>
|
||
|
<button id="7" class="bouton-c">7</button>
|
||
|
<button id="8" class="bouton-c">8</button>
|
||
|
<button id="9" class="bouton-c">9</button>
|
||
|
<button id="-" class="bouton-m">-</button>
|
||
|
</div>
|
||
|
<div>
|
||
|
<button id="4" class="bouton-c">4</button>
|
||
|
<button id="5" class="bouton-c">5</button>
|
||
|
<button id="6" class="bouton-c">6</button>
|
||
|
<button id="+" class="bouton-m">+</button>
|
||
|
</div>
|
||
|
<div>
|
||
|
<button id="1" class="bouton-c">1</button>
|
||
|
<button id="2" class="bouton-c">2</button>
|
||
|
<button id="3" class="bouton-c">3</button>
|
||
|
<button id="x" class="bouton-m">x</button>
|
||
|
</div>
|
||
|
<div>
|
||
|
<button class="bouton-c"></button>
|
||
|
<button id="0" class="bouton-c">0</button>
|
||
|
<button id="," class="bouton-c">,</button>
|
||
|
<button id="/" class="bouton-m">/</button>
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
<input type="text" id="oui"> <br>
|
||
|
<input type="text" id="nom">
|
||
|
<input type="text" id="memoir1">
|
||
|
<input type="text" id="memoir2">
|
||
|
|
||
|
<input type="reset" id="reset" value="reset">
|
||
|
<input type="submit" id="valider" value="valider">
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
</body>
|
||
|
|
||
|
<script>
|
||
|
|
||
|
document.getElementById("7").addEventListener("click", nombre_7)
|
||
|
function nombre_7(ev) {
|
||
|
let nomb7 = document.getElementById("oui")
|
||
|
nomb7.value += "7"
|
||
|
}
|
||
|
|
||
|
document.getElementById("8").addEventListener("click", nombre_8)
|
||
|
function nombre_8(ev) {
|
||
|
let nomb8 = document.getElementById("oui")
|
||
|
nomb8.value += "8"
|
||
|
|
||
|
}
|
||
|
|
||
|
document.getElementById("9").addEventListener("click", nombre_9)
|
||
|
function nombre_9(ev) {
|
||
|
let nomb9 = document.getElementById("oui")
|
||
|
nomb9.value += "9"
|
||
|
|
||
|
}
|
||
|
|
||
|
document.getElementById("4").addEventListener("click", nombre_4)
|
||
|
function nombre_4(ev) {
|
||
|
let nomb4 = document.getElementById("oui")
|
||
|
nomb4.value += "4"
|
||
|
|
||
|
}
|
||
|
|
||
|
document.getElementById("5").addEventListener("click", nombre_5)
|
||
|
function nombre_5(ev) {
|
||
|
let nomb5 = document.getElementById("oui")
|
||
|
nomb5.value += "5"
|
||
|
|
||
|
}
|
||
|
|
||
|
document.getElementById("6").addEventListener("click", nombre_6)
|
||
|
function nombre_6(ev) {
|
||
|
let nomb6 = document.getElementById("oui")
|
||
|
nomb6.value += "6"
|
||
|
|
||
|
}
|
||
|
|
||
|
document.getElementById("1").addEventListener("click", nombre_1)
|
||
|
function nombre_1(ev) {
|
||
|
let nomb1 = document.getElementById("oui")
|
||
|
nomb1.value += "1"
|
||
|
|
||
|
}
|
||
|
|
||
|
document.getElementById("2").addEventListener("click", nombre_2)
|
||
|
function nombre_2(ev) {
|
||
|
let nomb2 = document.getElementById("oui")
|
||
|
nomb2.value += "2"
|
||
|
|
||
|
}
|
||
|
|
||
|
document.getElementById("3").addEventListener("click", nombre_3)
|
||
|
function nombre_3(ev) {
|
||
|
let nomb3 = document.getElementById("oui")
|
||
|
nomb3.value += "3"
|
||
|
|
||
|
}
|
||
|
document.getElementById("0").addEventListener("click", nombre_0)
|
||
|
function nombre_0(ev) {
|
||
|
let nomb0 = document.getElementById("oui")
|
||
|
nomb0.value += "0"
|
||
|
|
||
|
}
|
||
|
document.getElementById(",").addEventListener("click", nombre_vigule)
|
||
|
function nombre_vigule(ev) {
|
||
|
let nombvirg = document.getElementById("oui")
|
||
|
nombvirg.value += "."
|
||
|
}
|
||
|
// les symboles
|
||
|
|
||
|
document.getElementById("-").addEventListener("click", symbole_min)
|
||
|
function symbole_min(ev) {
|
||
|
let symbmin = document.getElementById("memoir2")
|
||
|
symbmin.value = "-"
|
||
|
valider_f()
|
||
|
}
|
||
|
document.getElementById("+").addEventListener("click", symbole_plus)
|
||
|
function symbole_plus(ev) {
|
||
|
let symbpl = document.getElementById("memoir2")
|
||
|
symbpl.value = "+"
|
||
|
valider_f()
|
||
|
}
|
||
|
document.getElementById("x").addEventListener("click", symbole_x)
|
||
|
function symbole_x(ev) {
|
||
|
let symbx = document.getElementById("memoir2")
|
||
|
symbx.value = "x"
|
||
|
valider_f()
|
||
|
}
|
||
|
document.getElementById("/").addEventListener("click", symbole_div)
|
||
|
function symbole_div(ev) {
|
||
|
let symbdiv = document.getElementById("memoir2")
|
||
|
symbdiv.value = "/"
|
||
|
valider_f()
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
document.getElementById("valider").addEventListener("click", valider_f);
|
||
|
// console.log(document.getElementById("nom"))
|
||
|
// console.log(document)
|
||
|
function valider_f(ev) {
|
||
|
var element_oui = document.getElementById("oui")
|
||
|
//console.log(ev)
|
||
|
let val = element_oui.value
|
||
|
console.log(val)
|
||
|
if (val === "") {
|
||
|
console.log("met un truc !")
|
||
|
return
|
||
|
}
|
||
|
let val_int = parseFloat(val)
|
||
|
console.log(val_int)
|
||
|
|
||
|
element_oui.value = ""
|
||
|
|
||
|
let en_mem = document.getElementById("memoir1").value
|
||
|
if (en_mem !== "") {
|
||
|
let final = 0;
|
||
|
let en_mem_int = parseFloat(en_mem)
|
||
|
let mem_symb = document.getElementById("memoir2").value
|
||
|
|
||
|
if (mem_symb === "/") {
|
||
|
final = val_int / en_mem_int
|
||
|
} else if (mem_symb === "x") {
|
||
|
final = val_int * en_mem_int
|
||
|
} else if (mem_symb === "-") {
|
||
|
final = val_int - en_mem_int
|
||
|
} else if (mem_symb === "+") {
|
||
|
final = val_int + en_mem_int
|
||
|
}
|
||
|
|
||
|
element_oui.value = final
|
||
|
|
||
|
//document.getElementById("memoir1").value = final
|
||
|
return
|
||
|
}
|
||
|
|
||
|
|
||
|
document.getElementById("memoir1").value = val_int
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
//s'assurer que c'est des valeur numerique
|
||
|
|
||
|
|
||
|
//do...while
|
||
|
//Document.querySelectorAll()
|
||
|
// Document.querySelector()
|
||
|
// ici je pense que je devrais mettre mes fonctions de calcul puisque ce sera rattacher a l'action de valide
|
||
|
// faire une operation destructive
|
||
|
// faire des valeures numérique
|
||
|
// faire les multiplication et division avec en faire une val
|
||
|
// faire les addition et soustraction avec une autre val
|
||
|
// faire une variable resultat final ?
|
||
|
// 5+8*2
|
||
|
// faire 2 fichier temporaire au cas ou il y a plusieur multi
|
||
|
// je pense faire regarder la totaliter et faire calculer les multiplication & division, et ensuite faire addition/soustration.
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
document.getElementById("reset").addEventListener("click", reset_8)
|
||
|
function reset_8(ev) {
|
||
|
|
||
|
|
||
|
document.getElementById("nom").value = ""
|
||
|
|
||
|
document.getElementById("oui").value = ""
|
||
|
|
||
|
document.getElementById("memoir1").value = ""
|
||
|
|
||
|
document.getElementById("memoir2").value = ""
|
||
|
|
||
|
//console.log(prout.value)
|
||
|
// console.log(document.getElementById("oui").value)
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
</script>
|
||
|
|
||
|
</html>
|