M
Mike Brown
Please look at this section of my code. I am tryong to call the checkMonth
function if the year selected is the current year. I tested the value being
passed to the checkYear function and that is working. I seem to hava a
problem with the syntax when I call the checkMonth() from the checkYear
function? The rest of the site is coming along nicely. I am new but I am
working hard to learn. Please help. Any advice would be appreciated.
Thanks, Mike
<html>
<script language = "javascript">
function checkMonth()
{
var today = new Date();
var thisMonth = today.getMonth();
var myValue = this.selectMonth.selectedIndex;
if (myValue <= thisMonth)
{
alert("Month has expired")
}
}
function checkYear(myYear)
{
var today = new Date();
var thisYear = today.getFullYear();
if (myYear == thisYear)
{
checkMonth();
}
}
</script>
<body>
<hr>
<form name= "myform" align = center>
<table border = 0 align = "center">
<tr>
<td colspan = 2 align = center>Please select Payment Type</td>
</tr>
<br>
<tr>
<td><input type = "radio" name = "card" value = "visa">Visa
<input type = "radio" name = "card" value = "MC">MC
<input type = "radio" name = "card" value = "AmEx">AmEx
<input type = "radio" name = "card" value = "Disc">Discover
</td>
</tr>
</table>
<br>
<table align = center>
<tr>
<td>Card Number</td>
</tr>
<tr>
<td><input type = "text" name = "cardNumber" size = "16"></td>
</tr>
<tr>
<td><br></td>
</tr>
<tr>
<td>Expiration Date:</td>
</tr>
<tr>
<td>Month</td>
<td>Year</td>
</tr>
<tr>
<td><select name = "selectMonth" >
<option>Jan
<option>Feb
<option>Mar
<option>Apr
<option>May
<option>Jun
<option>Jul
<option>Aug
<option>Sep
<option>Oct
<option>Nov
<option>Dec
</select>
</td>
<td>
<select name = "selectYear" onChange =
"checkYear(this.options[selectedIndex].value);">
<script language = "javascript">
var today = new Date();
var thisYear = today.getFullYear();
var endYear = thisYear + 8;
for (i = endYear; i >= thisYear; i--)
{
document.write("<option value=" + i + ">" + i);
}
</script>
</select>
</td>
<tr>
<td><br></td>
</tr>
<tr>
<td>Reset Form</td>
<td>Submit Order</td>
</tr>
<tr>
<td><input type = "reset" value = "Clear"></td>
<td><input type = "submit" value = "Send"></td>
</tr>
</form>
</body>
</html>
function if the year selected is the current year. I tested the value being
passed to the checkYear function and that is working. I seem to hava a
problem with the syntax when I call the checkMonth() from the checkYear
function? The rest of the site is coming along nicely. I am new but I am
working hard to learn. Please help. Any advice would be appreciated.
Thanks, Mike
<html>
<script language = "javascript">
function checkMonth()
{
var today = new Date();
var thisMonth = today.getMonth();
var myValue = this.selectMonth.selectedIndex;
if (myValue <= thisMonth)
{
alert("Month has expired")
}
}
function checkYear(myYear)
{
var today = new Date();
var thisYear = today.getFullYear();
if (myYear == thisYear)
{
checkMonth();
}
}
</script>
<body>
<hr>
<form name= "myform" align = center>
<table border = 0 align = "center">
<tr>
<td colspan = 2 align = center>Please select Payment Type</td>
</tr>
<br>
<tr>
<td><input type = "radio" name = "card" value = "visa">Visa
<input type = "radio" name = "card" value = "MC">MC
<input type = "radio" name = "card" value = "AmEx">AmEx
<input type = "radio" name = "card" value = "Disc">Discover
</td>
</tr>
</table>
<br>
<table align = center>
<tr>
<td>Card Number</td>
</tr>
<tr>
<td><input type = "text" name = "cardNumber" size = "16"></td>
</tr>
<tr>
<td><br></td>
</tr>
<tr>
<td>Expiration Date:</td>
</tr>
<tr>
<td>Month</td>
<td>Year</td>
</tr>
<tr>
<td><select name = "selectMonth" >
<option>Jan
<option>Feb
<option>Mar
<option>Apr
<option>May
<option>Jun
<option>Jul
<option>Aug
<option>Sep
<option>Oct
<option>Nov
<option>Dec
</select>
</td>
<td>
<select name = "selectYear" onChange =
"checkYear(this.options[selectedIndex].value);">
<script language = "javascript">
var today = new Date();
var thisYear = today.getFullYear();
var endYear = thisYear + 8;
for (i = endYear; i >= thisYear; i--)
{
document.write("<option value=" + i + ">" + i);
}
</script>
</select>
</td>
<tr>
<td><br></td>
</tr>
<tr>
<td>Reset Form</td>
<td>Submit Order</td>
</tr>
<tr>
<td><input type = "reset" value = "Clear"></td>
<td><input type = "submit" value = "Send"></td>
</tr>
</form>
</body>
</html>