473,788 Members | 2,706 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.selectMont h.selectedIndex ;
if (myValue <= thisMonth)
{
alert("Month has expired")
}

}

function checkYear(myYea r)
{
var today = new Date();
var thisYear = today.getFullYe ar();
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">Disc over
</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>Expiratio n Date:</td>
</tr>

<tr>
<td>Month</td>
<td>Year</td>
</tr>

<tr>
<td><select name = "selectMont h" >
<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.getFullYe ar();
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 2434

"Mike Brown" <mi******@cox.n et> schreef in bericht
news:EqFYa.3104 0$ff.7131@fed1r ead01...
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.selectMont h.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.se lectedIndex;

Fred
Jul 20 '05 #2

"Mike Brown" <mi******@cox.n et> wrote in message
news:EqFYa.3104 0$ff.7131@fed1r ead01...
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.selectMont h.selectedIndex ;
if (myValue <= thisMonth)
{
alert("Month has expired")
}

}

function checkYear(myYea r)
{
var today = new Date();
var thisYear = today.getFullYe ar();
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">Disc over
</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>Expiratio n Date:</td>
</tr>

<tr>
<td>Month</td>
<td>Year</td>
</tr>

<tr>
<td><select name = "selectMont h" >
<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.getFullYe ar();
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.selectMont h.selectedIndex ;

put
var myValue=documen t.forms['myform'].selectMonth.se lectedIndex


Jul 20 '05 #3

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

Similar topics

1
2170
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 javax.swing.JApplet; import javax.swing.JOptionPane; import java.awt.Graphics;
1
2009
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 form i have a table with 3 rows (3 input text), in which user can enter values and then clik save. When he clicks the Save button, i'd like to be able to add the created items to the end of my table
0
1999
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 the DB I am using a DIV with a please wait message which is removed once the page is loaded. In addition I am using a global error handling using the Application_Error void in the Global.asax file. when the application is loading a page which...
2
2381
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 http-equiv="Content-Type" content="text/html;
7
3615
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> </head> <style type="text/css">
4
3521
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 Fixpack on a test machine running ESE but encountered a serious error during the install. It started 'copying new files' but then stopped cold and displayed a dialog box asking me to "Please insert disk 1". (It all fit on one CD!) I clicked OK...
23
3287
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 to create certain textboxes, labels, and combo boxes? Any ideas would be appreciated. Thanks
1
54537
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 we instruct our experts to ignore any such PMs completely Be sure to give the version of Access that you are working with and the Platform and OS if applicable.
4
2361
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. Here are the error codes and underneath i have listed the program. Thanks in advance for looking. client.c: In function `main': client.c:118: error: syntax error before '-' token client.c: At top level: client.c:132: error: conflicting types...
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10370
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10177
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10113
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8995
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5402
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.