473,385 Members | 1,492 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Please help me!

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>
Jul 20 '05 #1
2 2419

"Mike Brown" <mi******@cox.net> schreef in bericht
news:EqFYa.31040$ff.7131@fed1read01...
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")
}

}

<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
Jul 20 '05 #2

"Mike Brown" <mi******@cox.net> wrote in message
news:EqFYa.31040$ff.7131@fed1read01...
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>


Instead of
var myValue = this.selectMonth.selectedIndex;

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


Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Numberwhun | last post by:
Hello everyone! I am trying to learn java and have run into kind of a snag. Here is the code that I have so far: ------ <begin_code> ---------- import javax.swing.*; import...
1
by: HolaGoogle | last post by:
Hi all, Please help me with the following..it's realy urgent and i tried everything i could and i can't get it work properly!! Thanks in advance. Here's what i'm trying to accomplish: in my...
0
by: s_erez | last post by:
Hi, This is a realy tricky one. I have an ASP.NET application where some pages are reading data from a DB and presenting reports. In order for the user to wait while the page is reading data from...
2
by: rked | last post by:
I get nameSPAN1 is undefined when I place cursor in comments box.. <%@ LANGUAGE="VBScript" %> <% DIM ipAddress ipAddress=Request.Servervariables("REMOTE_HOST") %> <html> <head> <meta...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
4
by: pshindle | last post by:
DB2 Team - I just downloaded and unzipped the new Fixpack 9 for DB2 ESE V8 for Windows (FP9_WR21350_ESE.exe). I then burned the unzipped Fixpack files to a CD. I proceded to install this...
23
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application...
1
PEB
by: PEB | last post by:
POSTING GUIDELINES Please follow these guidelines when posting questions Post your question in a relevant forum Do NOT PM questions to individual experts - This is not fair on them and...
4
by: fatboySudsy | last post by:
Hi, I have constructed a client program that has given me some error codes that i just cannot see. I was wondering if a different set of eyes with much more experience than me could help me out. ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.