In my html, I created a table and I fetched in data from a DB. The goal of this table is to give scholar opinion for each student so I created a select dropdown list for each type of school with differents opinions option.

<table>
            <tr>
                <th>Nom</th>
                <th>Prénom</th>
                <th>BTS</th>
                <th>IUT</th>
                <th>Licence</th>
                <th>CPGE</th>
                <th>Ecole</th>
            </tr>
            <!-- PHP CODE TO FETCH DATA FROM ROWS -->
            <?php 
                // LOOP TILL END OF DATA
                while($rows=$result->fetchArray(SQLITE3_ASSOC))
                {
            ?>
<tr>
                <!-- FETCHING DATA FROM EACH
                    ROW OF EVERY COLUMN -->
                <td><?php echo $rows['NOM'];?></td>
                <td><?php echo $rows['PRENOM'];?></td>
                <td><select name="Avis" id="avis_BTS" onchange="change()">
                    <option value="">Avis</option>
                    <option value="TF">Très Favorable</option>
                    <option value="F">Favorable</option>
                    <option value="R">Réservé</option>
                    <option value="D">Défavorable</option>
                    </select>
                </td>
                <td><select name="Avis" id="avis_IUT" onchange="change()">>
                    <option value="">Avis</option>
                    <option value="TF">Très Favorable</option>
                    <option value="F">Favorable</option>
                    <option value="R">Réservé</option>
                    <option value="D">Défavorable</option>
                    </select>
                </td>
                <td><select name="Avis" id="avis_Licence" onchange="change()">>
                    <option value="">Avis</option>
                    <option value="TF">Très Favorable</option>
                    <option value="F">Favorable</option>
                    <option value="R">Réservé</option>
                    <option value="D">Défavorable</option>
                    </select>
                </td>
                <td><select name="Avis" id="avis_CPGE" onchange="change()">>
                    <option value="">Avis</option>
                    <option value="TF">Très Favorable</option>
                    <option value="F">Favorable</option>
                    <option value="R">Réservé</option>
                    <option value="D">Défavorable</option>
                    </select>
                </td>
                <td><select name="Avis" id="avis_Ecole" onchange="change()">>
                    <option value="">Avis</option>
                    <option value="TF">Très Favorable</option>
                    <option value="F">Favorable</option>
                    <option value="R">Réservé</option>
                    <option value="D">Défavorable</option>
                    </select>
                </td>
</tr>
<?php
    }
?>
</table>

I also created a java script file butit doesn’t work :/

// Import in the html

<!DOCTYPE html>
<html lang="fr">
 
<head>
    <meta charset="utf-8">
    <script type="text/javascript" src="script.js"></script>
    <title>Avis Terminales</title>

// JS file

// Initialisation des variables
var avis = "";

// fonction pour bien montrer visuellement au professeur que e choix a été validé
function change() 
{
    if(document.getElementsByID("avis_BTS").value != ""){
        document.getElementById("avis_BTS").style.backgroundColor = "green";
    }
}

// Pour récuperer les avis et les mettres dans une variable pour chaque élève
function save() 
{
    //var avis_bts = document.getElementById("avis_BTS").value;
    // document.write(avis_bts);
    //document.write(5+6);

    let selection = document.getElementById('avis_BTS');
    if(selection.selectedIndex == 1){
        a = "Très Favorable";
    }
    else if(selection.selectedIndex == 2){
        a = "Favorable";
    }
    else{
        a = "Avis";
    }

    document.getElementById('reponse2').innerHTML = "hello";
}

Nothing change on my web page

New contributor

moise_don’t know is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.