Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Javascript table problem

Featured Replies

Hi everyone!

 

I'm new to Javascript and I just can't figure how to make it work. it look ok for me but :wacko: First homework that make me want to smash my head on my keyboard.

 

It's in the fonction monChoix(). It don't seem to recognize the conditions use with the value of the table disponible[noSiege].

 

The error console of firefox see nothing at all.

sorry for my lame english XD.

 

 

 

 

<script type="text/javascript">

 

 

//déclaration des variables globales

var qualite;

var disponible;

 

 

function depart() {

qualite = [3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3];

disponible = [true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,

true,true,true,true,true,true,true,true,true,true,true,true,true,true,true];

document.getElementById("lblTotal").innerHTML = qualite.length;

document.getElementById("lblDispo").innerHTML = qualite.length;

} //fin depart

 

function afficherSalle() {

var i;

for(i=0;i<36; i++){

if(disponible == true){

disponible = "D";

}

else{

disponible = "V";

}

}

alert("État des ventes: " + disponible.join(" "));

 

} //fin afficherSalle

 

function meilleur() {

 

} //fin meilleur

 

function monChoix() {

 

var noSiege = parseInt(document.getElementById("txtNoSiegeLu")).value;

 

if(disponible[noSiege] == true){

document.getElementById("lblNoSiegeAchat").innerHTML = noSiege;

}

else{

if(disponible[noSiege] == false){

document.getElementById("errtxtNoSiegeLu").innerHTML = "Malheureusement, ce siege n'est pas disponible";

}

else if(disponible[noSiege] == isNaN){

document.getElementById("errtxtNoSiegeLu").innerHTML = "Vous devez specifier un nombre";

}

else if(disponible[noSiege] == ""){

document.getElementById("errtxtNoSiegeLu").innerHTML = "Vous devez specifier le numero du siege";

}

else{

document.getElementById("errtxtNoSiegeLu").innerHTML = "Numero de siege inexistant";

}

}

} //fin monChoix

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.