Note that there are some explanatory texts on larger screens.

plurals
  1. POSelf submitting form redirect still contains internal anchor
    primarykey
    data
    text
    <p>I currently have a form which points to itself but more precisely, to an internal anchor for errors:</p> <pre><code>&lt;form action="#errors" method="post"&gt; ... &lt;/method&gt; </code></pre> <p>When the form is submitted, I will validate incoming data and if errors are present output them on the screen (located inside the internal anchor). If the data is valid, I will redirect to a confirmation page:</p> <pre><code>&lt;cflocation url="confirm.cfm" addToken="no" /&gt; </code></pre> <p>My problem is that the page redirected to still contains the reference to the internal anchor. The URL looks like this:</p> <pre><code>http://mydomain.com/confirm.cfm#errors </code></pre> <p>I've tried this with other languages and was able to replicate this functionality without the anchor remaining after having redirected.</p> <p><strong>Edit #1</strong></p> <p>This is on CF10, Windows 2008 R2.</p> <p>Form page:</p> <pre><code>&lt;cfif not structIsEmpty(form)&gt; &lt;cfinvoke component="#request.cfcPath#.val" method="init" returnvariable="valObj"&gt;&lt;/cfinvoke&gt; &lt;cfset valObj.validateGame()&gt; &lt;cfif valObj.hasErrors()&gt; &lt;cfoutput&gt;#valObj.showErrors()#&lt;/cfoutput&gt; &lt;cfelse&gt; &lt;cfif form.editYN eq 0&gt; &lt;cfinclude template="actInsert.cfm"&gt; &lt;cfelse&gt; &lt;cfinclude template="actUpdate.cfm"&gt; &lt;/cfif&gt; &lt;/cfif&gt; &lt;/cfif&gt; </code></pre> <p>actUpdate.cfm</p> <pre><code>&lt;!--- Redirect ---&gt; &lt;cfquery&gt;...&lt;/cfquery&gt; ... &lt;cflocation url="default.cfm?fuseaction=Confirm.gameUpdated" addtoken="No"&gt; </code></pre> <p>actInsert.cfm</p> <pre><code>&lt;!--- Redirect ---&gt; &lt;cfquery&gt;...&lt;/cfquery&gt; ... &lt;cflocation url="default.cfm?fuseaction=Confirm.gameAdded" addtoken="No"&gt; </code></pre> <p><strong>Edit #2</strong></p> <p>Here's a test case:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;head&gt; &lt;title&gt;&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;cfif StructKeyExists(form, "doRedirect")&gt; &lt;cfif form.doRedirect eq 1&gt; &lt;cflocation url="http://stackoverflow.com" addtoken="false"&gt; &lt;cfelse&gt; &lt;div id="errors"&gt; &lt;ul&gt; &lt;li&gt;Some error could have occured here.&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/cfif&gt; &lt;/cfif&gt; &lt;form action="#errors" method="post"&gt; &lt;div&gt;&lt;label for="doRedirect"&gt;Do Redirect?&lt;/label&gt;&lt;select name="doRedirect" id="doRedirect"&gt;&lt;option value="0"&gt;No&lt;/option&gt;&lt;option value="1"&gt;Yes&lt;/option&gt;&lt;/select&gt;&lt;/div&gt; &lt;div&gt;&lt;input type="submit" value="Go"/&gt;&lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload