Jump to content
  • 0

JavaScript homework need help


Cayen

Question

basically since i cant put french words in english on how to do the work i have to make a javascript code that tells you what is the maximum value in between the numbers 7 and 8, and the minimu value between 2 and 4 using the if, else if , and basically i have to compare but im having issues with my coding anyone want to help me? this is for a college class..

Link to comment
Share on other sites

12 answers to this question

Recommended Posts

  • 0

I can help you on that either in french or english you choose.

I don't see why you want to do that but post your actual code and i'll see what I can do.

basically since i cant put french words in english on how to do the work i have to make a javascript code that tells you what is the maximum value in between the numbers 7 and 8, and the minimu value between 2 and 4 using the if, else if , and basically i have to compare but im having issues with my coding anyone want to help me? this is for a college class..
Edited by Levesque 1st MRB
Link to comment
Share on other sites

  • 0

alright so this is what i have to do

<script language="javascript">
<!--
function creerTable1()
{
document.write("<table border=1>");
document.write("<tr>");
document.write("<td>");
document.write(" "); //   désigne une espace insécable (non breaking space)
document.write("</td>");
document.write("</tr>");
document.write("</table>")
}
// -->
</script>

Inspirez-vous de la fonction CreerTable1() ci-dessus pour créer une fonction CreerTable2 qui permette de créer une table HTML aux dimensions spécifiées par les paramètres. Le premier paramètre spécifie le nombre de rangées et le deuxième, le nombre de colonnes. Indice: vous devez utiliser des itérations (boucles) ....

and then this is what i have for now i want to know if im on the right track

<Html>
<Head>
<Title> Exercices 2</Title>
<script language="javascript">
<!--
function creerTable1(nbligne,nbcolonne)
{
document.write("<table border=1>");
document.write("<br>");
for (i=0;i<nbligne;i++){
document.write("<tr>");
for (j=0;j<nbcolonne;j++){
document.write("<td>");
document.write(" ");
document.write("</td>");
}
document.write("</tr>");
}
document.write("</table>")
}
// -->
</script>
</head>
<Body onload="creerTable1(5,3)">
<Table BorderCellPadding=10>
</Body>
</Html>

Link to comment
Share on other sites

  • 0

Alright yet another problem i cant remember how to make a usefull alert() window, to show the information gathered from the name and everything this is the question.

so yeah if i didnt explain clearly enough i will be on vent at around 4 pm eastern, to get help thanks for all the help i got already guys.

Pour cette tâche vous devrez utiliser votre connaissance des tableaux et des boîtes de dialogue.

Dans une premier temps vous devrez définir un tableau de 3 éléments. Chacun des éléments sera associé à un prénom différent.

Ensuite vous devrez réaliser une première fonctions qui permettera d'ajouter un prénom dans le tableau. La fonction prendra en paramètre le tableau préalablement créé et retournera un tableau contenant un élément supplémentaire dont la valeur sera le prénom que l'on souhaite ajouter. Vous devrez utiliser la boîte de dialogue de type prompt pour demander à l'usager de spécifier le prénom qu'il souhaite ajouter au tableau.

Vous devrez également réaliser une seconde fonction qui aura pour but d'afficher les prénom qui sont compris dans les différents éléments du tableau. Cette fonction prendra également le tableau en paramètre et procèdera à l'affichage des noms à l'aide d'une boîte de dialogue de type alert qui contient l'ensemble des prénom séparé par des ";".

<html>
<head>
<title>Ex. 4</title>
<Table border="1" cellpading="5">
<FORM name="mon_formulaire">
<tr><td><INPUT type=text  value="" name="mon_champ_texte" onBlur="this.style.backgroundColor='yellow'"  readonly ><INPUT type=button value="Prenom" onClick="PromptMessage()"></tr></td>
</FORM>
<script language=javascript>
   function PromptMessage() {
       var saisie = prompt("Saisissez votre texte :", "Texte par défaut")
       if (saisie!=null) {
           document.forms["mon_formulaire"].elements["mon_champ_texte"].value=saisie;
       }
   }
</SCRIPT>
<FORM name="mon_formulaire1">
<tr><td><INPUT type=text  value="" name="mon_champ_texte1" onBlur="this.style.backgroundColor='yellow'"  readonly ><INPUT type=button value="Nom" onClick="PromptMessage1()"></tr></td>
</FORM>
<script language=javascript>
   function PromptMessage1() {
       var saisie1 = prompt("Saisissez votre texte :", "Texte par défaut")
       if (saisie1!=null) {
           document.forms["mon_formulaire1"].elements["mon_champ_texte1"].value=saisie1;
       }
   }
</SCRIPT>
<FORM name="mon_formulaire2">
<tr><td><INPUT type=text  value="" name="mon_champ_texte2" onBlur="this.style.backgroundColor='yellow'"  readonly ><INPUT type=button value="Age" onClick="PromptMessage2()"></tr></td>
</FORM>
<script language=javascript>
   function PromptMessage2() {
       var saisie2 = prompt("Saisissez votre texte :", "Texte par défaut")
       if (saisie2!=null) {
           document.forms["mon_formulaire2"].elements["mon_champ_texte2"].value=saisie2;
       }
   }
   </SCRIPT>
   <FORM name="mon_formulaire3">
   <tr><td><INPUT type=button value="Afficher donnée" name="">
    <script language=javascript>
    function  promptmessage3() {
    var a = "mon_formulaire";
    var b = "mon_formulaire1";
    var c = "mon_formulaire2";
    var d = a+b+c
       var vos_donnée = alert(d);
       if (vos_donnée!=null) {
            
       }
    }  
</SCRIPT>
<body bgcolor="Blue">
</body>
</html>

Link to comment
Share on other sites

  • 0

I believe when your teacher told you about "tableau" he meant arrays instead of tables.

So here is a startup you can use :

<html>

<head>

</head>

<title>Ex. 4</title>

<body bgcolor="Blue">

<script language=javascript>

var monTableauDePrenom = new Array(3);

monTableau [0] = "Prenom1";

monTableau [1] = "Prenom2";

monTableau [2] = "Prenom3";

var monTableauPlusGrand = new Array(4);

monTableauPlusGrand = ajouterPrenom(monTableauDePrenom);

//TODO afficher le tableau

function ajouterPrenom(monTableauDePrenom) {

var monTableau = new Array(4);

monTableau [0] = monTableauDePrenom [0]

monTableau [1] = monTableauDePrenom [1]

monTableau [2] = monTableauDePrenom [2]

monTableau [3] = "Prenom4";

return monTableau;

}

</SCRIPT>

</body>

</html>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Recent Posts

    • 2nd Platoon Weekly Attendance   Week of 05MAY2024   P = Present | E = Excused | A = Absent   Platoon Staff WO. A. Pitteway - Excused MSgt. J. Candy - Excused TSgt. A. Yoder - Present   1st Squad Squad leader:  Cpl. R. Fielding - Excused Cpl. B. Grande - Present Pfc. R. Smith - Present Pfc. X. Hocker - Excused Pvt. B. Niles - Excused* Resigned Pvt. M. Noel - Present   2nd Squad Squad leader:  Cpl. C. Dilley - Present Cpl. H. Nielsen - Absent Cpl. S. Holquist - Excused Pfc. T. Scary - Present Pfc. C. Marsh - Excused Pvt. K. Bradley - Absent   Reserves: Pvt. T. Mongillo - Excused, Pfc. M. Oake - Excused   Helpers: CWO. R. Martinez   Attendance Policy    1. Each Week you must submit a TDR through Perscomm on the website before practice starts     2. If you do not submit a TDR you will get an Unexcused absence    3. Three (3) Unexcused absences in a row you receive an Infraction Report with a possible demerit with Command Staff approval.    4. Five (5) Unexcused absences in a row will result in being moved from Active duty to Reserves   If you need any assistance learning how to fill out a TDR contact your Squad Leader or your Platoon Sergeant.
    • Dear Rec. S. Garrison,    Due to unforeseen circumstances with your family, and discussion with Myself, you have opted to rescind your application.     If in the future you decide to come back to the 1st Marine Raiders, we will be here.    Best of luck, and hope everything turns out for the best    
    • Welcome to the 1st Marine Raider Battalion! Now that you have been accepted don't forget to: 1. Check in at the Recruit Depot 2. Read the Marine Raider Handbook (you are expected to know everything in it) 3. Change your steam friends Avatar 4. Download, install and log into Discord NOTE: Please be aware that you will not have access to the above links until an officer has given you full access to the forum. Access to the forum should be given to you within the next day.
×
×
  • Create New...