Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Object expected

Status
Not open for further replies.

snyperx3

Programmer
May 31, 2005
467
US
I did a search and found many related topics, but none of them seemed to address the same problem I'm having.

I have some javascript in the head of my html page. It consists of ONE function - function CalcPrice(). In my html i have a form that consists of many text boxes and 3 buttons. My html (which i dont have directly in front of me because im away from home) for the line i am receiving the error on is this:

Code:
<p><input type="button" value="Calculate Price" onClick="CalcPrice()"></p>

The page loads no matter what browser I use. If I click the button in firefox, though, it doesnt do anthing, and if I click it in IE7, it gives me the error "Object Expected: Line ##: Char 1"...where ## is the line number (remember i dont have my code directly in front of me)

-Pete
 
That is the EXACT line of code that is giving me the error...that is EXACTLY how it appears in the html.

I'm letting you know that i dont have the code in front of me so you can know that im not able to test your suggestions or let you know what line it says.

What can be wrong with the code i have shown?

-Pete
 
what is wrong with the code you have shown is that it is likely calling a function that has an error within it. because you are not showing that code, there is no way to tell you what's wrong.

additionally, it could be that your JavaScript file is not in the correct place. make sure your file is where you claim it is in your <script> tag.



*cLFlaVA
----------------------------
[tt]"quote goes here"[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
That is the EXACT line of code that is giving me the error...that is EXACTLY how it appears in the html.

The code you supplied is symmantically correct (except that you may want to close your input tag with a /> instead of >). However, when you click the button it's running a function called CalcPrice() and you have not supplied the code for that function (which is obviously where the error is).

-kaht

[small](All puppies have now found loving homes, thanks for all who showed interest)[/small]
 
I was not aware that IE7 would give the error on the incorrect line of code. sorry for that.

again, I thought the error was on the line of code that it said the error was on...my mistake. I'll post the javascript when i get home.

thanks

-Pete
 
I was not aware that IE7 would give the error on the incorrect line of code.

The error was triggered on that line because that's where the function was called from, IE6 does the same thing. I'd suggest using cory's solution above though, use the firefox error console, it's 9999% more descriptive.

-kaht

[small](All puppies have now found loving homes, thanks for all who showed interest)[/small]
 
Pete,

You should confirm that the script file that is being included has the correct path and filename. I've seen so many errors that state "Char 1" as being the problem when the actual problem is that the browser simply cannot find the script file.

It might even be down to the case of the path / filename if you're on a case-sensitive OS like unix, etc.

If the path / filename all proves to be correct, then you'd definatley need to post the script file, and possibly the whole head section (or a URL to the page would be better).

Hope this helps,
Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
yeah i figured it out. just used firefox to find out where the REAL error was. very easy fix. had it all done about 2 minutes later.

thanks

-Pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top