Skip to main content
Inspiring
June 6, 2014
Answered

set value for input text or textarea

  • June 6, 2014
  • 2 replies
  • 1442 views

I can use following code to set cfinput text and cftextarea a value from my database, but following code fails for html standard components like

<input type="text"> or textarea.

<CFINPUT type="text" name="Mytext" id="idMyText" value="#mySP.MyValue#" />

Are there any way to set value from database for standard controls?

Your help and information is great appreciated,

regards,

Iccsi,

This topic has been closed for replies.
Correct answer Carl Von Stetten

@Iccsi,

You didn't give much of an explanation of "following code fails", so we're shooting in the dark here.  First thought though is: did you wrap the HTML form or input tag with a <cfoutput> tag?  The <cfform> tag includes the functionality of <cfoutput> already, which might be why your <cfinput> code works but <input> doesn't.

Rule of thumb when trying to output ColdFusion variable values to the page: if you aren't inside a ColdFusion tag designed to output data to the page (like CFFORM, CFMAIL, etc.), you need to have an enclosing <cfoutput> tag somewhere.

-Carl V.

2 replies

BKBK
Community Expert
Community Expert
June 7, 2014

iccsi wrote:

... but following code fails for html standard components like

<input type="text"> or textarea.

<CFINPUT type="text" name="Mytext" id="idMyText" value="#mySP.MyValue#" />

Strictly speaking, the code doesn't fail. It simply stores the string "#mySP.MyValue#" as the value of form.Mytext.

Carl Von Stetten
Carl Von StettenCorrect answer
Legend
June 6, 2014

@Iccsi,

You didn't give much of an explanation of "following code fails", so we're shooting in the dark here.  First thought though is: did you wrap the HTML form or input tag with a <cfoutput> tag?  The <cfform> tag includes the functionality of <cfoutput> already, which might be why your <cfinput> code works but <input> doesn't.

Rule of thumb when trying to output ColdFusion variable values to the page: if you aren't inside a ColdFusion tag designed to output data to the page (like CFFORM, CFMAIL, etc.), you need to have an enclosing <cfoutput> tag somewhere.

-Carl V.

iccsiAuthor
Inspiring
June 10, 2014

Thanks a million for the information and help,

Regards,

Iccsi,