Skip to main content
Participant
April 17, 2009
Question

Refreshing form value after submit

  • April 17, 2009
  • 2 replies
  • 2200 views

Ok, bear with me as I'm very new to CFML. I have a form that pulls from a cfquery and autofills two form textboxes with the current values from the datasource. User clicks submit and the changed values are made to the table data. The problem I'm having is that after clicking submit, the values in the two textboxes revert back to the old values prior to the edit. Browsing back to the page displays the new information. Any help would be greatly appreciated.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Modify Homepage</title>
</head>
<cfquery name="getleftmenu" datasource="mysql">
SELECT *
FROM homemenu
</cfquery>
<body>
<cfform format="XML" skin="basic">
<cfoutput query="getleftmenu">
    <cfformgroup type="vertical">
        <cfinput type="text" size="20" length="25" id="menu1label" label="Menu 1 Label:" name="menu1label" value="#getleftmenu.menu1label#" />
        <cfinput type="text" size="20" length="25" id="menu1link" label="Menu 1 Link:" name="menu1link" value="#getleftmenu.menu1#" />
    </cfformgroup>
</cfoutput>
    <cfformgroup type="horizontal" >
        <cfinput id="submit" title="Submit" name="submit"
            value="Submit" type="submit"
            style="margin-left:65px" />
        <cfinput id="reset" title="Reset" name="reset"
            value="Reset" type="reset" label="Reset" />
    </cfformgroup>   
</cfform>

<cfif isdefined("form.submit")>
    <cfquery name="putleftmenu" datasource="mysql">
        UPDATE homemenu
        SET menu1label='#form.menu1label#', menu1='#form.menu1link#'
    </cfquery>
   
    <cfoutput>Update complete</cfoutput> <br />
</cfif>

</body>
</html>

    This topic has been closed for replies.

    2 replies

    Inspiring
    April 17, 2009

    In addition to Dave's questions, how many records is your query returning?

    davidsimms
    Inspiring
    April 17, 2009

    Did you:

    1. Verify any updates are actually being saved to the database?

    2. Actually refresh the form page (by clicking the refresh button), or just browse back to it? If the latter, your browser's reading its cached version (as it should unless you do something to prevent caching).

    kristofjpAuthor
    Participant
    April 17, 2009

    David and Dan,

    Thanks for the reply. 1. I have verified that values are being saved to the database. 2. I refresh the page by hitting enter with the url in the address bar. Refresh attempts resubmit the form data.

    The query is pulling from a table with a single record in it.

    Josh

    davidsimms
    Inspiring
    April 17, 2009

    You're not actually refreshing the page. Try clicking the browser's Refresh button to prevent it from reading from cache.