SinceForever
SinceForever

Reputation: 232

Placing Text from textboxes into textareas using ColdFusion

I have tried several different thigs which did not work, so I decided to do a total edit to show some f the work I have done and go more in depth with what I am trying to accomplish. However, I will still keep it short so you guys don't have to sift through so much code

Basically, I have two different CFM's (Code1.cfm and Code2.cfm). Essentially I need to get some variables that are entered into text blocks from Code1.cfm into a specific area in Code2.cfm.

Code1.cfm code:

<table>
 <tr>
  <td>Full Name:</td>
  <td>
   <input type="text" label="FirstName" value="#FirstName#" name="FirstName">
  </td>
  <td>
   <input type="text" label="LastName" value="#LastName#" name="LastName">
  </td>
 </tr>
 <tr>
  <td>
   <unput type="submit" name="btn_Update" value="Update" 
    onclick="return confirm('Are you sure you want to update your selection?')">
  </td>
 </tr>
 <tr>
  <td>
   <IFrame id="sugg" name="NoteForm" width="745" height="205" src="Form2.cfm"></IFrame>
  </td>
 </tr>
</table>

<FORM action="form2.cfm" method="post" target="Notes">
 <CFIF IsDefined("FirstName") OR IsDefined("LastName")>
  <cfoutput>
   The Full Name has been changed to #form.FirstName# #form.LastName#.
  </cfoutput>
 </CFIF>
</FORM>

Code2.cfm code:

    <FORM>
    <TABLE width="670" background="/Index_MAB/_Images/CCT_Backdrop.jpg">
    <TR style="font: 8pt tahoma; color: 000066"  background="/Index_MAB/_Images/CCT_Backdrop.jpg">
        <TD align="left" width="498" valign="top"><textarea style="font: 8pt verdana; color: 000000; background-color:F7F5F0" name="Eng_Notes2" cols=75 rows=10 wrap="VIRTUAL" >
                #HtmlEditFormat(Eng_Notes)#
            </textarea></TD>
        <TD align="left" width="80" valign="top">
            <CFIF #Date_LastUpdate# IS NOT ''>
                <FONT color="FF0000">Updated:</FONT><BR> #DateFormat(Date_LastUpdate, 'dd-mmm-yy')#
            <CFELSE>
                <FONT color="003366">Entered:</FONT><BR> #DateFormat(DateofEntry, 'dd-mmm-yy')#
          </CFIF>
        </TD>
        <TD align="left" width="110" valign="top">
            <input type="submit" name="btn_updnote" value=" Update " style="font: 7pt verdana; color: CC0000;" ONCLICK="return confirm('You are about to Update this NOTE - are you sure?')">
        </TD>               
        <TD width="2%"></TD>
    </TR>   
    </CFOUTPUT>
    </TABLE>
    </FORM>
    <FORM>
<TABLE width="670" background="/Index_MAB/_Images/CCT_Backdrop.jpg">
    <TR style="font: 8pt tahoma; color: 000066"  background="/Index_MAB/_Images/CCT_Backdrop.jpg">
        <TD align="left" width="498" valign="top">
            <TEXTAREA STYLE="font: 8pt verdana; color: 000000; background-color: F3F8F7" NAME="Eng_Notes" COLS=75 ROWS=2 WRAP="virtual"></TEXTAREA>
        </TD>
        <TD align="left" width="110" valign="top">
            <input type="submit" name="btn_addnote" value="   Enter    " style="font: 8pt verdana; color: 003399;" ONCLICK="return confirm('You are about to Add a NOTE  - are you sure?')">
        </TD>               
        <TD width="2%"></TD>
    </TR>   
    </TABLE>
</FORM>

This whole thing is set up to where people can enter in notes as they feel and they type those comments into the second Text Area on Code2.cfm. When they are submited it is displayed in the first Text Area on Code2.cfm. I am trying to get the first Text Area on Code2.cfm to still continue to display the #HtmlEditFormat(Eng_Notes)# as it has been as well as display this automatic blanket statement about the Names being updated when they are done so by the user.

I hope this makes sense. I am trying to give you guys as much information as possible while not using useless code and still reamining discreet per the customer.

forgot to mention one thing. I have tried the format #form.FirstName# as well as #HtmlEditFormat('FirstName') and also session (which I may be doing incorrectly), and all I get is the comments that have already been made to display. None of the comments involving the updated name.

Edit
So I have made some progress, and it was not using the method I set out to, but by easier means.

When I asked this question I did not have acces to the database so I was not able to view the variables to make it happen through SQL, but just so happens I happen to get the permissions before I could figure out a way to do it any other way.

Anyway, I set the note I was trying to apply to the other textarea by using another textarea in the first form form for Example

Addition to Form1.cfm

<textarea name="new_name" style="visibility:hidden">The first and last name has been updated>

Then I made an insert statement for SQL to put the variable new_name where I needed it which so happens to be in the Eng_Note so that it can be displayed in the text area on the second form (form2.cfm)

I am still having 2 problems. The way it is set now it will update in the database everytime the form is submitted, which as you can see could lead to a memory issue, so therefore I need to make it to where it will only be submitted if the First and Last Name are updated? Also is it even possible for me to put variables from the database into the first textarea?

<textarea name="new_name" style="visibility:hidden">The first and last name has been updated>

I would like for it to be displayed in there like I had originally stated.Any help would be much appreciated.

Upvotes: 0

Views: 1304

Answers (3)

SinceForever
SinceForever

Reputation: 232

so the text area in the second box was pulling data from a database, so what I wound up doing is making some hidden text areas and putting the inormation that I needed in there and then used those values of the form and made an insert statement so it would be uploaded into the referenced data table

Upvotes: 0

Dan Bracuk
Dan Bracuk

Reputation: 20804

This is a formatted comment. You have this:

<TEXTAREA STYLE="font: 8pt verdana; color: 000000; background-color:F7F5F0" 
NAME="Eng_Notes" ID="Eng_Notes" COLS=75 ROWS=10 WRAP="VIRTUAL" >
#HtmlEditFormat(Eng_Notes)#
</TEXTAREA>

A textarea is not exactly the best spot to use the HtmlEditFormat() function. Let's say the value of Eng_Notes was, "if a <= b && b <= c then a <= c". Put that in your textarea with and without the function and decide what's best for your situation.

You also have this:

<CFIF #Date_LastUpdate# IS NOT ''>

You don't need the octothorps. All you need is this:

<CFIF Date_LastUpdate IS NOT ''>

You also said this, "I know in c# this would be accomplished using session settings." Transferring form submission values to the session scope can be done in .net, php, ColdFusion and pretty much any other web programming server side programming language. However, in all these languages, you still have to submit the form. Also, in all programming languages, it's risky. With modern browsers the likelihood of people changing those session variables in a way the programmer did not anticipate is much higher than it was 15 years ago.

Upvotes: 1

andrewdixon
andrewdixon

Reputation: 1069

All data from a form submission is available on the target in the form scope. Docs are here:

http://help.adobe.com/en_US/ColdFusion/10.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7ffe.html

Basically in your example "FirstName" and "LastName" would be available as:

#form.FirstName#

and

#form.LastName#

on the form target, which I have assumed is form2.cfm.

Hope that helps.

Upvotes: 0

Related Questions