473,395 Members | 2,467 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.

Question on math.pow function

I am working on a problem and have been trying for several hours to get this to work. Basically, the form language was provided - I need to input JS code to produce the square root of the number that is inputted by the user and display it on the form.

The form produces fine - the program not computing a result is my issue. Any help is appreciated. Code I have produced is as follows:


Expand|Select|Wrap|Line Numbers
  1. "http://www.w3.org/TR/html4/strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3.  
  4. <script language="JavaScript">
  5. function math.pow(number,2)
  6. </script>
  7.  
  8. <form name="square" action="#">
  9. <input type="text" name="number">
  10. <input type="button" value="compute" onclick="process()">
  11. <input type="text" name="result">
  12. </form>
  13. </html>
Jul 8 '13 #1
4 1598
Rabbit
12,516 Expert Mod 8TB
Please use code tags when posting code.

You have no function named process.
Jul 8 '13 #2
I made some edits, including a process function, however the code still does not work.

I am new to JS - any help is appreciated.

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
  2. "http://www.w3.org/TR/html4/strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <script language="JavaScript">
  6. <!-- 
  7. function process()
  8. {
  9.    var formObj = document.getElementById();
  10.    var number = formObj.number.value;
  11.    {
  12.       formObj.number.value = Math.pow(number,2); break;
  13.    }
  14.  
  15. //  -->
  16. </script>
  17. </head>
  18. <form name="square" action="#">
  19. <input type="text" name="number">
  20. <input type="button" value="compute" onclick="process()">
  21. <input type="text" name="result">
  22. </form>
  23. </html>    
  24.  
  25.  
Jul 9 '13 #3
Rabbit
12,516 Expert Mod 8TB
You didn't tell getElementById which id to get. Also, your form has no id. So you won't be able to get it anyways unless you give it one.
Jul 9 '13 #4
Dormilich
8,658 Expert Mod 8TB
I need to input JS code to produce the square root of the number that is inputted
Math.pow(x, 2) produces the square of x, not its square root (that would be Math.sqrt()).
Jul 9 '13 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Samuel Hon | last post by:
Hi All I'm trying to find a math function (if it exists) in SQL Server. If it doesnt exist, then maybe someone can tell me what its called so I can do a bit more reading on it Basically I...
3
by: Keith P. Boruff | last post by:
Hello all, Currently, in my work, I'm dealing with some old and sloppy C++ code (written before '93). I'm trying to put test harnesses around the stuff I'm working on (using Boost testsuite...
3
by: David | last post by:
Here is some code. I am trying to figure out how to raise, say, x to the yth power. I know that isn't explicitly what is in the code but that is the idea I am trying to solve. See the 2nd for...
3
by: philippe mordellet | last post by:
hello everybody is it possible to ask the user to write a math function (ie : y = ax + b) in a textbox, and use this function to plot the curve in a window (how do Mathematica guys manage this,...
3
by: Agnes | last post by:
my number is 100.1 , Now I only want to get 100 without any round up or round down function, Can anyone told me which function can do that ? Thanks
4
by: Raj | last post by:
Hello Coders- For calculating the Moment, Skew and Kurtosis, i found the following function in the help of C++ builder; But i couln't understand this, of how to use this; What i have is the data...
1
by: gdarian216 | last post by:
question on function and passing it an array this is what i have so far and im getting errors..... int dup_mark(int a, int b); int scores; int value;
10
by: colin | last post by:
Hi, I profile my code and find its spending a lot of time doing implicit conversions from similar structures. the conversions are mainly things like this class Point { implicit conversion...
2
by: Phive | last post by:
Hi all, I'm having some serious issues getting the SUM function below to work. I want to get a total of the three columns: TALKTIMES (which is numeric)*1.5 , the count of REMEDYSRNUMBER, and the...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
0
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,...

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.