473,386 Members | 1,698 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,386 software developers and data experts.

For loop error - object expected

When I run page I immediatley get "Object expected" message and the tag
<body onload="setfocus()" is highlighted.

The error occurs in this snippet from within the script file

function validatePage()
{
// select the items in the TeamDivisions listbox
var i=document.TeamMaintenance.TeamDivisions.options.l ength -1
For (i; i>=0; i--)
{document.TeamMaintenance.hiddenTeamDivisions.valu e +=
document.TeamMaintenance.TeamDivisions.options[i].value;
document.TeamMaintenance.hiddenTeamDivisions.value += ",";}

// Now validate the page
return validatePanels();
}

I know this because if I comment out the line "For (i; i>=0;i--)", the
functions within the script file work correctly. Obviosusly in the
above snippet the 2 lines to be executed within the For loop executes
the once but I get the expected value in the hiddenTeamDivisions
control so at least it shows that these lines do work.
The problem is why do I get the "object expected" message when this
line is not commented out?

Thanks in anticipation

Duncan

Jul 23 '05 #1
3 2361
Lee
undercups said:

When I run page I immediatley get "Object expected" message and the tag
<body onload="setfocus()" is highlighted.

The error occurs in this snippet from within the script file

function validatePage()
{
// select the items in the TeamDivisions listbox
var i=document.TeamMaintenance.TeamDivisions.options.l ength -1
For (i; i>=0; i--)

The keyword is "for", not "For".

Jul 23 '05 #2
undercups wrote:
When I run page I immediatley get "Object expected" message and the tag
<body onload="setfocus()" is highlighted.

The error occurs in this snippet from within the script file

function validatePage()
{
// select the items in the TeamDivisions listbox
var i=document.TeamMaintenance.TeamDivisions.options.l ength -1
For (i; i>=0; i--)
{document.TeamMaintenance.hiddenTeamDivisions.valu e +=
document.TeamMaintenance.TeamDivisions.options[i].value;
document.TeamMaintenance.hiddenTeamDivisions.value += ",";}

Try this:

// select the items in the TeamDivisions listbox
var x = [];
var f = document.TeamMaintenance.TeamDivisions.options;
var i = f.length;
while (i--){ x.push(f[i].value) }
document.TeamMaintenance.hiddenTeamDivisions.value = x.join(',');
// Now validate the page
return validatePanels();
}

[...]

--
Rob
Jul 23 '05 #3
thanks guys

Duncan

Jul 23 '05 #4

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

Similar topics

5
by: Enos Meroka | last post by:
Hallo, I am a student doing my project in the university.. I have been trying to compile the program using HP -UX aCC compiler, however I keep on getting the following errors. ...
5
by: Nick Calladine | last post by:
Learning : Loop to list all dropdown box values on a form Can some one point me in the right direction : I have a form which I want to loop through I basically want to get all the selected...
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: 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...
4
by: Fendi Baba | last post by:
I wrote a code to loop through an array and only the first item is updated. I think the sqlcommand is not updated properly in my code but I am not sure how to go about this. This is my code: ...
1
by: JOJO123 | last post by:
I got here in search of an answer to this Javascrpt question. I upgraded jave on XP Ie 7, acrobat 5.1 and suddenly can't open any pdf files on web sites using IE. I see u guys all say, this is a...
6
by: Lawrence Spector | last post by:
I ran into a problem using g++. Visual Studio 2005 never complained about this, but with g++ I ran into this error. I can't figure out if I've done something wrong or if this is a compiler bug. ...
9
by: pauldepstein | last post by:
On my visual c++ compiler, I compiled code which contained something like for( int i =0; i < 5; i++) { double x =5;} I expected it to give a compiler error because x is being redefined
1
by: BSand0764 | last post by:
I'm getting an error that I can't seem to resolve. When I compile the Functor related logic in a test program, the files compile and execute properly (see Listing #1). However, when I...
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...
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
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...

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.