473,805 Members | 2,272 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
19 2007
acoder
16,027 Recognized Expert Moderator MVP
Wow - the pinnacle of usefulness. I hope I've said everthing I meant to say, or if not I remember it real soon.
See this post. You only need to edit a post if you've made a mistake (which you should realise by re-reading your response).

If you've just got something to add, there's no harm in posting again.
Mar 9 '07 #11
Azzy
5 New Member
Thanx Logician and acoder!!! ^^?
Mar 10 '07 #12
acoder
16,027 Recognized Expert Moderator MVP
Thanx Logician and acoder!!! ^^?
Nah. It was Logician really who pointed out the most important things. Still, if you must, you're welcome anytime!
Mar 12 '07 #13
rpjd
25 New Member
Nah. It was Logician really who pointed out the most important things. Still, if you must, you're welcome anytime!
Object expected.
I have a form button calling a javascript file but I am getting object expected error.
form code taken from file c:\Databases\ph pscripts\viewPa rts.php
Expand|Select|Wrap|Line Numbers
  1. <? include("c:\Databases\javascripts\getParts.js") ?>
  2. <form name="parts" onSubmit="getParts.js"> //object expected
  3.     <input type="button" name="getParts" id="getParts" value="getParts" onclick="Parts();" />
  4.     </form>
  5.  
the javasscript being called getParts.js
Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript">
  2. function Parts()
  3.     { 
  4.     var url="http://localhost/Databases/phpscripts/parts.php"; 
  5.     if(window.XMLHttpRequest)
  6.     http = new XMLHttpRequest(); 
  7.     else if (window.ActiveXObject)
  8.     http  = new ActiveXObject(Microsoft.XMLHTTP); 
  9.     http.onreadystatechange = function()
  10.     { 
  11.     alert(http.readyState);
  12.     if(http.readyState == 4)
  13.         {
  14.         alert(http.status)
  15.         if(http.status == 200)
  16.             {
  17.             alert("hi");
  18.  
  19.             }    
  20.         else    
  21.             {
  22.             alert(http.status);
  23.             }    
  24.         } 
  25.     }
  26. http.open("GET", url, true); 
  27. http.setRequestHeader("text"); 
  28. http.send(null); 
  29. </script>
  30.  
The alert is just to verify ajax call works. Can anyone see what is causing the problem. any help appreciated.
Apr 21 '07 #14
Logician
210 New Member
Object expected.
I have a form button calling a javascript file but I am getting object expected error.
Too vague. What if anything do you get in the fireFox console?
Apr 21 '07 #15
rpjd
25 New Member
Too vague. What if anything do you get in the fireFox console?
Nothing, for some reason beyond my comprehension, my html file is not showing up in the dir having restarted apache server. I put the function being called into the html file the calls it and it worked fine. Now even though I have the complete file path of the external file in the include and the form action, the action is not seeing the external file, which is in the same dir.
The html file form1.html is in C:\Databases\we bpages
the javascript file Hi.js is in C:\Databases\ja vascripts

html file form1.html
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <HTML>
  3.  <HEAD>
  4.   <TITLE> New Document </TITLE>
  5.   <META NAME="Generator" CONTENT="EditPlus">
  6.   <META NAME="Author" CONTENT="">
  7.   <META NAME="Keywords" CONTENT="">
  8.   <META NAME="Description" CONTENT="">
  9.   <script src="c:\Databases\javascripts\Hi.js"></script>
  10.  </HEAD>
  11.  
  12.  <BODY>
  13.  <form action="c:\Databases\javascripts\Hi.js">
  14.     <input type="button" value="Hi" onclick="Hi();" />
  15.     </form>
  16.  </BODY>
  17. </HTML>
  18.  
javascript file Hi.js
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript" language="javascript">
  2. alert("hi");
  3. </script>
  4.  
Not sure if I need full path in the action though since its in the include. Can anyone help me on this?

RPJD
Apr 22 '07 #16
rpjd
25 New Member
Nothing, for some reason beyond my comprehension, my html file is not showing up in the dir having restarted apache server. I put the function being called into the html file the calls it and it worked fine. Now even though I have the complete file path of the external file in the include and the form action, the action is not seeing the external file, which is in the same dir.
The html file form1.html is in C:\Databases\we bpages
the javascript file Hi.js is in C:\Databases\ja vascripts

html file form1.html
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <HTML>
  3.  <HEAD>
  4.   <TITLE> New Document </TITLE>
  5.   <META NAME="Generator" CONTENT="EditPlus">
  6.   <META NAME="Author" CONTENT="">
  7.   <META NAME="Keywords" CONTENT="">
  8.   <META NAME="Description" CONTENT="">
  9.   <script src="c:\Databases\javascripts\Hi.js"></script>
  10.  </HEAD>
  11.  
  12.  <BODY>
  13.  <form action="c:\Databases\javascripts\Hi.js">
  14.     <input type="button" value="Hi" onclick="Hi();" />
  15.     </form>
  16.  </BODY>
  17. </HTML>
  18.  
javascript file Hi.js
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript" language="javascript">
  2. alert("hi");
  3. </script>
  4.  
Not sure if I need full path in the action though since its in the include. Can anyone help me on this?

RPJD
Hi.js is actually
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript" language="javascript">
  2. function Hi()
  3. {
  4. alert("hi");
  5. }
  6. </script>
  7.  
Apr 22 '07 #17
rpjd
25 New Member
Hi.js is actually
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript" language="javascript">
  2. function Hi()
  3. {
  4. alert("hi");
  5. }
  6. </script>
  7.  
Is it possible for an onclick function to call a a javascript function within an external javascript file without passing any parameters? The script being called is an xmlhttprequest which is getting info from a database query and returning the info. I not sure whether the "object expected" is a parameter or the file containing the script being called by onclick. The external file has been included with a full file path
Expand|Select|Wrap|Line Numbers
  1. <script src="http://localhost/ProjectFolder/Filename"></script>
  2.  
Can anyone offer a solution?

rpjd
Apr 22 '07 #18
acoder
16,027 Recognized Expert Moderator MVP
If you're using Ajax, why are you submitting a form?

You're trying to submit to a js file when in fact you should submit to a script which can deal with the response.

On which line does the error occur? Try checking the Firefox console.
Apr 27 '07 #19
rpjd
25 New Member
If you're using Ajax, why are you submitting a form?

You're trying to submit to a js file when in fact you should submit to a script which can deal with the response.

On which line does the error occur? Try checking the Firefox console.
Can someone help me with this?
I am trying to submit a form to update/add a database table
here is he code. It is giving me object expected at
Expand|Select|Wrap|Line Numbers
  1. onclick="get(this)";
  2.  
paramter is var poststr.

Expand|Select|Wrap|Line Numbers
  1. .<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <? include("http://localhost/Project/customers.php") ?>
  3. <HTML>
  4.  <HEAD>
  5.   <TITLE> ALLIED AUTO PARTS </TITLE>
  6.   <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
  7.   <META NAME="Generator" CONTENT="EditPlus">
  8.   <META NAME="Author" CONTENT="">
  9.   <META NAME="Keywords" CONTENT="">
  10. <script type="text/javascript" language="javascript">
  11. var url="http://localhost/Project/addCustomer.php";
  12. function addCustomer(url,parameters)
  13. if(window.XMLHttpRequest)
  14. http = new XMLHttpRequest(); 
  15. else if (window.ActiveXObject)
  16. http  = new ActiveXObject(Microsoft.XMLHTTP); 
  17. http.onreadystatechange = function()
  18. alert(http.readyState);
  19. if(http.readyState == 4)
  20. {
  21. alert(http.status)
  22. if(http.status == 200)
  23. {
  24.     response = http.responseText;
  25.     alert(response);
  26. }    
  27. else    
  28. {
  29. // + " " + http.statusText;
  30. alert(http.status);
  31. }    
  32. }
  33. http.open("GET", url + parameters, true); 
  34. http.setRequestHeader("text"); 
  35. http.send(null); 
  36.  
  37. function get(obj) 
  38.     {
  39.       var poststr = "?"
  40.       if (document.updateCustomer.customer_name.value != "")
  41.         {
  42.           poststr += document.updateCustomer.customer_name.name + "=" + document.updateCustomer.customer_name.value + "&";
  43.         }
  44.     if( document.updateCustomer.customer_address.value !="")
  45.             {
  46.             poststr += document.updateCustomer.customer_address.name + "=" + document.updateCustomer.customer_address.value + "&";
  47.             }
  48.             if (document.updateCustomer.customer_contact_no.value != "")
  49.                 {
  50.                 poststr += document.updateCustomer.customer_contact_no.name + "=" + document.updateCustomer.customer_contact_no.value;
  51.                 }
  52.                 else
  53.                 {
  54.                     alert("You missed one or more entries!");
  55.                 }
  56.                 addCustomer(url, poststr);
  57.    }
  58. </script>
  59. <script type="text/javascript" language="javascript">
  60.   function reset()
  61.   {
  62.       document.updateCustomer.customer_name.value="";
  63.       document.updateCustomer.customer_address.value="";
  64.       document.updateCustomer.customer_contact_no.value="";
  65.   }
  66.   </script>
  67.  
  68.   </HEAD>
  69.     <BODY onload="reset();">
  70. <p align="center">
  71. To add a new customer fill in the new customers name, address and contact number, then click <b>addCustomer</b>.
  72. <p align="center">
  73. To delete an existing customer, fill in the the details form the customers listed above, then click <b>deleteCustomer</b>.
  74. <p>
  75. <table border="1" align="center">
  76. <tr>
  77. <td align="center">Customer Name</td>
  78. <td><input type="hidden" size="10"/></td>
  79. <td align="center">Customer Address</td>
  80. <td><input type="hidden" size="10"/></td>
  81. <td align="center">Customer Contact Number</td>
  82. </tr>
  83. <tr>
  84. <form name="updateCustomer" method="get" action="javascript:get(document.('updateCustomer'));">
  85. <td align="center"><input type="text" name="customer_name" id="customer_name" size="25" value=""/></td>
  86. <td><input type="hidden" size="10"/></td>
  87. <td align="center"><input type="text" name="customer_address" id="customer_address" size="25" value=""/></td>
  88. <td><input type="hidden" size="10"/></td>
  89. <td align="center"><input type="text" name="customer_contact_no" id="customer_contact_no" size="12" value=""/></td>
  90. <td><input type="hidden" size="10"/></td>
  91. <td align="center"><input type="button" name="addCustomer" value="addCustomer" onclick="get(this);"/></td>
  92. <td><input type="hidden" size="10"/></td>
  93. <td align="center"><input type="button" name="deleteCustomer" value="deleteCustomer" onclick="deleteCustomer();"/></td>
  94. </form>
  95. </tr>
  96. </table>
  97. </p>
  98. <H1 align="center">ALLIED AUTO PARTS</H1>
  99. <p>
  100. <TABLE align="center">
  101. <TR>
  102.     <TD align="center" colspan="6"><H3>Choose from the following funtions</H3></TD>
  103. </TR>
  104. <TR>
  105.     <TD><a href="ViewParts.php">View Parts</a></TD>
  106.     <TD><a href="Purchases.php">Purchases</a></TD>
  107.     <TD><a href="Sales.php">Sales</a></TD>
  108.     <TD><a href="UpdateParts.php">Add parts</a></TD>
  109.     <TD><a href="UpdateCustomer.php">Update Customer</a></TD>
  110.     <TD><a href="UpdateSupplier.php">Update Supplier</a></TD>
  111. </TR>
  112. </TABLE>
  113.  
rpjd
Apr 27 '07 #20

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

Similar topics

5
5721
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
10317
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
2298
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
23517
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
5334
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
2821
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
2464
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
9718
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
9596
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
10617
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
10370
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
10109
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
9186
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
7649
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...
2
3849
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
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.