Jump to content
Sign in to follow this  
cheen

JavaScript

Recommended Posts

could someone out there help me out how to create an html file with the necessary html and javascript to allow a user to input three positive numbers using a form, and than display their sum, average, and the square root of each. Display all these results in a table. E.g. If the data typed is 4, 9, 25, your page should show: Numbers 4 9 25Square Root 2 3 5Sum 38Average 12.6 Note: You will need to validate the inputted values, and no computation is done until all the data typed in is A POSITIVE NUMBER! If u could show me all the codes please.Thanks.

Share this post


Link to post
Share on other sites

Is this a homework assignment? lolAnyway, I'm not sure how you could do that with just Javascript and HTML, maybe you can, but as far as I know (other than ajax) JavaScript is just a browser scripting language.If you have a JSP page it wouldn't be hard at all. Just submit the page to its self and collect the variables from the request using request.getParameter("NAME"). Check each one to make sure it's greater than zero, and then do your computation if it passes the check.

Share this post


Link to post
Share on other sites

I am as convinced as I need to be that this is a homework assignment. Notice how the language changes from kidspeak "u" in the request to teacher-speak "you" and "your page" in the instructions. I recognize the sloppiness from all the plagiarized papers I have to grade.I won't be helping, and I urge everyone else not to help either.Do you suppose we see other instances of this, only disguised better? I've wondered about a few.OP, if I am wrong, I apologize.

Share this post


Link to post
Share on other sites

If it is homework, I don't mind helping, but I'm not going to just do it for him.A basic idea of what needs to be done :Create a page with the proper formWhen the form is submitted, capture the variables from the request. request.getParameter()Calculate stuff. If you can't do this part without any help, you're in over your head with this project

Share this post


Link to post
Share on other sites

1. Create the form with HTML with name or id; Javascript can access the information by the tag name (HTML element), name you assigned to certain elements [these first two will create an array, so learn arrays and how to access the values inside them], or giving it a unique id.2. Look what type of data you are dealing with and how it's different from what the user can enter.3. Go the home page of w3schools and click JavaScript. Find the Javascript Object that will have relevance with square roots (what school subject are you most likely to see it).4. One thing I will tell you about JavaScript is that YOU will need to tell it when you want to join strings together and when to add numbers together because they both use the + symbol to do both operations; use parenthesis.5. Solve average and remember order of operations.6. Output results.

Share this post


Link to post
Share on other sites

Can't you just ask your teacher? After all, that is what they are there for!By the way, Java != JavaScript

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...