Jump to content

Form automatic fill space between Years


dani33l_87

Recommended Posts

I have this form:

 

 
Start Year:
<select name="start"><option value="" selected="selected"></option>
<option value="1991">1991</option><option value="1992">1992</option><option value="1993">1993</option><option value="1994">1994</option></selected.
 
to:
<select name="end"><option value="" selected="selected"></option>
<option value="2015">2015</option><option value="2014">2014</option><option value="2013">2013</option><option value="2012">2012</option>
<option value="2001">2001</option><option value="2010">2010</option></select>
 
 
$start = $_GET['start'];     // value="1994"
$end = $_GET['end'];      // value="2001"            
 
//the value can change
 
 
How can I get all the years between 1994-2010 + some text
 
$years= T1994YearT1995YearT1996YearT1997YearT1998YearT1999YearT2000YearT2001Year
 
 
 
 
Link to comment
https://forums.phpfreaks.com/topic/289489-form-automatic-fill-space-between-years/
Share on other sites

I don't know what you are really asking, but would something like this work?

<!DOCTYPE HTML>
<html>
<head>
	<meta charset="utf-8">
	<title>Birthdate</title>
	<style>
		.formStyle {
			margin-left: 200px;
		}
	</style>
</head>

<body>
	<form class="formStyle" action="theYears.php" method="post">
		<select id="yearBorn" name="yearBorn">
			<option selected>Date of Birth</option>
			<?php
			$year = 1914;
			for (  $x = 1; $x <= 101; $x++ ) {					
				echo '<option value="' . $year . '">' . $year . '</option>';
				$year += 1;
			}
			?>
			<input type="submit" name="submit" value="Submit">
		</select>
	</form>
</body>
</html>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.