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

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="myObject.testing()" ...

When I click the submit button for the form, I get the following
message in Mozilla's JavaScript Console:
"Error: myObject.testing 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(){

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 2443
Justin Koivisto wrote:
When I submit a form, I want to call it:
<form onsubmit="myObject.testing()" ...

When I click the submit button for the form, I get the following
message in Mozilla's JavaScript Console:
"Error: myObject.testing 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.testing)"> (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

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...
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"...
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 ......
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,...
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...
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() { ...
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...
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.
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...
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...

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.