Forum Moderators: open

Message Too Old, No Replies

Java Scripting and clueless

I need help bad.

         

opiesilver

9:54 am on Aug 17, 2004 (gmt 0)

10+ Year Member



Here's the basic problem. I've got a table that I want to default to "closed" on Mondays. I'm trying to use an "if" statement to check the variable passed to it, but from that point on I'm clueless.

Here's the best I can come up with and it probably has syntax errors.

<select name="mealtype" onChange="{if splitit(document.reservationform.reservationdate.value,document.reservationform.mealtype.value)!='Monday'">{<option value="Closed">Closed on Mondays</option>}

I'd like to put an "else" statement here for the other values, but I really don't know how.

<option value="" selected>Please Select</option>
<option value="Brunch">Brunch</option>
<option value="Lunch">Lunch</option>
<option value="Dinner">Dinner</option>

I'd really appreciate any advice.

Lance

12:17 pm on Aug 17, 2004 (gmt 0)

10+ Year Member



I'm no pro at this myself, but see if this will work for you:


<select name="mealtype">
<script type="text/javascript">
d = new Date();
if (d.getDay() == 1) { // 0 = Sunday, 1 = Monday, Etc.
document.write("<option value='Closed'>Closed on Mondays</option>");
}
else
{
document.write("<option value='' selected>Please Select</option>");
document.write("<option value='Brunch'>Brunch</option>");
document.write("<option value='Lunch'>Lunch</option>");
document.write("<option value='Dinner'>Dinner</option>");
}
</script>
</select>