Highlighted

Math

New Here ,
Jun 15, 2020

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.

Views

120

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Math

New Here ,
Jun 15, 2020

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.

Views

121

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jun 15, 2020 0
Adobe Community Professional ,
Jun 15, 2020

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 15, 2020 0
New Here ,
Jun 17, 2020

Copy link to clipboard

Copied

I do have an = in the actual code.  I flubbed it as I wrote it here.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 17, 2020 0
New Here ,
Jun 17, 2020

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 17, 2020 0
LEGEND ,
Jun 15, 2020

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,

 

^ _ ^

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 15, 2020 0