Shifting Form Field Values onclick
Posted: Tue Feb 24, 2009 2:11 pm
I have a page from which the user can select a date (in a text box updated via a calendar) and a time (selected from an options list)
I have two links that let the user cycle through the date field.
My javascript then changes the date accordingly
This works fine but i need to incorporate the time option too. The time dropdown list has:
What I would like to happen is that when the user clicks the 'next' it firstly updates the time, moving on one option value in the time field, and then only if the option value is <option value="22:00">Late</option> shifting/moving on 1 day.
Is this possible? I cant seem to get this functionality working
I have two links that let the user cycle through the date field.
Code: Select all
<a href="#" onclick="shiftDate(1, 'down');">Previous</a>
<a href="#" onclick="shiftDate(1, 'up');">Next</a>Code: Select all
function shiftDate(days, up_or_down)
{
date = new Date(document.getElementById('date').value);
if (up_or_down == 'up') {
date.setDate(date.getDate() + days);
} else {
date.setDate(date.getDate() - days);
}
document.getElementById('date').value = (date.getMonth()+1)+"/"+date.getDate()+"/"+date.getFullYear();
GetSchedule();
return false;
}Code: Select all
<select name="time" id="time" style="width:150px">
<option>Select Time</option>
<option value="9:00">Morning</option>
<option value="12:00">Afternoon</option>
<option value="16:00">Evening</option>
<option value="22:00">Late</option>
</select>
Is this possible? I cant seem to get this functionality working