Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Passing Parameters in Timeout Javascript

Posted on 2007-08-02
Medium Priority
Last Modified: 2009-06-19
Hello, I'm unable to get the following variables UserId, opt and level when I call the function status from timeout method.
help appreciated.

statusDetailsrefresh[details]=setTimeout('Status(UserId, opt, level)', 10000);
Question by:d2marcelo
1 Comment
LVL 12

Accepted Solution

netsmithcentral earned 1200 total points
ID: 19619003
The first parameter of a setTimeout call is evaluated at the time it is processed... so, to pass it variables you must include them in a properly formatted way (eg quotes for strings).

If, for example, I had the following:
var string = 'This is a string';
var integer = 23;
var DOMNode = document.getElementById('someNode');

To pass those three variables to setTimeout, I would do the following:
setTimeout('doSomething(\'' + string + '\', ' + integer + ', document.getElementById(\'' + DOMNode.id + '\')', 1000);

Here's a guess at what that means you need to change:
statusDetailsrefresh[details]=setTimeout('Status(\'' + UserId + '\', \'' + opt + '\', ' + level + ')', 10000);

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question