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

using setTimeout when using prototype

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

processForm=function(inservleturl) {
this.inservleturl = inservleturl;
this.submitForm();
}

processForm.prototype.submitForm2=function() {
}

processForm.prototype.submitForm=function() {
setTimeout("submitStep2()", 20);
}
How can the submitForm function's setTimeout call submitStep2?

Thank you.

Jan 31 '06 #1
7 18100
processForm=function(inservleturl) {
this.inservleturl = inservleturl;
this.submitForm();

}

processForm.prototype.submitForm2=function() {
}

processForm.prototype.submitForm=function() {
var self = this;
setTimeout(
function(){ self.submitForm2();}
, 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=function(inservleturl) {
this.inservleturl = inservleturl;
this.submitForm();
}

processForm.prototype.submitForm2=function() {
Should this have been "submitStep2"?
}

processForm.prototype.submitForm=function() {
setTimeout("submitStep2()", 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, "submitStep2" is not a variable in
any scope.
How can the submitForm function's setTimeout call submitStep2?


Try:
var self = this;
setTimeout(function(){self.submitStep2();}, 20);

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Feb 1 '06 #3
Lasse Reichstein Nielsen wrote:
"James Black" <pl***********@gmail.com> writes:
processForm.prototype.submitForm=function() {
setTimeout("submitStep2()", 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, "submitStep2" 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(function(){self.submitStep2();}, 20);

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

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


Say property instead and you are correct.


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


Try:
var self = this;
setTimeout(function(){self.submitStep2();}, 20);

^^^^^
Are you sure?


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

Perhaps it would be more readable to Rename the variable "self" to
"thisProcessFrom", 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/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Feb 1 '06 #5
Lasse Reichstein Nielsen wrote:
Thomas 'PointedEars' Lahn <Po*********@web.de> writes:
Lasse Reichstein Nielsen wrote:
Even if it wasn't, "submitStep2" is not a variable in
any scope. Say property instead and you are correct.


Not understood. I assumed that "submitForm2" should have been
"submitStep2". It was a property of processForm.prototype, 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(function(){self.submitStep2();}, 20);

^^^^^
Are you sure?


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


:)
Perhaps it would be more readable to Rename the variable "self" to
"thisProcessFrom", 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****************@PointedEars.de>, dated Wed, 1 Feb
2006 18:10:51 remote, seen in news:comp.lang.javascript, Thomas
'PointedEars' Lahn <Po*********@web.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.demon.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
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...
5
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
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...
4
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...
12
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. ...
2
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...
2
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 =...
15
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...
10
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 =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...
0
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...

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.