• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Overriding form variables

New Here ,
Apr 26, 2007 Apr 26, 2007

Copy link to clipboard

Copied

Hi,

Is there any way to override a form variable that is being passed. Would it be done via cfif?
....
Ok, that's a bit vague, so I'll try to clarify (I'm a little tired so bear with me ). I have the user fill out a form adding a new part to their inventory. If there going to take some parts out of the new stock there putting in to the database, it would leave a net amount (Gross amount being what was originally going to be inserted). So, on the update page, would I put that cfif statement in saying

<cfif #FORM.resNet# NEQ "">
<cfset #FORM.sOnHand# EQ #FORM.resNet#>
</cfif>

resNet being the resultant total of the previous calculation and sOnHand being the previous amount (gross) that would have been inserted in the form if the resNet field would have been left blank.

I hope my point got across.

Thank you in advance!
TOPICS
Advanced techniques

Views

384

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
community guidelines
LEGEND ,
Apr 26, 2007 Apr 26, 2007

Copy link to clipboard

Copied

What happened when you tried the code you are asking about? By the way, in that specific piece of code, you don't need octothorps.

Votes

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
community guidelines
New Here ,
Apr 27, 2007 Apr 27, 2007

Copy link to clipboard

Copied

Element RESNET is undefined in FORM.

Why don't I need octothorps?

DOH, I had the field disabled. But, even though it's now enabled, (I created a hidden field so that field can be kept disabled and edited the script to output the answer to the hidden field), and changed my query and put it in a if statement, I get a new error:

Data type mismatch in criteria expression

It says it occurs here:
<cfset net = FORM.Net>
<cfif Net NEQ 0>

<cfquery name="aAddItem" datasource="#application.dsn#">
INSERT INTO iParts (pType, pNumber,sOnHand, sNeeded)
VALUES ('#FORM.pType#', '#FORM.pNumber#','#Net#', '#FORM.sNeeded#')
</cfquery>

<cfelse>

<cfquery name="aAddItem" datasource="#application.dsn#">
INSERT INTO iParts (pType, pNumber,sOnHand, sNeeded)
VALUES ('#FORM.pType#', '#FORM.pNumber#','#FORM.sOnHand#', '#FORM.sNeeded#')
</cfquery>

</cfif>

Votes

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
community guidelines
LEGEND ,
Apr 27, 2007 Apr 27, 2007

Copy link to clipboard

Copied

Are all your datatypes char or varchar?

Votes

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
community guidelines
New Here ,
Apr 27, 2007 Apr 27, 2007

Copy link to clipboard

Copied

It's an access database, so...the sOnHand field is set to Number, if that's what you're asking

Votes

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
community guidelines
LEGEND ,
Apr 27, 2007 Apr 27, 2007

Copy link to clipboard

Copied

Then get rid of the quotes around that value.

Votes

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
community guidelines
Advocate ,
Apr 30, 2007 Apr 30, 2007

Copy link to clipboard

Copied

LATEST
a couple of (hopefully helpful) notes about your syntax:

<cfif #FORM.resNet# NEQ "">
<cfset #FORM.sOnHand# EQ #FORM.resNet#>
</cfif>


1) Dan's octothorp comment: If you are using a CF variable inside a <cfif> or <cfset> tag, you don't need to use the # symbol. CF will evaluate those values.
2) The second line should be: <cfset FORM.sOnHand = FORM.resNet> (notice the = sign)

Votes

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
community guidelines
Resources
Documentation