Die Idee ist, beim Ändern der Auswahl einen AJAX-Request auszulösen und den Wert zu übergeben.
HTML:
<select name="sometest" onchange="call_ajax_fun(this.value)">
<option value="1">A</option>
<option value="2">B</option>
</select>JavaScript:
function call_ajax_fun(str) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
document.getElementById('your_result_div_id').innerHTML =
xhr.responseText;
}
};
xhr.open('GET', 'get_result.php?pas_val=' + encodeURIComponent(str), true);
xhr.send();
}PHP:
<?php
if (isset($_REQUEST['pas_val'])) {
$pas_val = $_REQUEST['pas_val'];
$tbl = $pas_val < 5 ? 'table_1' : 'table_2';
// Abfrage ausführen
} else {
exit;
}