Advertisement
TonyAR

javascript issue

Mar 13th, 2023 (edited)
633
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.74 KB | Source Code | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>Test</title>
  6. </head>
  7. <body>
  8. <?php
  9.  
  10. $day = range(1,31);
  11. $month = range(1,12);
  12. $year = range(2019,2040);
  13.  
  14. echo"<br />\n";
  15. echo "Select Date (d/m/y)&nbsp;";
  16. echo "<select name=\"selectDay\" id=\"selectDay\">\n";
  17. foreach($day as $key =>$value){
  18.         $day_value = str_pad($value, 2, '0', STR_PAD_LEFT);
  19.         echo "<option value='$day_value'>$day_value</option>\n";
  20.         }
  21.         $day_value = str_pad($day[0], 2, '0', STR_PAD_LEFT);
  22.         echo "<option value=$day_value selected='selected'>$day_value</option></select>\n";
  23. //
  24. echo "<select name=\"selectMonth\" id=\"selectMonth\">\n";
  25. foreach($month as $key =>$mvalue){
  26.         $month_value = str_pad($mvalue, 2, '0', STR_PAD_LEFT);
  27.         echo "<option value='$month_value'>$month_value</option>\n";
  28.         }
  29.         $month_value = str_pad($month[0], 2, '0', STR_PAD_LEFT);
  30.         echo "<option value=$month_value selected='selected'>$month_value</option></select>\n";
  31. //
  32. echo "<select name=\"selectYear\" id=\"selectYear\">\n";
  33. foreach($year as $key =>$value){
  34.         echo "<option value='$value'>$value</option>\n";
  35.         }
  36.         }
  37.         echo "<option value={$year[0]} selected='selected'>{$year[0]}</option></select>\n";
  38. //
  39. ?>
  40. <button onclick="myFunction()">Submit</button>
  41.  
  42. <p id="demo"></p>
  43.  
  44. <script>
  45. function myFunction() {
  46.         var x = document.getElementById("selectDay").value;
  47.         var y = document.getElementById("selectMonth").value;
  48.         var z = document.getElementById("selectYear").value;
  49.         document.getElementById("demo").innerHTML =
  50.         "Date selected = " + x + '-' + y + '-' + z;
  51. }
  52. // SOLUTION - hyphens needed to be quoted above
  53. </script>
  54. </body>
  55. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement