When I put my form up in the browser, IF i dont check the
Instock checkbox then its undefined. If I check it, then it runs
fine. Why is it undefined when uncheck. How can I give my check box
a default value without putting %26lt;cfif
undefined(form.instock)%26gt; make it defined%26lt;/if%26gt; Is there
something i can put into the form to give it a default value
%26lt;table border=''0'' cellspacing=''0'' cellpadding=''0''
style=''position:relative; left:200px; ''%26gt;
%26lt;cfform action=''articlesuccess.cfm?sub=2'' method=''post''
enctype=''multipart/form-data''%26gt;
%26lt;tr%26gt;
%26lt;td width=''139''%26gt;Product Name: %26lt;/td%26gt;
%26lt;td width=''317''%26gt;%26lt;cfinput type=''text''
name=''ProductName''%26gt;%26lt;/td%26gt;
%26lt;/tr%26gt;
%26lt;tr%26gt;
%26lt;td%26gt;Product Price: %26lt;/td%26gt;
%26lt;td%26gt;%26lt;cfinput type=''text''
name=''ProductPrice''%26gt;%26lt;/td%26gt;
%26lt;/tr%26gt;
%26lt;tr%26gt;
%26lt;td%26gt;Product Category:%26lt;/td%26gt;
%26lt;td%26gt;%26lt;cfselect query=''gotShopCat''
display=''ShopCatName'' value=''ShopCatID''
name=''ShopcatName''%26gt;#ShopCatName#%26lt;/cfselect%26gt;%26lt;/td%26gt;
%26lt;/tr%26gt;
%26lt;tr%26gt;
%26lt;td%26gt;In Stock: %26lt;/td%26gt;
%26lt;td%26gt;Yes%26lt;cfinput type=''checkbox'' name=''instock''
value=''yes''%26gt; %26lt;/td%26gt;
%26lt;/tr%26gt;
%26lt;tr%26gt;
%26lt;td%26gt;Product Picture:%26lt;/td%26gt;
%26lt;td%26gt;%26lt;cfinput name=''ProductPic'' type=''file''%26gt;
%26lt;/td%26gt;
%26lt;/tr%26gt;
%26lt;tr%26gt;
%26lt;td valign=''top''%26gt;Product Description: %26lt;/td%26gt;
%26lt;td%26gt;%26lt;cftextarea name=''ProductDesc'' cols=''50''
rows=''10''%26gt;%26lt;/cftextarea%26gt;%26lt;/td%26gt;
%26lt;/tr%26gt;
%26lt;tr%26gt;
%26lt;td%26gt; %26lt;/td%26gt;
%26lt;td%26gt;%26lt;cfinput type=''submit'' name=''submit''
value=''Submit''%26gt;%26lt;/td%26gt;
%26lt;/tr%26gt;
%26lt;/cfform%26gt;
%26lt;/table%26gt;My FORM ELEMENT IS UNDIFINED
Use %26lt;CFPARAM%26gt; for give a default value to undefined
variables or the function IsDefined that returns true or false is
the variable passed as argument is defined :
i.e. :
%26lt;CFPARAM name=''FORM.instock'' default=''NO''%26gt;
%26lt;CFIF IsDefined(''FORM.instock'') EQ False%26gt;
......
%26lt;/CFIF%26gt;
RegardsMy FORM ELEMENT IS UNDIFINED
Yea, I know how to do that, I was just wondering if there was
a special attribute for the %26lt;cfinput type=''textbox''%26gt; tag Just
making sure there wasnt a better way I didnt know about. But I
guess i can do that, thanks for the info.
Ok, I put a Isdefined function in there. I put it on the next
page where the CFC is invoked and the form values are inserted into
a query. Keep in mind that everything works when the checkbox
checked (isdefined) . In bold below is where i inserted it. It
still doesnt work. it still says that my form.instock is still not
defined after i insert what is in bold
%26lt;cfif NOT isdefined(FORM.Instock)%26gt;
%26lt;cfparam name=''FORM%26gt;Instock'' default=''No''%26gt;
%26lt;/cfif%26gt;
%26lt;cfinvoke component=''application'' method=''getcat''
returnvariable=''gotcat''%26gt;
%26lt;cfinvoke component=''application'' method=''ProductEntry''
returnvariable=''success''%26gt;
%26lt;cfinvokeargument name=''Instock''
value=''#Trim(Form.Instock)#''%26gt;
%26lt;cfinvokeargument name=''ProductDesc''
value=''#Trim(Form.ProductDesc)#''%26gt;
%26lt;cfinvokeargument name=''ProductName''
value=''#Trim(Form.ProductName)#''%26gt;
%26lt;cfinvokeargument name=''ProductPic''
value=''#Trim(Form.ProductPic)#''%26gt;
%26lt;cfinvokeargument name=''ProductPrice''
value=''#Trim(Form.ProductPrice)#''%26gt;
%26lt;cfinvokeargument name=''ShopCatID''
value=''#Trim(Form.ShopCatName)#''%26gt;
%26lt;/cfinvoke%26gt;
Seems to be that I didn't be clear enough.
First, the syntax is %26lt;cfparam name=''FORM.Instock''
default=''No''%26gt; and not %26lt;cfparam name=''FORM%26gt;Instock''
default=''No''%26gt; (the %26gt; is incorrect)
%26lt;cfparam name=''FORM.Instock'' default=''No''%26gt;
is the same as using
%26lt;cfif NOT isdefined(FORM.Instock)%26gt;
%26lt;cfset FORM.Instock=''No''%26gt;
%26lt;/cfif%26gt;
And you put it at the top of the page, function of component.
Using :
%26lt;cfif NOT isdefined(FORM.Instock)%26gt;
%26lt;cfparam name=''FORM.Instock'' default=''No''%26gt;
%26lt;/cfif%26gt;
should work but is not the best coding.
Regards
Ah.. by the way.. the behaviour if an HTML checkbox (CFFINPUT
generates an HTML control) is to send the value when is checked,
but if it's unchecked, don't send even the control with an empty
value (like a textbox)
Regards
First, the syntax is %26lt;cfparam name=''FORM.Instock''
default=''No''%26gt; and not %26lt;cfparam name=''FORM%26gt;Instock''
default=''No''%26gt; (the %26gt; is incorrect)
%26lt;cfparam name=''FORM.Instock'' default=''No''%26gt;
-Sojovi
Lets ignore the mistake I made. Cause when its corrected, its
still saying that the FORM.Instock is undefined.
47 : %26lt;cfif NOT isdefined(FORM.Instock)%26gt;
48 : %26lt;cfparam name=''FORM.Instock'' default=''No''%26gt;
49 : %26lt;/cfif%26gt;
And you put it at the top of the page, function of component.
-Sojovi
Why does it matter where I put it if the CF server is saying
that immediately after I submit the form, FORM.Instock is
undefined.
Using :
%26lt;cfif NOT isdefined(FORM.Instock)%26gt;
%26lt;cfparam name=''FORM.Instock'' default=''No''%26gt;
%26lt;/cfif%26gt;
should work but is not the best coding.
-Sojovi
What is the best Coding then
Try this:
%26lt;cfparam name=''FORM.Instock'' default=''No''%26gt;
%26lt;cfinvoke component=''application'' method=''getcat''
returnvariable=''gotcat''%26gt;
%26lt;cfinvoke component=''application'' method=''ProductEntry''
returnvariable=''success''%26gt;
%26lt;cfinvokeargument name=''Instock''
value=''#Trim(Form.Instock)#''%26gt;
%26lt;cfinvokeargument name=''ProductDesc''
value=''#Trim(Form.ProductDesc)#''%26gt;
%26lt;cfinvokeargument name=''ProductName''
value=''#Trim(Form.ProductName)#''%26gt;
%26lt;cfinvokeargument name=''ProductPic''
value=''#Trim(Form.ProductPic)#''%26gt;
%26lt;cfinvokeargument name=''ProductPrice''
value=''#Trim(Form.ProductPrice)#''%26gt;
%26lt;cfinvokeargument name=''ShopCatID''
value=''#Trim(Form.ShopCatName)#''%26gt;
%26lt;/cfinvoke%26gt;
--
Ken Ford
Adobe Community Expert
Fordwebs, LLC
http://www.fordwebs.com
''numerical07'' %26lt;webforumsuser@macromedia.com%26gt; wrote in
message news:euhq5e$r44$1@forums.macromedia.com...
%26gt; First, the syntax is %26lt;cfparam name=''FORM.Instock''
default=''No''%26gt; and not
%26gt; %26lt;cfparam name=''FORM%26gt;Instock'' default=''No''%26gt; (the
%26gt; is incorrect)
%26gt; %26lt;cfparam name=''FORM.Instock'' default=''No''%26gt;
%26gt; -Sojovi
%26gt;
%26gt; Lets ignore the mistake I made. Cause when its
corrected, its still saying
%26gt; that the FORM.Instock is undefined.
%26gt; 47 : %26lt;cfif NOT isdefined(FORM.Instock)%26gt;
%26gt; 48 : %26lt;cfparam name=''FORM.Instock'' default=''No''%26gt;
%26gt; 49 : %26lt;/cfif%26gt;
%26gt;
%26gt; And you put it at the top of the page, function of
component.
%26gt; -Sojovi
%26gt;
%26gt; Why does it matter where I put it if the CF server is
saying that immediately
%26gt; after I submit the form, FORM.Instock is undefined.
%26gt;
%26gt; Using :
%26gt; %26lt;cfif NOT isdefined(FORM.Instock)%26gt;
%26gt; %26lt;cfparam name=''FORM.Instock'' default=''No''%26gt;
%26gt; %26lt;/cfif%26gt;
%26gt; should work but is not the best coding.
%26gt; -Sojovi
%26gt;
%26gt;
%26gt; What is the best Coding then
%26gt;
%26gt;
Take it easy man.. haha.. I'm not saying that you are stupid,
just giving you some tips to solve the problem.
If you put it like Ken said, it should work. If not, try the
:
%26lt;cfif NOT isdefined(FORM.Instock)%26gt;
%26lt;cfset FORM.Instock=''No''%26gt;
%26lt;/cfif%26gt;
REgards
%26gt; It still doesnt work. it still says that my form.instock
is still not defined
%26gt; %26lt;cfif NOT isdefined(FORM.Instock)%26gt;
Looks like you didn't follow Sojovi's original example. You
left out the double quotes around the variable name. From the
documentation
IsDefined(''variable_name'')
Parameter: variable_name
Decription: String, enclosed in quotation marks. Name of
variable to test for.
If you don't put the variable name in quotes, CF will treat
it as a variable and immediately attempt to evaluate it.
Good point cf_dev2. I didnt recognize the quotations in
sojovi's first example. Sorry about that sojovi, I was stupid about
one thing, not paying close attention. This isnt the first time I
screwed that up. I always seem to screw that up when for some dumb
reason. Anyhow thanks everyone, i appreciate it
One quick question just to wrap this discussion up. is it
possible to check if the actual value of a varible isdefined(). If
write the isdefined('''') like so then your evaluate the varible. if
you take the quotations out then your evaluating the value, right ?
If so, why would you do that.
%26gt; is it possible to check if the actual value of a varible
isdefined()
You have to call IsDefined()
first then you can check the variable value.
%26lt;cfif IsDefined(''form.myVariable'') AND form.myVariable is
''Articles''%26gt;
Yes, form.myVariable exists and its value is ''Articles''
%26lt;/cfif%26gt;
%26gt; if you take the quotations out then your evaluating the
value,
%26gt; right ? If so, why would you do that.
I can't think of a reason.
Subscribe to:
Post Comments
(Atom)
No comments:
Post a Comment