Copy link to clipboard
Copied
having trouble multiplying form variables. I have not used CFML for years and I am not sure what I am missing.
<cfset variablea - #form.b# * #form.c#>
I have use '' and () in this as well.
Copy link to clipboard
Copied
OK, there are a couple of things going on. First, your multiplication looks fine, but you've got it as the subtrahend of a subtraction operation. So, that's not going to make sense unless you've got a value in variablea already. (BTW, I had to look up "subtrahend" - it's just a fancy word for "the part after the subtraction sign".) So, you'll probably want to change that to an equality operator.
Second, while what you have will work, most CF developers only use hash marks/pound signs when they want to output a value to the HTML page. So, you could just as easily use
<cfset variablea = form.b * form.c>
Finally, there's nothing here that guarantees that your form variables can be cast as numbers, so you'd probably want to wrap the whole thing in some code to guarantee that. Here's a simple and probably incomplete example.
<cfif isNumeric(form.b) and isNumeric(form.c)>
... do your multiplication ...
<cfelse>
... do something else ...
</cfif>
Dave Watts, Eidolon LLC
Copy link to clipboard
Copied
I do have an = in the actual code. I flubbed it as I wrote it here.
Copy link to clipboard
Copied
What if I want to us a certain number of places in an order number? it is comprised of the data and 4 more places which is the cordcount of the date entered plus 1.
I have this working but not with the extra 0's in front of the second part of the order number. So today would start with 061720202 which is the second order of the day. I want 06172020002
Copy link to clipboard
Copied
<cfset variablea - val(form.b * form.c) />
This assumes that you can guarantee that form.b and form.c are, indeed, parseInt, Int, or float values.
V/r,
^ _ ^