Jump to content

Recommended Posts

hi,

I have a form that has 2 lists, first one has the months from Jan to Dec which i am done with, for the second list i want to have years from current year for other say 5 years. Example, we are in 2020 so i should have the list populate 2020,2021,2022,2023,2024 and next year it should show 2021-2025, how to do that.

Here is what i have as HTML:

<html>
<head>
<link rel="stylesheet" type="text/css" href="reportstyle.css">
</head>

<body>
	
				<div class="form-wrapper">
					<form action="reportanalysis.php" method="post">
					
					<div class="form-item">
						<h4>Select a month:</h4>
						<select id="months" name="months" required="required">
						<option selected="selected" value="chose">Choose one option...</option>
						<option value="jan">Jan - 01</option>
						<option value="feb">Feb - 02</option>
						<option value="mar">Mar - 03</option>
						<option value="apr">Apr - 04</option>
						<option value="may">May - 05</option>
						<option value="jun">Jun - 06</option>
						<option value="jul">Jul - 07</option>
						<option value="aug">Aug - 08</option>
						<option value="sep">Sep - 09</option>
						<option value="oct">Oct - 10</option>
						<option value="nov">Nov - 11</option>
						<option value="dec">Dec - 12</option>
						</select>
					</div>
					
					<div class="form-item">
						<h4>Select a year:</h4>
						<select id="years" name="years" required="required">
						<option selected="selected" value="chose">Choose one option...</option>
						<option value="2020">2020</option>
						<option value="2021">2021</option>
						<option value="2022">2022</option>
						<option value="2023">2023</option>
						<option value="2024">2024</option>
						</select>
					</div>
					
					<div class="button-panel">
						<center><button type="submit" name="reporting" class="buttonstyle">Generate Graph Report</button></center>
					</div>
					
					<div class="reminder">
						<p><a href="home.php">Return to Main Menu</a>
					</div>
					
					</form>
				</div>
				

</body>
</html>

 

Edited by ramiwahdan
typo error
Link to comment
https://forums.phpfreaks.com/topic/310454-populating-list-box/
Share on other sites

13 minutes ago, ramiwahdan said:

hi,

I have a form that has 2 lists, first one has the months from Jan to Dec which i am done with, for the second list i want to have years from current year for other say 5 years. Example, we are in 2020 so i should have the list populate 2020,2021,2022,2023,2024 and next year it should show 2021-2025, how to do that.

Here is what i have as HTML:


<html>
<head>
<link rel="stylesheet" type="text/css" href="reportstyle.css">
</head>

<body>
	
				<div class="form-wrapper">
					<form action="reportanalysis.php" method="post">
					
					<div class="form-item">
						<h4>Select a month:</h4>
						<select id="months" name="months" required="required">
						<option selected="selected" value="chose">Choose one option...</option>
						<option value="jan">Jan - 01</option>
						<option value="feb">Feb - 02</option>
						<option value="mar">Mar - 03</option>
						<option value="apr">Apr - 04</option>
						<option value="may">May - 05</option>
						<option value="jun">Jun - 06</option>
						<option value="jul">Jul - 07</option>
						<option value="aug">Aug - 08</option>
						<option value="sep">Sep - 09</option>
						<option value="oct">Oct - 10</option>
						<option value="nov">Nov - 11</option>
						<option value="dec">Dec - 12</option>
						</select>
					</div>
					
					<div class="form-item">
						<h4>Select a year:</h4>
						<select id="years" name="years" required="required">
						<option selected="selected" value="chose">Choose one option...</option>
						<option value="2020">2020</option>
						<option value="2021">2021</option>
						<option value="2022">2022</option>
						<option value="2023">2023</option>
						<option value="2024">2024</option>
						</select>
					</div>
					
					<div class="button-panel">
						<center><button type="submit" name="reporting" class="buttonstyle">Generate Graph Report</button></center>
					</div>
					
					<div class="reminder">
						<p><a href="home.php">Return to Main Menu</a>
					</div>
					
					</form>
				</div>
				

</body>
</html>

 

I figured it out, just created a counter and got this year value.

Link to comment
https://forums.phpfreaks.com/topic/310454-populating-list-box/#findComment-1576214
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.