Kurrel Posted July 26, 2007 Share Posted July 26, 2007 Hi everyone, I am writing a birthday input for a user management system. At this point in time the code looks like this print("<select style='width:40%;'>"); for ($day=1; $day < 32; $day++) { print("<option>"); print($day); print("</option>"); } print("</select>"); print("<select style='width:60%;'>"); for ($month=1; $month < 13; $month++) { print("<option>"); print(date("F", mktime(0, 0, 0, $month, 01, 2000))); print("</option>"); } print("</select>"); I don't like having the full 31 days for every month, including February and 30 day months. I am trying to develop an onchange for the month select that will repopulate the day select but can't find javascript functions that can (a) depopulate elements from a select and (b) insert elements into a select. So far, I've managed to get a hack by creating strings $28day, $30day and $31day of hardcoded text '<select><option>1</option>...</select> and replacing as needs, but it seems a truly clumsy and laborious workaround. Can anyone point me to commands for manipulating selects or to a cleaner workaround? ~Kurrel Link to comment https://forums.phpfreaks.com/topic/61826-repopulating-a-select-with-number-of-days-in-a-month/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.