Preserved Topic: Simple calculations using javascript????? (Page 1 of 1) |
|
---|---|
Bipolar (III) Inmate From: Derbyshire, UK |
posted 01-12-2001 09:30
I don't even know if this can be done using javascript (or it is java?) but stay with me . . . . . |
Bipolar (III) Inmate From: |
posted 01-12-2001 21:25
This is interesting. I've been thinking lately about trying to make a calculator for a website. I created a nice looking calculator in PS and wanted it to actually work in a browser, like a real calculator. You know, click on a number and that number appears in the screen (all precreated graphics) then each of the + - / * and = signs would be on buttons, and some script would keep track of all that was going on to work like a real calculator. Wasn't really going to worry about it yet, but since Trixter asked first, thought I'd throw this in. Any thoughts on how to get started??? |
Paranoid (IV) Inmate From: 127.0.0.1 |
posted 01-12-2001 23:44
Go to Blood Alcohol Calculator and click on the button. You'll see one that I am working on. Nothing fancy, but it might answer your question. |
Nervous Wreck (II) Inmate From: |
posted 01-13-2001 05:24
I may not make the prettiest web pages in the world, but this sort of question is something I can handle. To see something I did with forms and calculations, swing by: |
Paranoid (IV) Inmate From: 127.0.0.1 |
posted 01-13-2001 06:44
Man, stuff like that should be on the gurusnetwork! |
Maniac (V) Mad Scientist From: New California |
posted 01-13-2001 06:55
You can also perform the computations and include the results "inline" by including javascript code in the body of your page. Usually you put the javascript in the header. Here's an example page: code: <html> |
Bipolar (III) Inmate From: Derbyshire, UK |
posted 01-13-2001 07:00
Scarab, I like the juggler, but I have no idea which pieces of code I need to strip out. Could you help me out with a real simple example. |
Bipolar (III) Inmate From: Derbyshire, UK |
posted 01-13-2001 07:03
Oob Bug, you beat me by 5 minutes. That looks very close to what I'm after, except that the value for the variable a, b & c need to come from the forms input, how do you factor that into the calculation? |
Bipolar (III) Inmate From: Derbyshire, UK |
posted 01-13-2001 07:13
Pugzly, I've just had a look at the alcohol calculator! Excellent. |
Nervous Wreck (II) Inmate From: |
posted 01-15-2001 04:24
OK, it looks like you have everything you need except how to pull data out of a form. It sounds like all of the forms you're looking for can be "selects" rather than anything where you type... So, in the body of the html, you should have something like: |
Nervous Wreck (II) Inmate From: |
posted 01-15-2001 04:31
Um, Pugzly, was that comment about gurusnetwork directed at me? I thought my juggler page was fun, but wouldn't be the best subject of a tutorial: the javascript code could still use a bit of "cleaning up" and would be rather long (and, thus, annoying to wade through) in any event. I suppose I could make a much-simplified version, to use as an example of grabbing data from javascript forms, but as I noted, WebMonkey does a pretty darned good job of that already. |
Paranoid (IV) Inmate From: 127.0.0.1 |
posted 01-15-2001 05:04
Trixter - There is a lot of validation code in there to make sure someone enters data in all four fields. That's optional. |