Connecting Tech Pros Worldwide Help | Site Map

Please help me!

  #1  
Old July 20th, 2005, 10:33 AM
Mike Brown
Guest
 
Posts: n/a
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>


  #2  
Old July 20th, 2005, 10:34 AM
Fred Serry
Guest
 
Posts: n/a

re: Please help me!



"Mike Brown" <mikeb455@cox.net> schreef in bericht
news:EqFYa.31040$ff.7131@fed1read01...[color=blue]
> Please look at this section of my code. I am tryong to call the[/color]
checkMonth[color=blue]
> function if the year selected is the current year. I tested the value[/color]
being[color=blue]
> 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[/color]
checkYear[color=blue]
> function? The rest of the site is coming along nicely. I am new but I[/color]
am[color=blue]
> 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")
> }
>
> }
>[/color]
<snip code>

Hi,

"this" does not have the scope that you obviously expect from it here.
Try:

var myValue = document.forms["myform"].selectMonth.selectedIndex;

Fred


  #3  
Old July 20th, 2005, 10:34 AM
Vjekoslav Begovic
Guest
 
Posts: n/a

re: Please help me!



"Mike Brown" <mikeb455@cox.net> wrote in message
news:EqFYa.31040$ff.7131@fed1read01...[color=blue]
> 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[/color]
being[color=blue]
> 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[/color]
[color=blue]
> <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>[/color]

Instead of
var myValue = this.selectMonth.selectedIndex;



put
var myValue=document.forms['myform'].selectMonth.selectedIndex




Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
using paramiko problem? please help me sa6113 answers 0 October 26th, 2008 01:35 PM
Please, Please help me =?Utf-8?B?TWljaGFlbA==?= answers 5 October 17th, 2007 11:05 PM
Please help me to catch this error Amali answers 22 March 12th, 2007 05:45 PM
Please, please help me urgent!!! Bsnpr8 answers 2 November 27th, 2006 03:11 AM
HTML problem. Converting a Webpage into Word- features are lost- Can anyone please help me as I need to reproduce the page more or less as it was. CM answers 8 August 16th, 2006 12:15 AM