473,796 Members | 2,741 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error: Object Expected

5 New Member
I had been trying to solve this error for the past days... tried a number of ways but still the error return to me eventually and its driving me to the very end!!! I keep getting this error when it reach the onblur event!!! Pls share some advice for me? All will be greatly appreciated!!

[HTML]<html>
<head><title>Sh opping Cart</title>
<script language="javas cript" type="text/javascript">
<!-- Hide javascript from older browsers

function CheckPen(qty){
if(qty=="")
alert('Hello')
}

function cart(selected) {

//Array is used to store a set of values in a single variable name
var price = new Array(1.5,1.2,1 .6,0.5,0.8,2);
var prod = new Array(0,1,2,3,4 ,5);

//the bellow var is for the place to hold the data for the calculation
var selectNo = selected.select edIndex;
var selectName = selected.option s[selectNo].value;
var list = selected.option s.size;
var choice = selected.option s[selectNo].selected;
var total = 0;
var line = "";

if (selectNo !=-1) {
// line command is for tob display in new screen
line = "<form><tab le border=2 bordercolor=blu e cellspacing=15 cellpadding=10> ";
line = line + "<tr align='center'> <th colspan=4><font size='5'>Purcha se Products"
line = line + "<tr><td align=center>St ationary<td align=center>Pr ice<td align=center>Qu antity<td align=center>Pr ice"

for(var i = 0;i<list;++i) {
choice = selected.option s[i].selected;
if (choice == true) {
itemName = selected.option s[i].value;
//display the the selected items aling with their price in a table
line = line + "<tr><td>"+sele ctName;
line = line + "<td align=center>S$ <input type=button name=priceLabel "+prod[i]+" value="+price[i]+">";
line = line + "<td><input type=text size=10 maxlength=5 name=qty"+prod[i]+" onblur='CheckPe n(qty"+prod[i]+".value)'>" ;
line = line + "<td><input type=button value=Calculate name=subTotal"+ prod[i]+" onclick=subTota l"+prod[i]+".value=priceL abel"+prod[i]+".value*qty"+p rod[i]+".value,total. value=total.val ue*1+subTotal"+ prod[i]+".value*1>" ;
}
}
line = line + "<tr><td><td><t d>Total:";
// bellow command is used to diplay the total cost of the items selected
line = line + "<td><input type=Text readonly size=6 name=total value=0>";
line = line + "</table></form>";
line = line + "</body></html>";

document.writel n(line)
}
}

// End hiding javascript-->
</script>
</head>
<body>
<form name=list>
<table>
<tr>
<td align=center><h 2><u>Shopping Cart</u></h2>
<tr>
<td>
<select name=product size=6 multiple>
<option name=pen value="Pen">Pen </option>
<option name=pencil value="Pencil"> Pencil</option>
<option name=colour value="Colour Pencil">Colour Pencil</option>
<option name=eraser value="Eraser"> Eraser</option>
<option name=ruler value="Ruler">R uler</option>
<option name=high value="Highligh ter">Highlighte r</option>
</select>
<tr>
<td><input type="button" value="Add To Cart" onClick="cart(l ist.product)">
</table>
</form>
</body>
</html>[/HTML]
Mar 9 '07 #1
19 2006
mrhoo
428 Contributor
Expand|Select|Wrap|Line Numbers
  1. line = line + "<td><input type=text size=10 maxlength=5 name=qty"+prod[i]+" onblur='CheckPen(qty"+prod[i]+".value)'>";

chances are this line doesn't do what you thought it does.
Mar 9 '07 #2
Azzy
5 New Member
Expand|Select|Wrap|Line Numbers
  1. line = line + "<td><input type=text size=10 maxlength=5 name=qty"+prod[i]+" onblur='CheckPen(qty"+prod[i]+".value)'>";

chances are this line doesn't do what you thought it does.
Thanx for the reply... i wanted it to do a simple verification by checking if the value is a null value and return an alert but it just doesnt seem to work as i though it was suppose to...
even if i were to change it into
line = line + "<td><input type=text size=10 maxlength=5 name=qty"+prod[i]+" onblur='return CheckPen()'>";

function CheckPen(){
alert('hello')
return true
}

sadly it will not prompt the alert message too...
any advice? ^^?
Mar 9 '07 #3
acoder
16,027 Recognized Expert Moderator MVP
Change this line
Expand|Select|Wrap|Line Numbers
  1. var list = selected.options.size;
to
Expand|Select|Wrap|Line Numbers
  1. var list = selected.options.length;
Mar 9 '07 #4
Azzy
5 New Member
Change this line
Expand|Select|Wrap|Line Numbers
  1. var list = selected.options.size;
to
Expand|Select|Wrap|Line Numbers
  1. var list = selected.options.length;
your reply was greatly appreciated! But sadly, the error still returns even after changing the code to what u had advised...
after u have clicked the 'Add To Cart' button, u will still received an error stating that object expected when the quantity text box losses focus... I do not understand what is wrong about the coding too... Stress!! >.<
Mar 9 '07 #5
Logician
210 New Member
your reply was greatly appreciated! But sadly, the error still returns even after changing the code to what u had advised...
after u have clicked the 'Add To Cart' button, u will still received an error stating that object expected when the quantity text box losses focus... I do not understand what is wrong about the coding too... Stress!! >.<
As you know, if nothing is selected, selectedIndex is -1, so you need to check that before you do:
Expand|Select|Wrap|Line Numbers
  1. var selectName = selected.options[selectNo].value;
Mar 9 '07 #6
Logician
210 New Member
your reply was greatly appreciated! But sadly, the error still returns even after changing the code to what u had advised...
after u have clicked the 'Add To Cart' button, u will still received an error stating that object expected when the quantity text box losses focus... I do not understand what is wrong about the coding too... Stress!! >.<
Sadly this poxy forum doesn't allow editing so I have to post again.
The reason for the 'object expected' message on blur is that you are using document.write( ln) in a loaded document. If you do this, it destroys the previous content, which means that function CheckPen no longer exists and cannot be called.
You'll need to do this another way and innerHTML is not the answer.

Also your generated HTML is incorrect and does not produce what you expect in other browsers.
Mar 9 '07 #7
acoder
16,027 Recognized Expert Moderator MVP
Sadly this poxy forum doesn't allow editing so I have to post again.
You can edit within 5 minutes only. What's poxy? Some slang word?
Mar 9 '07 #8
Azzy
5 New Member
Sadly this poxy forum doesn't allow editing so I have to post again.
The reason for the 'object expected' message on blur is that you are using document.write( ln) in a loaded document. If you do this, it destroys the previous content, which means that function CheckPen no longer exists and cannot be called.
You'll need to do this another way and innerHTML is not the answer.

Also your generated HTML is incorrect and does not produce what you expect in other browsers.

WOW!!!! Million Thanks Logician!!! Realli appreciated the advice!!! Thank you for pointing out my mistakes!!! ^^? After much considerations from your advice... i have managed to resolved the issue!!! YEAH!!!! U ARE THE MAN!!! ^^ Realli thanx a lot dude!!! 3 cheers for you!!!
Mar 9 '07 #9
Logician
210 New Member
You can edit within 5 minutes only.
Wow - the pinnacle of usefulness. I hope I've said everthing I meant to say, or if not I remember it real soon.
Mar 9 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

5
5719
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. ================================================================= Error 19: "CORBAManagerMessages.h", line 4 # Unexpected 'std'. using std::string; ^^^
1
10316
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
2295
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...
0
23515
by: HKSHK | last post by:
This list compares the error codes used in VB.NET 2003 with those used in VB6. Error Codes: ============ 3: This Error number is obsolete and no longer used. (Formerly: Return without GoSub) 5: Procedure call or argument is not valid. 6: Overflow. 7: Out of memory.
1
3918
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 Javscript issue. but how do we, mere mortals who know nothing of anything about Java, scripts, etc, fix this? Is there a programm, does MS have any fix? is there any tweak like in the Registry, or whatever, how do I access anyihint java without in IE 7...
6
5331
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. Here's a very simple example which should illustrate what I'm doing. #include <iostream> template <class T> class TestBase {
1
2812
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 incorporate the same logic within my simulation, the class that implements the functor logic has problems compiling. I get the following errors: -- Building myTest.cpp --
2
5746
by: thj | last post by:
Hi. I've got this form that I'm trying to validate: <form id="periodForm" action="" method="post"> <p> Periode: <input id="startDate" name="startDate" type="text" size="7" value="<%= ViewData %>" /> -
2
2463
by: vijayrvs | last post by:
SearchCrawler.java The program search crawler used to search the files from the website. From the following program i got 7 compiler error. can any body clarify it and provide me solution. import java.awt.*; import java.awt.event.*; import java.io.*; import java.net.*; import java.util.*;
0
9535
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
10244
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
10201
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
9061
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...
1
7558
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6802
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
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4130
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
3
2931
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.