Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Anchor in cfinclude?

Status
Not open for further replies.

Dawg06

Programmer
Jul 24, 2006
13
0
0
CA
Does anyone know how to cfinclude template with an anchor?

<cfinclude template="page.cfm#midpage">
page.cfm has a form which posts to page_action.cfm. Once the error checking is done on page_action.cfm it kicks back to page.cfm, BUT, I need to go back to the page with the variables and anchor as the form is near the bottom of the page.

Thanks for any help I can get with this :)
 
i dont think it's possible what you are trying to do - the anchor doesn't mean anything server side, what if i had 3 different includes all to a different anchor - what would the page do? I would include the <a> tag in the code as you probably have it now and use javascript to move the page there after the page loads.

=========================================
Don't sweat the petty things and don't pet the sweaty things.
 
If page_action.cfm it kicks back to page.cfm then you should be using <cflocation> tag not the <cfinclude> tag.

<cfinclude> is used when you want to append another file inside the current file.

From the setup it seems that:
1) the user fills out the form, and hits submit
2) the form is sent to page_action.cfm (which is different then page.cfm) where validations occur
3) if the validation passes then the user is sent back to the form.

If the above is true then you'd <cflocation> the user back, not <cfinclude>

____________________________________
Just Imagine.
 
GUJUm0deL is correct that cflocation would be much prefered over cfinclude in this instance, however, the above won't solve the issue of passing variables back to page.cfm to repopulate the form unless your form variables are simple enough that you can append them to the url, but that can get a little ugly.

You may want to consider using target="_blank" in your <form> tag on page.cfm, so when the user submits, it will pop up a new window, and you can have it do whatever you need and just show a "close window" button when the action is complete. The page with the form would not move at all, so you wouldn't have to worry about the anchor or repassing the form fields.

If you *really* want to stick with your current method of using <cfinclude> on your action page, you can change your form tag to include action="action_page.cfm#anchor
 
If you *really* want to stick with your current method of using <cfinclude> on your action page, you can change your form tag to include action="action_page.cfm#anchor"

But if you wrapped the <form...> tag within <cfoutput> tags then you need to double-up on the # or else CF will think #anchor is a variable and is missing the closing #.

EX:<cfoutput><form name="me" action="action_page.cfm##anchor>...

I still feel the <cflocation> tag is more appropriate in this instance. But as jmille34 pointed out the only way to repopulate the form vars is to append them at the back of the URL which will get sloppy and ugly. You can instead use SESSION vars to hold the values and pass them back and forth. If you need an example let us know.

____________________________________
Just Imagine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top