Chemistry, asked by jessiica8401, 1 year ago

H0w to change the colour of drop down list in php for calendar

Answers

Answered by raghav752
0

can anybody tell me important q of sci. 10

Answered by Lavanyachaudhary1984
0

Answer:

Explanation:

'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');

   // Make the months pull-down menu:

   //echo '

Date of Birth

';

   echo '';

   echo 'Month\n';

   foreach ($months as $key => $value) {

       echo "$value\n";

   }

   echo '';

   // Make the days pull-down menu:

   echo '';

   echo 'Day\n';

   for ($day = 1; $day <= 31; $day++) {

       echo "$day\n";

   }

   echo '';

   // Make the years pull-down menu:

   echo '';

   echo 'Year\n';

   for ($year = 1910; $year <= 2000; $year++) {

       echo "$year\n";

   }

   echo '';

Once values have been defined, I convert them to MySQL format with the following code:

// Validate the month.

if (is_numeric ($month)) {

   $dob = $month . '-';

} else {

   $action['result'] = 'error';  

   array_push($text,'Please insert a valid Month for patient birth date');

}

// Validate the day.

if (is_numeric ($day)) {

   $dob .= $day . '-';

} else {

   $action['result'] = 'error';  

   array_push($text,'Please insert a valid Day for patient birth date');

}

// Validate the year.

if (is_numeric ($year)) {

   $dob = $year . '-' . $month . '-' .  $day; // Set Birthdate in SQL format

Finally, I call the function in the form with the following code:

php

mysql

list

function

share  follow  

edited Sep 29 '14 at 8:13

RiggsFolly

79.6k1818 gold badges9191 silver badges130130 bronze badges

asked Sep 29 '14 at 8:05

Diego

7311 silver badge1111 bronze badges

So am I correct in thinking you want someone here to write this code for you? This is not s free coding service Can I suggest a quick read of this How to ask a good question – RiggsFolly Sep 29 '14 at 8:15  

ehmm...my apologies if I asked something inappropriate, actually I did not want someone to write the function for me (I have already worked on that), just to show me the way to modify it so to make it re-usable. Anyhow, thanks for the suggestion, will take a look at that. – Diego Sep 29 '14 at 13:09

add a comment

1 Answer

1

Actually some parts of it are a bit off:

// Make the months array:

$months = array ('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');

// some months are a bit off, the keys are missing

// Should be something like this:

$months = array ('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');

$month_num = range(1, 12);

$months = array_combine($month_num, $months);

And the days are hardcoded, what about February 31?

The Years I guess should be okay.

Why not use a date picker (jQuery UI in particular) for this purpose instead?

$(function() {

   $( "#datepicker" ).datepicker({

       changeMonth: true,

       changeYear: true,

       dateFormat: 'yy-mm-dd', // iso format

   });

});

 

Date:

 

Similar questions