473,837 Members | 1,791 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

using setTimeout when using prototype

I have an object, and I define the following:
var processForm=new Object();

processForm=fun ction(inservlet url) {
this.inservletu rl = inservleturl;
this.submitForm ();
}

processForm.pro totype.submitFo rm2=function() {
}

processForm.pro totype.submitFo rm=function() {
setTimeout("sub mitStep2()", 20);
}
How can the submitForm function's setTimeout call submitStep2?

Thank you.

Jan 31 '06 #1
7 18120
processForm=fun ction(inservlet url) {
this.inservletu rl = inservleturl;
this.submitForm ();

}

processForm.pro totype.submitFo rm2=function() {
}

processForm.pro totype.submitFo rm=function() {
var self = this;
setTimeout(
function(){ self.submitForm 2();}
, 20);
}

Jan 31 '06 #2
"James Black" <pl***********@ gmail.com> writes:
I have an object, and I define the following:
var processForm=new Object();
No need to assign an object to the variable when you overwrite
it immediatly afterwards:
processForm=fun ction(inservlet url) {
this.inservletu rl = inservleturl;
this.submitForm ();
}

processForm.pro totype.submitFo rm2=function() {
Should this have been "submitStep 2"?
}

processForm.pro totype.submitFo rm=function() {
setTimeout("sub mitStep2()", 20);
WHen the first argument to setTimeout is a string, then it
is parsed and executed as a program in the global context.
Even if it wasn't, "submitStep 2" is not a variable in
any scope.
How can the submitForm function's setTimeout call submitStep2?


Try:
var self = this;
setTimeout(func tion(){self.sub mitStep2();}, 20);

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Feb 1 '06 #3
Lasse Reichstein Nielsen wrote:
"James Black" <pl***********@ gmail.com> writes:
processForm.pro totype.submitFo rm=function() {
setTimeout("sub mitStep2()", 20);


WHen the first argument to setTimeout is a string, then it
is parsed and executed as a program in the global context.
Even if it wasn't, "submitStep 2" is not a variable in
any scope.


Say property instead and you are correct.
How can the submitForm function's setTimeout call submitStep2?


Try:
var self = this;
setTimeout(func tion(){self.sub mitStep2();}, 20);

^^^^^
Are you sure?
PointedEars
Feb 1 '06 #4
Thomas 'PointedEars' Lahn <Po*********@we b.de> writes:
Lasse Reichstein Nielsen wrote:

Even if it wasn't, "submitStep 2" is not a variable in
any scope.


Say property instead and you are correct.


Not understood. I assumed that "submitForm 2" should have been
"submitStep 2". It was a property of processForm.pro totype, but it was
not a variable anywhere.
How can the submitForm function's setTimeout call submitStep2?


Try:
var self = this;
setTimeout(func tion(){self.sub mitStep2();}, 20);

^^^^^
Are you sure?


.... checking ... rechecking ... yes, I'm sure.

Perhaps it would be more readable to Rename the variable "self" to
"thisProcessFro m", but that would not change the meaning of the
program.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Feb 1 '06 #5
Lasse Reichstein Nielsen wrote:
Thomas 'PointedEars' Lahn <Po*********@we b.de> writes:
Lasse Reichstein Nielsen wrote:
Even if it wasn't, "submitStep 2" is not a variable in
any scope. Say property instead and you are correct.


Not understood. I assumed that "submitForm 2" should have been
"submitStep 2". It was a property of processForm.pro totype, but it was
not a variable anywhere.


What I meant was that a method reference does not need to be a
identifier of a variable for the method to be possible to be called.
How can the submitForm function's setTimeout call submitStep2?
Try:
var self = this;
setTimeout(func tion(){self.sub mitStep2();}, 20);

^^^^^
Are you sure?


... checking ... rechecking ... yes, I'm sure.


:)
Perhaps it would be more readable to Rename the variable "self" to
"thisProcessFro m", but that would not change the meaning of the
program.


Correct. Sorry, I overlooked the first line, probably because it was late.
PointedEars
Feb 1 '06 #6
JRS: In article <23************ ****@PointedEar s.de>, dated Wed, 1 Feb
2006 18:10:51 remote, seen in news:comp.lang. javascript, Thomas
'PointedEars' Lahn <Po*********@we b.de> posted :

Correct. Sorry, I overlooked the first line, probably because it was late.


You've already been told to pay more attention to what you write.

Time-of-day is no excuse for carelessness.

Gaining a reputation for unreliability will not enhance your career
prospects.

Feeling that you must answer, even if in haste, is mere arrogance; you
are not indispensable.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME ©
Web <URL:http://www.uwasa.fi/~ts/http/tsfaq.html> -> Timo Salmi: Usenet Q&A.
Web <URL:http://www.merlyn.demo n.co.uk/news-use.htm> : about usage of News.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
Feb 2 '06 #7
Thank you for the suggestion. I will try it in tomorrow and see what
happens.

Feb 3 '06 #8

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

Similar topics

29
8789
by: Mic | last post by:
Goal: delay execution of form submit Code (Javascript + JScript ASP): <% Response.Write("<OBJECT ID='IntraLaunch' STYLE='display : none' WIDTH=0 HEIGHT=0 CLASSID='CLSID:0AE533FE-B805-4FD6-8AE1-A619FBEE7A23' CODEBASE='IntraLaunch.CAB#version=5,0,0,3'>") Response.Write("<PARAM NAME='ImageLoc' VALUE='Null'>") Response.Write("<PARAM NAME='ImageSrc' VALUE='Null'>")
5
2581
by: oliver | last post by:
Hi, the structure of my source code is like this: <script> C = function(){ //some initialization } C.prototype.start = function{ //some action
6
15235
by: marktm | last post by:
Hi- I am trying to use setInterval to call a method within an object and have not had any luck. I get "Object doesn't support this property or method" when I execute the following code. What I am doing wrong? Your help will be much appreciated. Thanks
4
1940
by: Telmo Costa | last post by:
I have a HTML page with a form with 2 buttons like this .... <input type="button" value="Add" onClick="ClickAdd();"/> <input type="button" value="Reset" onClick="ClickReset();"/> .... I also have this javascript code: ----------------------------------------
12
5563
by: Andrew Poulos | last post by:
With the following code I can't understand why this.num keeps incrementing each time I create a new instance of Foo. For each instance I'm expecting this.num to alert as 1 but keeps incrementing. Foo = function(type) { this.num = 0; this.type = type this.trigger(); } Foo.prototype.trigger = function() {
2
10418
by: rain_c1 | last post by:
hi, i think this is a little exercise for real experts, but i suffer from real headaches because of it... :-\ i have an object method (method1), that calls setTimeout with an other method (method2) as parameter which calls further another method (method3), but i do not know how to realize it. it is important to use object context and not static members, because method3 uses a member (more precisely a constructor parameter) that
2
9456
by: petermichaux | last post by:
Hi, I've been searching google and the archives here but haven't found a clear solution. I want to do something like the following function C(){ this.message = 'hi'; } C.prototype.set = function(){ setTimeout(this.talk, 4000);
15
3804
by: nikki_herring | last post by:
I am using setTimeout( ) to continuously call a function that randomly rotates/displays 2 images on a page. The part I need help with is the second image should rotate 3 seconds after the first image rotates. I cannot figure out how to accomplish the 3 second delay. My code is pasted below: function randPic(){ randPic1(); randPic2();
10
1942
by: Evan Charlton | last post by:
Hey all, I'm having some trouble with window.setInterval() within a custom object/prototype. Here is my code: function MyClass() { // do some junk // ... // define methods this.m_one = function() { // nothing happens with this line. No alert, no errors
0
9853
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
9696
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
10903
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...
0
10584
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
10644
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
10289
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
9423
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...
0
5681
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
3131
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.