Sorry to bother you, but im really stuck and google was no help 🙂
test1.php:
// In te vullen waardes
$startjaar = 2005;
// Einde in te vullen waardes
// include('connect.php');
if (isset($_REQUEST['dag'])) $dagstr = $_REQUEST['dag'];
if (isset($_REQUEST['maand'])) $maandstr = $_REQUEST['maand'];
if (isset($_REQUEST['jaar'])) $jaarstr = $_REQUEST['jaar'];
// filling the first dropbox, the daynumbers
$select1 = "<select name=\"dag\">\n";
for ($i=1; $i <= 31; $i++) {
$select1 .= "<option value=\"$i\">$i</option>\n";
}
$select1 .="</select>";
// filling the second dropbox, making an array with the months first,
// then use it for the dropbox
$select2 = "<select name=\"maand\">\n";
$maand [1] = "Januari";
$maand [2] = "Februari";
$maand [3] = "Maart";
$maand [4] = "April";
$maand [5] = "Mei";
$maand [6] = "Juni";
$maand [7] = "Juli";
$maand [8] = "Augustus";
$maand [9] = "September";
$maand [10] = "Oktober";
$maand [11] = "November";
$maand [12] = "December";
for ($i=1; $i <= 12; $i++) {
$select2 .= "<option value=\"$i\">$maand[$i]</option>\n";
}
$select2 .= "</select>";
// finding out how many years have past since $startjaar (startyear)
// then building the array from $startyear till current year
// then building the dropbox with the information gathered.
$select3 = "<select name=\"jaar\">\n";
$huidigjaar = date("Y");
$aantaljaar = ($huidigjaar - $startjaar) + 1;
for ($i=1; $i <= $aantaljaar; $i++) {
$jaar [$i] = $startjaar + $i -1;
}
for ($i=1; $i <= $aantaljaar; $i++) {
$select3 .= "<option value=\"$jaar[$i]\">$jaar[$i]</option>\n";
}
$select3 .= "</select>\n";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<form action="test1.php" method="post" name="form1" id="form1" >
<?php print $select1 ?><?php print $select2 ?><?php print $select3 ?><br />
<input type="submit" name="submit" value="submit" />
</form>
<br /><br />
Datum: <?= $dagstr ?> de/ste van de maand <?= $maandstr ?> en jaar <?= $jaarstr ?> <br />
testje: <?= $maand[3] ?>
</body>
</html>
Sorry for the dutch 🙂
Anyway it works perfectly. You get 3 selection boxes,
one with 1-31
one with Januari - December
one with 2005 and 2006
[1]V [Januari]V [2005]V
So no problems there...
but then... as soon as you press the submit button, the sites get reloaded (because the target is the same site... test1.php)
and then the dropboxes are like this:
[1]V [J]V [2]V
how can that happen? why the code works, but doesnt when the site gets reloaded? i really cant figure out what i did wrong
all the array got cut off to 1 character only 🙁
Sorry to waste your time, but if you can help me.. you get infinite thanks 🙂