473,804 Members | 2,536 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

OO JS and onsubmit - error: not a function

This is probabally a basic question, but I don't quite understand what
is going on with this...

Say I have a variable called "myObject" which is an object created from
a class I wrote. The class has a method called "testing".

When I submit a form, I want to call it:
<form onsubmit="myObj ect.testing()" ...

When I click the submit button for the form, I get the following
message in Mozilla's JavaScript Console:
"Error: myObject.testin g is not a function"

While trying to figure this out, I created a new function called
"test_form" , and changed the form declaration to look like:
<form onsubmit="test_ form()" ...

Test form looks like this:
function test_form(){
myObject.testin g();
}

When I do this, the script works exactly as I had intended it to. Can
any of you js experts tell me why that is?

Jul 23 '05 #1
2 2479
Justin Koivisto wrote:
When I submit a form, I want to call it:
<form onsubmit="myObj ect.testing()" ...

When I click the submit button for the form, I get the following
message in Mozilla's JavaScript Console:
"Error: myObject.testin g is not a function"


Probably you have another object or property named "myObject"
which is found in the form element's scope chain before your
requested object is found; this could be a form element named
"myObject", for example.

Try to find out what's happening by
1) trying <form onsubmit="alert (myObject.testi ng)"> (cave:
no function calling round brackets!)
2) looking for other occurences of "myObject" in your document

ciao, dhgm
Jul 23 '05 #2
DOH! Such a simply thing to overlook! Thanks a bunch!

Jul 23 '05 #3

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

Similar topics

3
4544
by: Varun | last post by:
Hi There, I have a form("myRequest.asp") and the values from it are retrieved into the page ("output_Print.asp") on which I have two buttons('Save As Complete' and 'Save As Incomplete'). When the 'Save as Incomplete' button is Clicked the form will be going to the "SaveAsincomplete.asp" without validation of the fields. And when the 'save as complete' is clicked certain fileds are to be validated and by the function return value, if false...
12
1656
by: micahl0180 | last post by:
Ok, I am having trouble with the code below, but cannot seem to find the problem. When I run it, it says Object Expected" and points me to line 31: <form action="" method="post" name="payroll" onSubmit="earnings()"> Can anyone spot teh error in my ways. Thanks again for all your help, you guys have been great and our making my class SOOOOOO much easier. TIA, ML
2
6473
by: Sean Dockery | last post by:
Which is the following is correct? a) <form ... onSubmit="return checkData()"> b) <form ... onSubmit="return checkData();"> c) <form ... onSubmit="checkData()"> d) <form ... onSubmit="checkData();">
8
1803
by: Chris Kettenbach | last post by:
I have a function that validates a text box. Is there anyway to run that function on submit and if it returns false to cancel the submit. Any ideas. Thanks Guys! This group is awesome. Thanks, Chris
4
10152
by: usl2222 | last post by:
Hi folks, I appreciate any assistance in the following problem: I have a form with a bunch of dynamic controls on it. All the controls are dynamically generated on a server, including all the validators. The user enters the data, presses OK. My OK button is dynamically generated as well, with some code-behind logic in
4
3703
by: cssExp | last post by:
hello, i want to check for errors on submitting a form, on encountering an error it runs a function and returns a false preventing form submit. I have implemented that. function eCheck() { var filePath = document.getElementsByName("fileSelect"); if (filePath == '')
2
6610
by: Sorrow | last post by:
If you have an onsubmit event handler defined for a form, it doesn't seem to trigger if you manually call the .submit() method of the form object. Is there any way you can make sure that code is executed? thnx, Christoph
8
6854
by: Mark Livingstone | last post by:
I have a form that uses the following: onSubmit="some_var = 'validated';" FireFox is OK with that. Internet Explorer isn't. any ideas why? Thanks.
2
4778
by: rudiedirkx | last post by:
Gents, I have a problem (only in Safari) with the onsubmit in webforms. This topic covers the same subject: http://bytes.com/topic/javascript/answers/166542-onsubmit-safari but not as detailed as I will. Let me illustrate the problem with examples. The HTML: <html> <head> <script type="text/javascript" src="/js/mootools_1_11.js"></script>
0
9711
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
9591
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
10594
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
10331
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
10087
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
5667
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4306
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
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
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.