So im trying to create a form that will send the date of the next friday as the value. The value should be in the form "YYYY-MM-DD"
Here is what i have so far:
<input type="hidden" name="next_charge_scheduled_at" id="s1" value="" />
<script type="text/javascript">
var elem = document.getElementById("s1");
elem.value = function()
{
var d = new Date();
switch (d.getDay())
{
case 0: d.setDate(d.getDate() + 5);
break;
case 1: d.setDate(d.getDate() + 4);
break;
case 2: d.setDate(d.getDate() + 3);
break;
case 3: d.setDate(d.getDate() + 2);
break;
case 4: d.setDate(d.getDate() + 1);
break;
case 6: d.setDate(d.getDate() + 6);
break;
}
return d;
};
</script>
However, this returns the whole function, and not the result, as far as i can see.
What am I doing wrong?