astratt Posted September 24, 2008 Share Posted September 24, 2008 How do would I convert this php function into a js function? function getWeeks(){ $day = date('N'); // numeric representation of the day of the week if ($day == 1) // today is Sunday, so let the range begin with today $n = 0; else //today is not Sunday, so set the range to begin from the last Sunday $n = -$day; echo "<select name='dates'>"; $string .= '<option value="null" selected="true">Select a Value</option>'; for ($i = 0; $i < 4; $i++) { // add each week to the list echo "<option value=\"". date("m/d/Y", mktime(0,0,0,date("m"), date("d") + $n + 1, date("y"))) . " - " . date("m/d/Y", mktime(0,0,0,date("m"), date("d") + ($n + 7), date("y"))) ."\">" . date("m/d/Y", mktime(0,0,0,date("m"), date("d") + $n + 1, date("y"))) . " - " . date("m/d/Y", mktime(0,0,0,date("m"), date("d") + ($n + 7), date("y"))) . "</option>"; $n += 7; } echo "</select>"; } If anyone could help that would be great. Ultimately these values are generated on the fly but after the value is selected I need to insert them into the database field. If you don't understand just ask me to clarify. Just remember the first thing I need to do is convert this php function to javascript. Which is what I really would like to know how to do first. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.