Purchase Solution

A javascript function to double numbers

Not what you're looking for?

Ask Custom Question

Create a Web page named double.html whose HEAD includes the DoubleIt function. The page should contain a text box with an initial value of 1 and a button labeled "Double It". When the user clicks the button, the DoubleIt function should be called to double the contents of the text box.

If you start with a value of 1 in the text box, how many times must you click the button before the displayed value exceeds 500? How many times to exceed 1000?

Purchase this Solution

Solution Summary

This solution shows how to create a Javascript function to double a number. The solution shows how to integrate this function with an HTML file. See attachment for further details.

Solution Preview

The DoubleIt function is fairly straight-forward. The function needs to find the input field and then double the value in that field. The function is as follows:

function DoubleIt() {
var el = document.getElementById("numfield");
el.value *= 2;
}

The "getElementById" function call will find the input field named ...

Purchase this Solution


Free BrainMass Quizzes
Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.

C# variables and classes

This quiz contains questions about C# classes and variables.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.