Skip to main content

Loops in Javascript



The do...while Loop

The do...while loop is just a variant of the while loop. In such loop the block of code is always executed atleast once. The loop will repeat as long as the specified condition is true.

Syntax:

do
{
// Enter here the code to be executed
}
while (var<=endvalue); E.g. Using do…while loop to display numbers

Output: Number:0 Number:1 Number:2 Number:3 Number:4 Note: This loop will always be executed at least once, even if the condition is false, because the code is executed before the condition is tested. 4. JavaScript Break and Continue JavaScript has two special statements that can be used inside loops: a. break: The break command will break the loop and continue executing the code that follows after the loop (if any). E.g Using break statement to come out of the for loop



Output:

The number is 0
The number is 1

b. Continue: The continue command is used in case you need to break the current loop and continue with the next one.

E.g.







Output:

Number:0
Number:1
Number:3
Number:4
Number:5
4.4.3 JavaScript Popup Boxes
In JavaScript you have the ability to pickup the user input or display small amount of text to the user using dialog boxes. There are kinds of popup boxes: Alert box, Confirm box, and Prompt box. These dialog boxes appear as separate windows and their content depend on the information that has been input by the user.
Note: The content of these dialog boxes is independent of the text in the HTML page and do not effect content of webpage in any way.
The three types of dialog boxes are:
1. Alert Box: You can use alert box if you want to make sure information comes through to the user. It is the simplest way to output small amount of textual information to browser’s window. The javaScript alert() method takes a string argument and displays an alert dialog box in the browser window when it is invoked by appropriate code in javaScript. The alert box will display string passed to the alert() method and the ‘OK’ button. User cannot proceed without clicking on the alert button.
Syntax:
alert("text message ");
E.g. Using Alert Box to message user





Output:


2. Prompt Box: You can use prompt box to input a value before entering a page. When a prompt box pops up, the user needs to click either "OK" or "Cancel" to proceed after entering an input value. In case user clicks "OK" button prompt box returns the input value where as if the user clicks "Cancel" the box will return null value.

Syntax:
prompt("text message ","defaultvalue");

E.g. Prompting user to answer a question using Prompt Box







In case user answers correct i.e. user enters 25. Following screen will be displayed on the browser:










3. Confirm Box: JavaScript provides a confirm box to prompt user for verification or confirmation before continuing further with the execution of JavaScript. When a confirm box pops up, the user will have to options either to click on "OK" or "Cancel" button to proceed. In case user clicks "OK", the box returns true and if the user clicks "Cancel", the box returns false.
Syntax:

confirm("text message");

Example:









As the browser finds confirm box following output will be generated.

Comments

Popular posts from this blog

Advantages and Disadvantages of EIS Advantages of EIS Easy for upper-level executives to use, extensive computer experience is not required in operations Provides timely delivery of company summary information Information that is provided is better understood Filters data for management Improves to tracking information Offers efficiency to decision makers Disadvantages of EIS System dependent Limited functionality, by design Information overload for some managers Benefits hard to quantify High implementation costs System may become slow, large, and hard to manage Need good internal processes for data management May lead to less reliable and less secure data

Inter-Organizational Value Chain

The value chain of   a company is part of over all value chain. The over all competitive advantage of an organization is not just dependent on the quality and efficiency of the company and quality of products but also upon the that of its suppliers and wholesalers and retailers it may use. The analysis of overall supply chain is called the value system. Different parts of the value chain 1.  Supplier     2.  Firm       3.   Channel 4 .   Buyer

CONCEPTUAL VIEW OF MIS

The concept is a blend of principles, theories and practices of management, information and system giving rise to a single product called MANAGEMENT INFORMATION SYSTEM . The concept of management gives high regard to the individual and his ability to use the information. MIS gives information through data analysis. While analyzing the information, it relies on many academic disciplines like management science, OR, organization behavior, psychology, etc. The foundation of MIS is the principles of management and its practices. MIS uses the concept of management control in its design and relies heavily on the fact that the decision maker is a human being and is a human processor of information. A MIS can be evolved for a specific objective it is evolved after systematic planning and design. It calls for an analysis of business, management views and policies, organization culture and the management style. The MIS,therefore relies heavily on systems theory.The systems theory offers soluti