homepage Welcome to WebmasterWorld Guest from 54.204.58.87
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

    
Maths in HTML?
Can sums be done on a basic web page?
CelticFC




msg:608751
 6:01 pm on Dec 23, 2003 (gmt 0)

I would like to allow visitors to my site to do some simple calculations. For example

Enter Number [text box]
multiply by: [text box]

[calculate Button]

Answer is: [answer displayed here]!

Hope you get the general idea!

Is their a method/formula for doing these sorts of sums?
If not what programs should i be using or learning?

I wrote a visual basic application a few years ago that does all the calculations that would be required in my field. I havent touched VB in years so i dont even know if that could be converted to go on the site?

Any help or advice greatly appreciated!

Thanks

 

dmorison




msg:608752
 6:03 pm on Dec 23, 2003 (gmt 0)

Pure HTML has no computational element to it; however you can build an extremely sophisticated calculator in HTML using JavaScript.

Plenty of examples on the web; try:

[google.com...]

If you have no experience of JavaScript it may be best to get into the basics of JavaScript first, in particular how you get and set form field values...

[edited by: dmorison at 6:04 pm (utc) on Dec. 23, 2003]

redzone




msg:608753
 6:04 pm on Dec 23, 2003 (gmt 0)

VB executables can be run in certain web server environments, but you are much better off, using a scripting language such as JavaScript, PERL, or PHP, that is more geared for the web.

Just do a search for -> basic math scripts
and you will get plenty of information on implementing math functionality into your web site.

dwilson




msg:608754
 6:08 pm on Dec 23, 2003 (gmt 0)

Raw HTML cannot do such calculations. HTML makes pages look pretty, but that's about where it stops.

You're interested in some scripting. Server-side scripting requires support by the hosting server. This could be PHP, ASP, Perl, or any number of alternatives. Your visitors would enter the numbers & click the button which would post the figures back to the server. The server would serve up another page with the results.

An alternative is client-side scripting. I think this is what most online mortgage calculators I've seen are doing.

The browser loads a small script & runs it right there. This can be done in VBScript or Java ... probably some alternatives there too. But now that the browser is doing the work, you get into issues of which browsers support which constructs of which languages. Most modern browsers support Java, but there are differences in how they treat various aspects of it.

I think there's a Java forum here ... and you'd get more help there I suspect.

CelticFC




msg:608755
 12:06 pm on Dec 24, 2003 (gmt 0)

Cheers for the replys, seems most of you reckon Java is the way to go.

I have no experience in java at all! but i guess you have got to start somewhere.

Thanks again

Mohamed_E




msg:608756
 1:06 pm on Dec 24, 2003 (gmt 0)

Welcome to WebmasterWorld, CelticFC!

I have no experience in java at all! but i guess you have got to start somewhere.

I wrote a simple JS calculator (my first and only JS program) by looking at a couple of calculators and shamelessly stealing and modifying. Most programming languages are fairly similar, and a simple program in most languages is fairly understandable even by someone who has not used that language.

I used the w3schools tutorials to help me, found them moderately useful. Also asked many questions here when I got stuck!

A full JS book would have been overkill for my needs, but might be the way to go if you plan on doing more than that calculator.

<added>We now have a Javascript Forum [webmasterworld.com] where you can ask for advice.</added>

CelticFC




msg:608757
 1:43 pm on Dec 24, 2003 (gmt 0)

Hi Mohamed

I think a book would probably be a bit of an overkill for me to. The calculations i want to do on the website is quite basic stuff. For example convert Litres to Gallons, PSI to BAR.

If i could find a basic script for this i think it would be easy to modify for other similar conversions.

I was thinking of making the program i made available for free download, but if i can get the conversions to run online it may help in keeping visitors coming back to my site.

HarryM




msg:608758
 1:59 pm on Dec 24, 2003 (gmt 0)

I have no experience in java at all! but i guess you have got to start somewhere.

My apologies if this is too basic, but make sure you are not confusing java with javascript (also known as js). Both have been mentioned here.

trismegisto




msg:608759
 2:53 pm on Dec 24, 2003 (gmt 0)

If your calculation is complicated, maybe the best choice would be to search and download a script already created by someone else, but if it is simple, maybe itís preferable to create it on your own, in that way you will learn in the process, and probably then youíll realize that you can use JavaScript for many other things, it is by far the most used client side language on the web.

I started to learn JavaScript in www.quirksmode.org, so I would recommend to go there to begin with the basics of the language, very good resource i think.

MichaelEKauffman




msg:608760
 11:37 am on Dec 26, 2003 (gmt 0)

Here's a page with conversion tables I use all the time. The calculations are done using JavaScript which is going to be the "easiest" resolution to your situation.

Click on the "Interactive Converters" page and then view source to get some ideas:

www.economatics.co.uk/industrial/conversiontables/

Good Luck

CelticFC




msg:608761
 2:59 pm on Dec 26, 2003 (gmt 0)

Thanks Michael thats just the sort of calculations i needed.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved