Copy link to clipboard
Copied
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>
Copy link to clipboard
Copied
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).
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
You're not actually refreshing the page. Try clicking the browser's Refresh button to prevent it from reading from cache.
Copy link to clipboard
Copied
Refreshing the page using the browser refresh submits the form again and then shows the correct value in the textbox, but that's not the problem I'm having.
What I want the page to do is to show me the new value in the textbox without having to refresh or reload the page. Currently I clear the old value, enter the new one, click submit, and the new value is replaced in the textbox with the old one. When I click submit, I want the new value I entered to stay displayed in the textboxes.
Copy link to clipboard
Copied
The lack of an action attribute in your cfform tag might be relevent.
Copy link to clipboard
Copied
I added an action attribute and it does the same thing.
Copy link to clipboard
Copied
In addition to Dave's questions, how many records is your query returning?