Skip to main content
Known Participant
May 6, 2010
Question

Help Please

  • May 6, 2010
  • 1 reply
  • 1451 views

I am a novice cold fusion writer. I would like to set a variable on a cell from a table with in a page. Then i would like to extract that data in a procces page to make a email with cfmail. I need to know how to set the cell on the table to a variable and how to pull that variable in a cfmail to make it veiwable in an email.

Thanks

Guy

    This topic has been closed for replies.

    1 reply

    ilssac
    Inspiring
    May 6, 2010

    As a new developer you are going to need to get a clearer idea of what happens on the Client and what happens on the Server.  ColdFusion is a server technology.  It runs on the server behind the web server (IIS, Apache, etc).  A client makes a request to a web server.  If the request is for a resource the web server has been configured send to ColdFusion it fowards the request.  ColdFusion processes any dynamic instructions (CFML) found in the requested file, builds a response (HTML, JavaScript, CSS, XML, PDF, an ever growing list of outputs) and returns this to the web server.  The web server sends the response back to the client.  The Client then does what it is built to do with the request, i.e. render HTML, execute JavaScript, apply CSS directives, pass the PDF file to a plug-in, etc.

    So it is unclear from your request to "set a variable" to a table cell and extract the data from the cell what you are trying to do on the server and what you are trying to do on the client.  It would be very easy to set the content of an <td></td> tag set to a value of a variable before that HTML markup is sent back to the browser.  It is no more difficult to also use that value in an email.  But if you are expecting the value to somehow be generated or modified on the client and that trigging all these actions, that is not so easy and will take sometype of request|response communction between the client and server.

    A silly example of the first, simple option:

    myFirstCFML.cfm

    <cfset variables.aVariable = "Look at me ma, I'm using a variable">

    <table>

      <tr>

        <td><cfoutput>#variables.aVariable#</cfoutput></td>

      </tr>

    </table>

    <cfmail from="an.Address@email.com" to="my.Address@email.com" subject="testing one two three testing">

    #variables.aVariable#

    </cfmail>

    P.S.  It sure is encouraging to see so many people new to ColdFusion showing up these days.  Kind of puts a damper on those "ColdFusion is Dead" diatribes one runs into here and there.

    Guy DowdAuthor
    Known Participant
    May 6, 2010

    In a sense i am try to do the simple thing you have written. but I want to take it a step further and

    set the <td></td> as the variable and take the text from that cell and input it into an email. I want this because this changes per different link tho this table.

    For example:

    <table>

    <td><b>Part #</b></td>

    <td>1234567</td>

    </table>

    I want to take <td></td> in red into the cfmail

    I know how to write cfinputs and input that into a cfmail

    for example:

    <cfinput type="Text" name="company" required="no" size="40">

    then on process page

    <b>Company:</b> #form.company#

    I hope this helps clarify what I am attempting to do.

    Thanks

    Guy Dowd

    ilssac
    Inspiring
    May 6, 2010

    Guy Dowd wrote:


    I hope this helps clarify what I am attempting to do.

    Thanks

    Guy Dowd

    Not really.  I need to understand where you are expecting the value for this variable to come from.

    If you have a variable you want to use for an HTML table cell, use the same variable in the <cfmail...> tag.

    The form scope (i.e. form.company) is just one class of variables, the <cfmail...> tag can use the whole gament of ColdFusion variable scopes: variables, session, application, server, client, cookie, attributes, form, url, etc.