Jump to content
xisto Community
Sign in to follow this  
Phil

Java Help

Recommended Posts

I would like to make a webpage that allows the user to input various numbers into a series of testboxes and when they click calculate it will total the numbers for them and display it at the bottom in another textbox.

Share this post


Link to post
Share on other sites

Well what i want is basically an order form where they also input the quantity and the price is already inputed. I am also confused what is the difference between Java and Javascript or is there a difference? ;)

Share this post


Link to post
Share on other sites

One way to do it is to give make a quantity field and a disabled price field and give each an id:var userTotal;var i=0, ;while(document.getElementById){ var quantity = document.getElementById('quantity' + i).value; var price = document.geteElementById('price' + i).value; var total = quantity * price; userTotal += total; i++;}document.getElementById('totalPrice').value = userTotal;now your going to have issues with decimal places, but thats another story...though often confused, java and javascript are very different. javascript was created by netscape as a browser scripting language that lacks any file i/o,etc. Its simple and easy to learn, whereas java is a more substantial object oriented scripting language that can be used to create standalone applications and such

Share this post


Link to post
Share on other sites

Javascript is easier and more convenient to use, but Java can be used for standalone applications and is overall much more powerful.As for the script you want, it would better to just do it serverside. If it's an order form and not just some sort of calculator, I assume it would involve serverside scripting anyway, so you might as well do the calculations serverside.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.