Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Redirecting after form submit, hash tag remains and shouldn't

New Here ,
Oct 08, 2013 Oct 08, 2013

I have a form that submits to itself, validates data, manipulates data if no errors are detected and redirects to another page to confirm the action to the user. If an error is detected, it will show them above the form.

In this case, the form submits to a hash tag (internal anchor) to forward the user to the errors instead of having to scroll.

The issue is that during redirection, the hash tag is added to the destination URL. Here is my test case:

<!DOCTYPE html>

   <head>
       
<title></title>
   
</head>
   
<body>

       
<cfif StructKeyExists(form, "doRedirect")>
           
<cfif form.doRedirect eq 1>
               
<cflocation url="http://adobe.com" addtoken="false">
           
<cfelse>
               
<div id="errors">
                   
<ul>
                       
<li>Some error could have occured here.</li>
                   
</ul>
               
</div>
           
</cfif>
       
</cfif>

       
<form action="#errors" method="post">
       
<div><label for="doRedirect">Do Redirect?</label><select name="doRedirect" id="doRedirect"><option value="0">No</option><option value="1">Yes</option></select></div>
       
<div><input type="submit" value="Go"/></div>
       
</form>
   
</body>
</html>

TOPICS
Getting started
737
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation
Resources