<?php
$years = array();
echo "<select name='Year'>";
for ($i = 1900; $i < 2026; $i++){
echo "<option value='$i'>$i</option>";
}
echo "</select>";
?>
OK that's your form
Depending on which method you use ('get' or 'post'), you pick up the variable like this:
$year = $_POST['Year'];
OR
$year = $_GET['Year'];
This will probably throw an error if you include this on the same page as the form. Forms should be sent to form handling files to do the processing.
If you want to display the last known selection after sending the form:
//assume you've placed the selection into a variable called $year:
echo "<select name='Year'>";
for ($i = 1900; $i < 2026; $i++){
$sel = (isset($year) && $year == $i) ? ' selected="selected"' : '';
echo "<option value='$i'$sel>$i</option>";
}
echo "</select>";
Not tested.
diafol
Keep Smiling
10,826 posts since Oct 2006
Reputation Points: 1,675
Solved Threads: 1,532
Skill Endorsements: 61
Question Answered as of 1 Year Ago by
diafol
and
raphie hi I want to select value from drop down list and selected value should be print in another Textbox without using submit button.
That's javascript - this is the PHP forum.
diafol
Keep Smiling
10,826 posts since Oct 2006
Reputation Points: 1,675
Solved Threads: 1,532
Skill Endorsements: 61