Gör det med AJAX så behöver du heller aldrig ladda om sidan.
För svårt är det inte precis som Klas skriver.
Jag skall prova AJAX.
Så här ser min kod ut:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/1999/REC-html401-1999122...">
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>
Error description
</title>
<script type="text/javascript">
function changedEquipmentType()
{
var mylist=document.getElementById("myEquipmentList")
document.getElementByID("BrandFavorite").value=mylist.options[mylist.selectedIndex].text
}
function changedEquipmentBrand()
{
var mylist=document.getElementById("myBrandList")
document.getElementByID("EquipmentFavorite").value=mylist.options[mylist.selectedIndex].text
}
function changedEquipmentBrand()
{
var mylist=document.getElementById("myModelList")
document.getElementByID("ModelFavorite").value=mylist.options[mylist.selectedIndex].text
}
</script>
</head>
<body>
<h1>Error description</h1>
<?php
function load_brand_list($db) {
print ("Brand name<br>\n");
$resultat = mysql_query("SELECT * FROM brand order by brand_name", $db);
print ("<select id=\"myBrandList\" name=\"brand_name\" onchange=\"changedEquipmentBrand()\">");
while ($kolumn = mysql_fetch_array($resultat)) {
print ("<option value=" . $kolumn['brand_name'] . ">" . $kolumn['brand_name'] . "</option>\n");
}
print("</select><br>\n");
}
function load_equipment_list($db) {
print ("Type<br>\n");
$resultat = mysql_query("SELECT * FROM equipment order by equipment_name", $db);
print ("<select id=\"myEquipmentList\" name=\"equipment_name\" onchange=\"changedEquipmentType()\">");
while ($kolumn = mysql_fetch_array($resultat)) {
print ("<option value=" . $kolumn['equipment_name'] . ">" . $kolumn['equipment_name'] . "</option>\n");
}
print("</select><br>\n");
}
function load_model_list($db) {
print ("Model<br>\n");
$resultat = mysql_query("SELECT * FROM model order by model_name", $db);
print ("<select id=\"myModelList\" name=\"model_name\" onchange=\"changedModelType()\">");
while ($kolumn = mysql_fetch_array($resultat)) {
print ("<option value=" . $kolumn['model_name'] . ">" . $kolumn['model_name'] . "</option>\n");
}
print ("</select><br>\n");
}
function load_revision_list($db) {
print ("Revision<br>\n");
$resultat = mysql_query("SELECT * FROM revision order by revision_name", $db);
print ("<select id=\"myRevisionList\" name=\"revision_name\" onchange=\"changedRevisionType()\">");
while ($kolumn = mysql_fetch_array($resultat)) {
print ("<option value=" . $kolumn['revision_name'] . ">" . $kolumn['revision_name'] . "</option>\n");
}
print ("</select><br>\n");
}
// Skapa en databaskoppling
$db = mysql_pconnect("localhost", "xxxxxxxxxx", "yyyyyyyyyy");
print ("Lyckades skapa en databaskoppling<br>\n");
mysql_select_db("knowledge_bank_db", $db);
// Equipment Information
print("<form>");
print("<table border=\"1\">\n");
print("<tr>\n");
print("<th colspan=\"6\">\n");
print("Equipment information");
print("</th>\n");
print("</tr>\n");
print("<tr>\n");
// --- Brand ---
print("<td>\n");
load_brand_list($db);
print ("</td>\n");
// --- Equipment ---
print("<td>\n");
load_equipment_list($db);
print ("</td>\n");
// --- Model ---
print("<td>\n");
load_model_list($db);
print ("</td>\n");
// --- Revision ---
print("<td>\n");
load_revision_list($db);
print ("</td>\n");
// end of Equipment informaton
print("<td>\n");
print("<input value=\"Add new equipment\" type=\"button\"></input>\n");
print("</td>\n");
print("</tr>\n");
print("</table>\n");
print("</form>\n");
mysql_close($db);
print ("Lyckades stänga databaskopplingen<br>\n");
?>
</body>
</html>