I’m trying to find the root cause of the error message when viewing my CF page, however the page still functions correctly. I have to apologize now. This is my third day using CF. I really appreciate any help
<cfsetting showDebugOutput="Yes">
<form id="form1" name="form1" method="post" action="">
<label for="Chris3">Please Select.<br />
</label>
<select name="Chris3" id="Chris3">
<option value="COOKWARE/CUTLERY">COOKWARE/CUTLERY</option>
<option value="BAKEWARE/ ELECTRICS">BAKEWARE/ ELECTRICS</option>
<option selected="selected">Please Select one</option>
</select>
<input type="submit" name="SUBMIT" id="SUBMIT" value="Submit" />
</form>
<p>
<cfset Chris3 ="Form.Chris3">
<cffile action="append"
file="C:\Inetpub\wwwroot\PURGE\WS\DEPTM.txt"
output="#Chris3#">
Error Message:
The following information is meant for the website developer for debugging purposes.
Error Occurred While Processing Request
Variable CHRIS3 is undefined.
The error occurred in C:\Inetpub\wwwroot\PURGE\WS\PURGE.cfm: line 29
27 : <cffile action="append"
28 : file="C:\Inetpub\wwwroot\PURGE\WS\DEPTM.txt"
29 : output="#Chris3#">
30 : </p>
31 : <p>Below are Departments that have finished reviewing the purge</p>
--------------------------------------------------------------------------------
Resources:
Check the ColdFusion documentation to verify that you are using the correct syntax.
Search the Knowledge Base to find a solution to your problem.
Browser Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E)
Remote Address 192.168.97.38
Referrer
Date/Time 06-Apr-12 03:30 PM
Stack Trace (click to expand)
It looks like there are two issues:
The first issue is where you’re setting the variable
Chris3. If you want it to be equal to the value passed into the form, then you need to use.. the way you have it written now it’s storing the literal string “form.Chris3” as the entered value.
The second is that field does not exist until after the form is submitted. You can do one of two things to handle this. Either add a
cfparam, like Scott suggested, so the value is always defined:OR you can add a check to see if the form has been submitted before you access set the value to your variable:
If you used
<cfparam>simply check the field’s length instead:As far as the value showing up undefined, I don’t see anything wrong with your code. I copy and pasted it and it worked fine on my machine.