I spend way too much time building forms, so I devised a better more
flexible way to work with inputs. (IMHO) :-)

This is function will look for a form value named "Yellow", then a query
value named "Yellow" if it does not find either, it will be blank.  This UDF
lends its self very well for adding required fields and "add / edit" admin
pages..

<cfset variables.var= "Yellow">

<input name="<cfoutput>#variables.var#</cfoutput>" type="text"
value="<cfoutput>#smartvarText(variables.var)#</cfoutput>" size="35"
maxlength="255" >



All of the outputs are and the cfset out side of the input tag to keep Dream
weaver (users) happy.



UDF:
<cfscript>

function smartvarText(var1) {

  if (IsDefined("form.#var1#"))

  { return #form[var1]#;

  }

else if(IsDefined(queryname &'.'& var1))

{ return Evaluate(queryname &'.'& var1);

}

return "";

}

</cfscript>

<cfparam name="queryname" default="NULL" type="string">



Mark W. Breneman
-Cold Fusion Developer
-Network Administrator
  Vivid Media
  [EMAIL PROTECTED]
  www.vividmedia.com
  608.270.9770

-----Original Message-----
From: Tipton, Joshua [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 06, 2004 10:46 AM
To: CF-Talk
Subject: RE: CFIF within input

<cfif isdefined("var_name")>

  _____  

From: Robert Orlini [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 06, 2004 11:34 AM
To: CF-Talk
Subject: RE: CFIF within input

Tony,

When I try this I get this error:
Parameter 1 of function IsDefined which is now "text" must be a
syntactically valid variable name

RO

-----Original Message-----
From: Tony Weeg [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 06, 2004 11:32 AM
To: CF-Talk
Subject: RE: CFIF within input

but at the same time...i would...

<cfif isDefined(side_1_comments) and len(side_1_comments)>
  <input type="text" size="95" name="side_1_comments"
value="#trim(side_1_comments)#" maxlength="100">
<cfelse>
  <input type="text" size="95" name="side_1_comments" maxlength="100">
</cfif>

just to double check, and its more read-able :)

hth
tony

-----Original Message-----
From: Tony Weeg [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 06, 2004 11:28 AM
To: CF-Talk
Subject: RE: CFIF within input

ur missing a ">"

<input type="text" size="95" name="side_1_comments" maxlength="100" <CFIF
trim(side_1_comments) NEQ ""> value="#trim(side_1_comments)#"</cfif>>

try that.

-----Original Message-----
From: Robert Orlini [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 06, 2004 11:21 AM
To: CF-Talk
Subject: CFIF within input

I want to display text in a input box's value field if there is any info in
the database. The code I'm trying is:

<input type="text" size="95" name="side_1_comments" maxlength="100" <CFIF
trim(side_1_comments) NEQ "" value="#trim(side_1_comments)#"</cfif>>

But I get an error. It seems simple, but I must be missing something I can't
see.

Any suggestion please? Thanks.

Robert O.
HWW
  _____

  _____

  _____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to