hip1/16.2/ajax.php

<?php include('../db.php'); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <link href="ajax.css" rel="stylesheet" type="text/css"> <script src="ajax.js"></script> <script> window.onload = starten; function starten(){ document.getElementById('auteurs').onchange = boekenlijst; } function uitleningen(lijst){ var id = lijst.options[lijst.selectedIndex].value ajax('uitleningen.php?boeknr=' + id,'boekuitlening') } function boekenlijst(){ //ajax aanroepen var auteurs = document.getElementById('auteurs') var id = auteurs.options[auteurs.selectedIndex].value ajax('boekenlijst.php?auteurnr=' + id,'boekenselect') } </script> </head> <body> <div id='container'> <div id='right'> <div id='ajax'> <h3 align="center">A.J.A.X.</h3> <p align="right"><input type="checkbox" id='alertRespons'>Alert antwoord</p> <div id='ajaxtext'></div> </div> </div> <?php include('../db.php'); $query = "select auteurnr, voornaam, tussenvoegsel, achternaam from auteurs order by achternaam"; $result = mysqli_query($db, $query) ; echo "<form><p>"; echo "<span class='label'>Auteurs :</span>"; echo "<span class='info'>"; echo "<select name='auteurnr' id='auteurs'>"; echo "<option value=''></option>"; $selected[$auteurnr]='selected'; while($row = mysqli_fetch_array($result)){//auteurs langs echo "<option value='$row[auteurnr]' ". $selected[$row['auteurnr']].">$row[achternaam], $row[voornaam] $row[tussenvoegsel]</option>"; } echo "</select></span>"; echo "</p></form>"; echo "<p>"; echo "<span class='label'>Boeken :</span>"; echo "<span class='info'>"; echo "<span id ='boekenselect'></span>"; echo "</span>"; echo "</p>"; echo "<p>"; echo "<span class='label'>Uitleningen :</span>"; echo "<span class='info'>"; echo "<span id ='boekuitlening'></span>"; echo "</span>"; echo "</p>"; ?> </div> </html>

Resultaat

Made by Thijs Aarnoudse