473,407 Members | 2,598 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,407 software developers and data experts.

Run Time Error. Expected ';'

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

Please Select One:
<form name="form1"> <<------------ Error is here.
<select name="selectTrans" 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="JavaScript" 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="selectTrans" onChange="HereWeGo();">
<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 5183
an**********@gmail.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="selectTrans" onChange="If (this.value == 'checkout')
window.location.href='CheckOut.php';">
You have a capital I in If.
<select name="selectTrans" onChange="if(this.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="JavaScript" 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**********@gmail.com said:

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

Please Select One:
<form name="form1"> <<------------ Error is here.
<select name="selectTrans" onChange="If (this.value == 'checkout')
window.location.href='CheckOut.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**********@gmail.com wrote:
I'm getting this Error Message. Expected ';'

[snip]
The error is actually here:
<select name="selectTrans" 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**********@gmail.com wrote:
I'm getting this Error Message. Expected ';'

[snip]
The error is actually here:
<select name="selectTrans" 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
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...
1
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...
1
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:...
5
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
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. ...
19
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...
1
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,...
4
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...
3
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
0
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...
0
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,...
0
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...
0
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.