Calculated Form Fields
5 Message(s) by 3 Author(s) originally posted in cfml database access
| From: advancemal |
Date: Sunday, October 21, 2007
|
I come from a desktop
development background with products like
access/
file maker etc. I am used to easily dropping calculated fields on
forms
to do things like calculate invoice totals, tax amounts etc... Is there any
similar way of doing this on Cold Fusion page. These'd need to dynamicaly
change on the
client side as other fields on the form change. I honestly cant
see how to do this and the only possible
solution I can think of is to have a
complex JAVAscript
function to do all the calculations each time the form
onchange()
event is fired, any ideas'd be greatly appreciated.
| From: Dan Bracuk |
Date: Sunday, October 21, 2007
|
You have already answered your question with the word JAVAscript. You were also
right about it being complex. Not only do you've to do the math, you've to
verify that your users entered
numbers into the
text box. JS has something
called
NaN (not a number) that looks promising but has a gotcha. The
string
"a6" is NaN, which you'd expect. However, "6a" is 6, which you wouldn't
expect.
| From: advancemal |
Date: Sunday, October 21, 2007
|
thanks, what about doing the calculations as
query fields in the bac end sql
server and living with the fact that a refresh/recalcuate button'd be
needed? which is the lesser of 2 evils? what about all this
talk of ajax etc,
is there anything in the
pipeline to accomplish this easier?
| From: cf_dev2 |
Date: Sunday, October 21, 2007
|
[b]advancemal[/b]
> which is the lesser of 2 evils?
IMO submitting another request to the server to do calculations you could
easily perform on the client-side does not make sense.
[b]advancemal[/b]
> have a complex JAVAscript function to do all the calculations ...
> what about all this talk of ajax etc
Ajax uses JAVAscript anyway.
If you
break it
down into small pieces, the functions aren't that complex.
You'd need one function to convert an input string to a number (0 if its NaN).
Another to format the numeric values if desired. Put the functions in an
external file so you can
reuse them. Then
include the .js files and call the
two functions where needed.
function convertToNumber() {
...
}
function formatAsDecimal() {
...
}
function calculateTotal() {
var quantity = convertToNumber(document.getElementById('qty').value);
var price = convertToNumber(document.getElementById('price').value);
var total = quantity * price;
document.getElementById('total').value = formatAsDecimal(total);
}
| From: advancemal |
Date: Sunday, October 21, 2007
|
thanks all, that was very helpful to me.:grin;
Next Message: Help with calling Oracle Procedure
Blogs related to Calculated Form Fields
Isp
... kalispell, montana how marine radar synchronizes antenna and display plastic gumball dispencer wind chime display rack mosses dispers whispering palms holiday resort iworo badagry nis-room19.wikispace.co
coldfusion display query
...
list of noble prize winners...
Physics - Presented to John Bockris of Texas A&M University, for his achievements in
cold fusion, in the transmutation of base elements into gold, and in the electrochemical incineration of domestic rubbish.
...
21 new messages in 10 topics - digest
inadvertantly discover a new
form of
cold fusion or did you just find a way to harness the excess amounts of hot air generated on most film sets?... Best, Billy. On Oct 11, 5:33 pm, Larry Fisher
wrote: ...
Questions and Answers About Physics
A: Sadly, cold fusion is science fiction. While it is true that fusion is in principle an excellent and abundant alternative source of energy, we do not yet understand how to get a commercially viable, sustained fusion reaction. ...
Elapsed time/DB question...
And what datatype should the field be? Just a number, and insert total seconds into it? But maybe I wanna use minutes:seconds.... I've done this: User lands on the form page: User submits the eval: Calculate elapsed time for this eval ...
10 new messages in 4 topics - digest
time using only static electric and magnetic fields. One such configuration is called a Penning Trap, after the inventor FM Penning. The trap consists of a several cylindrically symmetric electrodes and a uniform magnetic field applied ...