Jump to content

How to convert a php function into a javascript function


astratt

Recommended Posts

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.