Putting a Calculator in a Web Page
Putting a Calculator in a Web Page
Author
Discussion

406

Original Poster:

3,636 posts

283 months

Tuesday 12th April 2005
quotequote all
Does any one know how to add a Calculator into a web page. I need to add a function so a customer puts the size of their garden in cell and it gives them a figure that is multiplied by a fixed number.

It actually needs to multiply A x B x C (C is a fixed number) = Total

Thanks in advance

Dave

zaktoo

1,401 posts

270 months

Tuesday 12th April 2005
quotequote all
The easiest solution is to use javascript. The best solution is to use a server-side script to process the data. Depending on what platform your server is you'd need to figure out what language to write that in. For most platforms though, perl is available and quick to use for such an application.

Ciao

Zak

docevi1

10,430 posts

278 months

Tuesday 12th April 2005
quotequote all
like this?

the code is here



edit:: for the constant value, it'd be easy enough to change c to be a hidden field within the form, or ignore the c field altogether and simply multiply by a given number in the function.

>> Edited by docevi1 on Tuesday 12th April 18:27

406

Original Poster:

3,636 posts

283 months

Tuesday 12th April 2005
quotequote all
docevi1 said:
like this?

the code is here



edit:: for the constant value, it'd be easy enough to change c to be a hidden field within the form, or ignore the c field altogether and simply multiply by a given number in the function.

>> Edited by docevi1 on Tuesday 12th April 18:27


Stefan

All I get when I click your link is the calculation, not the code

Dave

Don

28,378 posts

314 months

Tuesday 12th April 2005
quotequote all
All you need to do is right-click and select View Source from the menu. The calculation all happens on the client (in the web browser) no server side nonsense at all and is EXACTLY what I would have done - good job Stefan...

406

Original Poster:

3,636 posts

283 months

Tuesday 12th April 2005
quotequote all
Don said:
All you need to do is right-click and select View Source from the menu. The calculation all happens on the client (in the web browser) no server side nonsense at all and is EXACTLY what I would have done - good job Stefan...


Great, thanks. Sorry, being a bit of a div today

docevi1

10,430 posts

278 months

Wednesday 13th April 2005
quotequote all


the second link there was a plain text file - should have loaded up in IE easy enough.

406

Original Poster:

3,636 posts

283 months

Thursday 14th April 2005
quotequote all
How do I hide value c so it does not show?

I am hopeless at this sort of stuff, born too early

406

Original Poster:

3,636 posts

283 months

Friday 15th April 2005
quotequote all
Bump

FunkyGibbon

3,860 posts

294 months

Friday 15th April 2005
quotequote all
406 said:
How do I hide value c so it does not show?

I am hopeless at this sort of stuff, born too early


change < input type="number" size=4 value=20 name="c" >

to < input type="hidden" value=?? name="c" >

where ?? is the value of your constant.

(remove the spaces after < and before the >, I've only added them so you can see the code on PH)

406

Original Poster:

3,636 posts

283 months

Friday 15th April 2005
quotequote all
FunkyGibbon said:

406 said:
How do I hide value c so it does not show?

I am hopeless at this sort of stuff, born too early



change < input type="number" size=4 value=20 name="c" >

to < input type="hidden" value=?? name="c" >

where ?? is the value of your constant.

(remove the spaces after < and before the >, I've only added them so you can see the code on PH)



Thanks for that, I will give it a try

Dave

docevi1

10,430 posts

278 months

Friday 15th April 2005
quotequote all
check the links again - I've done it for you

demo
code

406

Original Poster:

3,636 posts

283 months

Friday 15th April 2005
quotequote all
Thanks a million guys