Correction examen 4 en HTML , CSS et JS 2-3
- Posted by Riadh HAJJI
- Categories News
- Date 29 avril 2021
Correction examen 4 en HTML , CSS et JS 2-3
-
Recherche, affichage des valeurs dans un tableau
-
Énoncé
- Vous pouvez visualiser l’énoncé de l’exercice
-
Solution : Partie HTML
-
Solution : Partie CSS
-
Solution : Partie Javascript
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css" rel="stylesheet">
<script type="text/javascript" src="tableau.js"/></script>
</head>
<body>
<div class="container-sm">
<form>
<div class="row m-4">
<div class="col-md-2">
<label for="inputCity" class="form-label">Dimension du tableau</label>
<input type="text" class="form-control" id="dim_tab">
</div>
<div class="col-md-2">
<label for="inputState" class="form-label">La valeur minimale</label>
<input type="text" class="form-control" id="borne_inf">
</div>
<div class="col-md-2">
<label for="inputZip" class="form-label">La valeur maximale</label>
<input type="text" class="form-control" id="borne_sup">
</div>
</div>
<div class="col-md-6 ms-2 ">
<div class="row m-4">
<input type="button" class="btn btn-primary btn-block" onclick="Afficher()" value="Générez un tableau"/>
</div>
<div class="row m-4" id="afficherTableau"> </div>
</div>
<div class="row m-4" id="afficherTableau1"> </div>
</form>
</div>
</body>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/js/bootstrap.bundle.min.js"></script>
</html>
<style>
table{border: 3px solid #4a06e7;}
td {
text-align: center;
}
.texteAlternatif{
font-family: sans-serif;
font-size: .7rem;
color: darkorange;
vertical-align:bottom;
text-align: right;
padding-right: -4px;margin-right: -4px;
}
span{ padding-right: -4px;margin-right: -4px;
}
</style>
<script>
function Afficher() {
document.getElementById("afficherTableau").innerHTML="";
document.getElementById("afficherTableau").innerHTML=RemplirTableau();
}
function randomInteger(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function RemplirTableau(){
var dim_tab=document.getElementById("dim_tab").value;
var borne_inf=document.getElementById("borne_inf").value;
var borne_sup=document.getElementById("borne_sup").value;
var res="";
if(isNaN(dim_tab) == true || isNaN(borne_inf)==true || isNaN(borne_sup)==true
|| dim_tab == '' || borne_inf=='' || borne_sup==''|| borne_inf>=borne_sup)
{
res="Une faute...";
}
else{
var T=new Array();
var Tab2=new Array();
var nbr=0;
//Remplissage
for(var i=0;i<parseInt(dim_tab);i++){
nbr=randomInteger(parseInt(borne_inf), parseInt(borne_sup));
T[i]=nbr;
Tab2[i]=nbr;
}
//Affichage
res="<table class='table table-bordered table-striped'><tr>";
var largeur=0;
for(var i=0;i<T.length;i++)
{
if ( largeur<9)
{
res+= "<td>"+T[i]+"<sub> <span class='texteAlternatif'></span></td>";
largeur+=1;
}
else{
res+= "<td>"+T[i]+"<sub> <span class='texteAlternatif'></span></td></tr><tr>";
largeur=0;
}
}
res+= "</tr></table>";
//////////
return res;
}
}
//result;
</script>
Riadh HAJJI
You may also like
MOS PowerPoint 2019 projet 01
Projet 01 Projet 02 Préparer et réussir la certification MOS PowerPoint 2019 Projet 01 Tâche 01: Créer un dossier et télécharger les fichiers de travail mes Aventures 1.Configurez les options d’impression de façon à imprimer cinq copies des Pages de notes de …
Where architecture meets news
The ways without commission are Skrill, Qiwi, Neteller, Visa and Mastercard. There is no commission charged on forex and valuable metals. Nonetheless, there is a genuinely perplexing and variable commission structure for the wide range of various resources. So regardless …
الإمتحانات والأسئلة لسنة 2017
الإمتحانات والأسئلة لسنة 2017 الفهرس النظام الاساسي الخاص بأعوان الوكالة التونسية للتكوين المهني طبقا للامر الحكومي 856 لسنة 2017 المؤرخ في 8 أوت 2017 ملاحظة: بالنسبة للاسئلة المقترحة تهم الفصول المنقحة والقديمة التي لم تنقح الاختبارات النفسية تصفح الاختبارات النفسية …