473,932 Members | 18,595 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Run Time Error. Expected ';'

I'm getting this Error Message. Expected ';'

Please Select One:
<form name="form1"> <<------------ Error is here.
<select name="selectTra ns" onChange="If (this.value == 'checkout')
window.location .href='CheckOut .php';">
<option>---Please Select One ---</option>
<option value="checkout ">Check OUT</option>
<option value="checkin" >Check IN</option>
</select>
</form>

What looks wrong with the above code? I did it this way because I was
getting the same error (Expected ';' error) with the code below....
<head>
<script language="JavaS cript" type="text/javascript">

function deil(ans)
{ <<<-----------------------error here
If (ans == "checkout") {
window.location .href="CheckOut .php";
}
}
..... more functions here...
</script>
</head>
..
..
..
Please Select One:
<form name="form1">
<select name="selectTra ns" onChange="HereW eGo();">
<option>---Please Select One ---</option>
<option value="checkout ">Check OUT</option>
<option value="checkin" >Check IN</option>
</select>
</form>

I've spent hours trying to figure this out and I still can't get it to
work!!! Does anyone know what is going on? It looks good to be but
obviously it's not.

Thanks in advance!!! no, really :-)

Andy

Jul 26 '05 #1
5 5225
an**********@gm ail.com wrote:
I'm getting this Error Message. Expected ';'

Please Select One:
<form name="form1"> <<------------ Error is here.

The error is actually here: <select name="selectTra ns" onChange="If (this.value == 'checkout')
window.location .href='CheckOut .php';">
You have a capital I in If.
<select name="selectTra ns" onChange="if(th is.value == 'checkout')
window.location .href='CheckOut .php';">
[snip] What looks wrong with the above code? I did it this way because I was
getting the same error (Expected ';' error) with the code below....
<head>
<script language="JavaS cript" type="text/javascript">

function deil(ans)
{ <<<-----------------------error here
Same error here: capital I in If. If (ans == "checkout") {
window.location .href="CheckOut .php";
}
}
..... more functions here...
</script>
</head>
[snip] Thanks in advance!!! no, really :-)

Andy


Odd... I would've expected the error 'Object expected.', especially if
it's a runtime error.

Either way, that looks like your problem.

For the record, anytime you have an error involving a semicolon, always
check the lines immediately surrounding the one cited in the error.
Just like with errors involving braces you should trace backward
indefinitely, with semicolons trace back a line, then forward two.

Also, I'm reliably informed that we shouldn't use the .value property
of select boxes. I've never had a problem with it myself, but I'm told
that compatibility is limited or unpredictable.

Hope that helps.

Jul 26 '05 #2
Lee
an**********@gm ail.com said:

I'm getting this Error Message. Expected ';'

Please Select One:
<form name="form1"> <<------------ Error is here.
<select name="selectTra ns" onChange="If (this.value == 'checkout')
window.locatio n.href='CheckOu t.php';">


Apparently you're using some horribly defective browser that's not
pointing out the actual error.

There is no builtin Javascript function named "If".
You mean "if"

Jul 26 '05 #3
On 26/07/2005 06:23, Christopher J. Hahn wrote:
an**********@gm ail.com wrote:
I'm getting this Error Message. Expected ';'

[snip]
The error is actually here:
<select name="selectTra ns" onChange="If (this.value == 'checkout')
window.location .href='CheckOut .php';">

[snip]
Odd... I would've expected the error 'Object expected.', especially if
it's a runtime error.
In both cases, the parser will be encountering a syntax error.

If (...)

will be considered a function call, with If as the identifier of that
function. In the first case, what immediately follows is an assignment
expression:

A() a = b;

which not match any grammar production. With the second case, a block
statement follows:

A() {}

which is also nonsense.

[snip]
Also, I'm reliably informed that we shouldn't use the .value property
of select boxes. I've never had a problem with it myself, but I'm
told that compatibility is limited or unpredictable.


Older browsers may not support the property. NN4, for example, always
returns null. It's briefly mentioned in the group FAQ.

Mike

--
Michael Winter
Prefix subject with [News] before replying by e-mail.
Jul 26 '05 #4
Wow! I can't believe it needed to be a lowercase i in the 'if'
statement! I wasted so many hours. Thanks so much for your help!!

Andy

Jul 26 '05 #5
Michael Winter wrote:
On 26/07/2005 06:23, Christopher J. Hahn wrote:
an**********@gm ail.com wrote:
I'm getting this Error Message. Expected ';'

[snip]
The error is actually here:
<select name="selectTra ns" onChange="If (this.value == 'checkout')
window.location .href='CheckOut .php';">


[snip]
Odd... I would've expected the error 'Object expected.', especially if
it's a runtime error.


In both cases, the parser will be encountering a syntax error.

If (...)

will be considered a function call, with If as the identifier of that
function. In the first case, what immediately follows is an assignment
expression:

A() a = b;


Put that way, it makes perfect sense. Thanks for clarifying that for
me.
[on using .value property of select elements]
Older browsers may not support the property. NN4, for example, always
returns null. It's briefly mentioned in the group FAQ.
Again, thank you. I hadn't seen that in the FAQ (I confess to not
having read *every* line of it).
Mike

--
Michael Winter
Prefix subject with [News] before replying by e-mail.


Good info, Mike. I appreciate it.

Jul 27 '05 #6

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

Similar topics

5
3348
by: Carmine Cairo | last post by:
Hi, I'm working on a project and today I've note a little problem during the compile fase. Here a little piece of code: // 1st version welldone = 0; size = p->getSize(); backbone = new rightType;
1
10320
by: Franko | last post by:
I get the following error. Please help c:\inetpub\wwwroot\WebApplication1\WebForm2.aspx(6,38): error CS1001: Identifier expected c:\inetpub\wwwroot\WebApplication1\WebForm2.aspx(6,52): error CS1002: ; expected c:\inetpub\wwwroot\WebApplication1\WebForm2.aspx(7,19): error CS1519: Invalid token '(' in class, struct, or interface member declaration c:\inetpub\wwwroot\WebApplication1\WebForm2.aspx(9,2): error CS0116: A namespace does not...
1
3667
by: Carlos Kim via DotNetMonster.com | last post by:
Compiler Error Message: CS1026: ) expected Source Error: Line 12: <body MS_POSITIONING="GridLayout"> Line 13: <form id="Form1" method="post" runat="server"> Line 14: <cr:CrystalReportViewer id=CrystalReportViewer3 style="Z-INDEX: 101; LEFT: 24px; POSITION: absolute; TOP: 40px" runat="server" Height="1013px" Width="901px" ReportSource='<%# c:\inetpub\wwwroot\ WebApplication4\CrystalReport222.rpt %>'>
5
5702
by: cranium.2003 | last post by:
hi, Here is my code #include <iostream.h> int main() { cout <<"HI"; return 0; } and using following command to compile a C++ program g++ ex1.cpp -o ex1
17
6468
by: OlafMeding | last post by:
Below are 2 files that isolate the problem. Note, both programs hang (stop responding) with hyper-threading turned on (a BIOS setting), but work as expected with hyper-threading turned off. Note, the Windows task manager shows 2 CPUs on the Performance tab with hyper-threading is turned on. Both Python 2.3.5 and 2.4.3 (downloaded from python.org) have this problem. The operating system is MS Windows XP Professional.
19
8802
by: Rahul | last post by:
Hi, Is there a way to find the offset of a class member at compile time. e.g. class A{ int i; int j; char c; }; Here the offset of c = 8 bytes from the start of an object of A (assuming 4 byte int). Can it be done at compile time. Thanks in advance
1
22325
by: Richard Hollenbeck | last post by:
I wonder what I'm missing? I really feel like a retard because I've been screwing with some code for a very long time. I just must be missing something very simple. In the following example, I've stripped away everything that doesn't cause the error to make my question a little simpler. Here's the problem in its simplest form inside a report: Dim db As DAO.Database
4
2426
by: daivdh | last post by:
I recently tried to download and install a Gadget called "Piano" which would put a piano keyboard on the screen. It downloaded and installed okay. When I dragged the keyboard from the sidebar onto the screen it enlarged as expected but when I tried to play the keyboard I began getting Run Time Errors and it didn't work at all. In frustration I simply deleted the Gadget. Since then, I have been getting Run Time Errors at random times, usually...
3
3278
by: rorni | last post by:
Hi, I'm porting code from Windows to HP-UX 11, compiling with g++. I'm getting a compilation error on the system's debug.h include file, which is included very indirectly through a series of other system include files. The one I am including is <map> . The errors I am getting are: /opt/hp-gcc-4.2.1/lib/gcc/ia64-hp-hpux11.23/4.2.1/../../../../include/c++/4.2.1/debug/debug.h: At global scope:...
0
10122
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
9954
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11499
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...
1
11258
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
10638
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6057
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
6267
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4888
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4431
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.