Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8" />
- <title>Test</title>
- </head>
- <body>
- <?php
- $day = range(1,31);
- $month = range(1,12);
- $year = range(2019,2040);
- echo"<br />\n";
- echo "Select Date (d/m/y) ";
- echo "<select name=\"selectDay\" id=\"selectDay\">\n";
- foreach($day as $key =>$value){
- $day_value = str_pad($value, 2, '0', STR_PAD_LEFT);
- echo "<option value='$day_value'>$day_value</option>\n";
- }
- $day_value = str_pad($day[0], 2, '0', STR_PAD_LEFT);
- echo "<option value=$day_value selected='selected'>$day_value</option></select>\n";
- //
- echo "<select name=\"selectMonth\" id=\"selectMonth\">\n";
- foreach($month as $key =>$mvalue){
- $month_value = str_pad($mvalue, 2, '0', STR_PAD_LEFT);
- echo "<option value='$month_value'>$month_value</option>\n";
- }
- $month_value = str_pad($month[0], 2, '0', STR_PAD_LEFT);
- echo "<option value=$month_value selected='selected'>$month_value</option></select>\n";
- //
- echo "<select name=\"selectYear\" id=\"selectYear\">\n";
- foreach($year as $key =>$value){
- echo "<option value='$value'>$value</option>\n";
- }
- }
- echo "<option value={$year[0]} selected='selected'>{$year[0]}</option></select>\n";
- //
- ?>
- <button onclick="myFunction()">Submit</button>
- <p id="demo"></p>
- <script>
- function myFunction() {
- var x = document.getElementById("selectDay").value;
- var y = document.getElementById("selectMonth").value;
- var z = document.getElementById("selectYear").value;
- document.getElementById("demo").innerHTML =
- "Date selected = " + x + '-' + y + '-' + z;
- }
- // SOLUTION - hyphens needed to be quoted above
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement