Skip to main content
Participant
May 1, 2009
Question

how to solve this problem

  • May 1, 2009
  • 1 reply
  • 754 views

Hi ...how to solve this problem........In a form there is a  Cfbutton which is of submit type.when the user click this button i want a insertquery to be executed which collects datat from a dynamic table.I dont want to reload the whole page when the user clicks this button.

<table border="2px">
                                              <tr>
                                                <td>product</td>
                                                <td>Lot</td>
                                                <td>d_amount</td>
                                                <td>d_unit</td>
                                               
                                              </tr>
                                              <cfoutput query="qrecipes">
                                                <tr>
                                                  <td>#qrecipes.ingredient#</td>
                                                  <td><cfselect name="lot" id="lot" ><option value=1>xyz</option><option value=2>abc</option></cfselect></td>
                                                  <td>#qrecipes.d_amount#</td>
                                                  <td>#qrecipes.d_unit#</td>
                                                
                                                 
                                                </tr>
                                              </cfoutput>
                                            </table>

                                          <cfinput type="submit" name="storebuild" value="sotrebuild">
                              <cfinput type="submit" name="clear" value="clear">

when the user clicks the storebuild button i want to run a insert query to enter the data displayed in to another table.how do i need to approach thisproblem.

    This topic has been closed for replies.

    1 reply

    ilssac
    Inspiring
    May 1, 2009

    nagkar wrote:

    I dont want to reload the whole page when the user clicks this button.

    The most common way to do something like that is with a JavaScript asynchronous http request using XMLHttpRequest() object, aka AJAX.  CF 8 has many built in AJAX tools.  As well as the community grown AJAXCFC and CFAJAX frameworks that work with older MX generation CF versions.  Or you can roll your own.

    There is plenty of searchable resources and documentation about any or all of those options.

    nagkarAuthor
    Participant
    May 1, 2009

    Thanks Ian skinner for the reply........... i am totally new to ajax..i dont know anything about ajax...can you say some tips  how to start solving this problem. and some material that tells about cfajax, it would be very helpful to me.......Is there any alternate method if i say that when the button is clicked the page can reload...... and one more question how do i call a coldfusion function when i click a cfbutton

    ilssac
    Inspiring
    May 1, 2009

    At the most basic you use XMLHTTPRequest() or a frame work that does it for you to make a request to an URL behind the scenes and then process the returned results.  This is not a simple example of one or two lines of code.  There are serious concepts here to master and it will take some trial and error and reading of the manual to get it right.

    Using Ajax UI Component and Features

    http://livedocs.adobe.com/coldfusion/8/htmldocs/ajaxui_1.html

    Using Ajax Data and Development Features

    http://livedocs.adobe.com/coldfusion/8/htmldocs/ajaxdata_01.html

    AjaxCFC

    http://www.robgonda.com/blog/projects/ajaxcfc/

    CFAjax

    http://www.indiankey.com/cfAjax/

    Mastering Ajax

    http://www.ibm.com/developerworks/web/library/wa-ajaxintro1.html

    http://www.ibm.com/developerworks/web/library/wa-ajaxintro2/

    http://www.ibm.com/developerworks/web/library/wa-ajaxintro3/

    http://www.ibm.com/developerworks/web/library/wa-ajaxintro4/

    http://www.ibm.com/developerworks/web/library/wa-ajaxintro5/

    http://www.ibm.com/developerworks/web/library/wa-ajaxintro6/

    http://www.ibm.com/developerworks/web/library/wa-ajaxintro7.html

    http://www.ibm.com/developerworks/web/library/wa-ajaxintro8.html

    http://www.ibm.com/developerworks/web/library/wa-ajaxintro9/

    http://www.ibm.com/developerworks/library/wa-ajaxintro10/

    http://www.ibm.com/developerworks/web/library/wa-ajaxintro11.html

    If you want to forgo the AJAX route, then you just submit the form to an action page, the action page takes the data and processes it as desired and then builds a response to send to the browser.  This response can easily simple be a new version of the original form with some new information included as desired.

    Another old school technique would be to open new windows or frames with JavaScript that make a request and display the results.  One can Google for examples, tutorials and documentation on this technique just like I did to give the above list of links.