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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Coming back to the file after submitting the file in coldfusion

Status
Not open for further replies.

VisualBasicHelp

Programmer
Sep 7, 2005
74
GB
In coldfusion, after submitting the form it goes to another file where I am writing sql queries which inserts some records and does a verification. I like to bring the control back to the calling file and do the rest of the work in that file.

I am new to coldfusion and don't have any idea how to do it.
 
I prefer the <cflocation url=""> tag because that takes the user away from the code that processes the form.

The <cfinclude template=""> tag includes the page inside the processing page which can be problematic if the user hits refresh because that will rerun all the queries and other processing you might be doing.


____________________________________
Just Imagine.
 
Won't this load the first full page. I would like to bring the control below the first page's form tag and do the next work.
 
What's the setup of the page? How many forms do you have on the 1st page? Does 1st page have sections that you need the user to complete in order to go on?

Give us some code samples or a test URL, maybe there's an easier way to do this.

You should also consider the maintenance aspect for this page. In the future if you need to make updates/tweaks/or trouleshooting it's a good idea to keep the application flow as convientant as possible.

____________________________________
Just Imagine.
 
<!--show_randomize_IWR.cfm --->
<!-- In this file some insert and select queries are also there --->

<body>
<cfinclude template="show_GetSubject_IWR.cfm">
<cfinclude template="show_DOB.cfm">
</body>

<!---show_Get_subject_IWR.cfm--->
<head>

<script type="text/javascript">
function go()
{
return document.getElementById("subject_id").value;
}
</script>
</head>
<body>
<cfform name="get_subject_IWR" action="Get_Subject_Insert_IWR.cfm" method="get" target="show">
<cfoutput query="subject_select">
<option value="#subject_select.subject_id#">#subject_select.subject_id#&nbsp;&nbsp;</cfoutput>
</select
<cfoutput>
<cfoutput>
<input type=submit SIZE="20" READONLY VALUE="Confirm" align="center" onclick="return (confirm('#MsgArray_MULTI_USE[12]#'+go()));">
</cfoutput>


</cfoutput>

</cfform>
</body>

<!---Get_Subject_Insert_IWR.cfm--->

<cflock scope="application" type="readonly" throwontimeout="no" timeout="60">
<cfset dsname = Application.dsname>
<cfset dslogin = Application.dslogin>
<cfset dspassword = Application.dspassword>
<cfset schema = Application.schema>
</cflock>

<cfquery name="Get_Subject_insert" datasource="#dsname#"
username="#dslogin#" password="#dspassword#">
insert into #schema#.transaction_log(SESSION_ID,SCHEMA,TRANSACTION_NAME,USER_ID,SITE_ID,NPARM1,CPARM1)
values(#client.session_id#,'#SCHEMA#','GET_SUBJECT',#client.user_id#,#client.site_id#,#url.subject_id#,'#url.function#')
</cfquery>
<cfquery name="Get_Subject_select" datasource="#dsname#"
username="#dslogin#" password="#dspassword#">
select cparm1,result from current_transaction
where session_id=#client.session_id# and transaction_name='GET_SUBJECT'
</cfquery>





I would like to bring the control back to show_randomize_IWR.cfm to go to a different route show_DOB.cfm
 
Why not pass a variable in the cflocation tag back to show_randomize_IWR.cfm and then run a <cfif> statment to see if the URL (or session) has that varaible. If it does, then load the show_DOB.cfm, if not direct the user to a more custom page. The key is to make sure the user is not sent back to show_randomize_IWR.cfm (the place where they started or else you'll have an infinite loop).

What I mean is something like this:

Code:
NOT TESTED!!

<!--show_randomize_IWR.cfm --->
<!-- In this file some insert and select queries are also there --->

<body>
[COLOR=red]
	<cfif not isdefined("URL.Status")>
		<cfinclude template="show_GetSubject_IWR.cfm">
	</cfif>
	<cfif isdefined("URL.Status") and URL.Status EQ "1">
		<cfinclude template="show_DOB.cfm">
    <cfelse>
    	<cflocation url="error.cfm">
	</cfif>	 
[/color]
</body>

<!---show_Get_subject_IWR.cfm--->
<head>

<script type="text/javascript">
function go() 
{
    return document.getElementById("subject_id").value;
}
</script>
</head>
<body>
<cfform name="get_subject_IWR" action="Get_Subject_Insert_IWR.cfm" method="get" target="show">
	<cfoutput query="subject_select">
    	<option value="#subject_select.subject_id#">#subject_select.subject_id#&nbsp;&nbsp;</cfoutput>
    </select    
     <cfoutput>
<cfoutput>
    <input type=submit SIZE="20" READONLY VALUE="Confirm" align="center" onclick="return (confirm('#MsgArray_MULTI_USE[12]#'+go()));">
</cfoutput>

    
</cfoutput>

</cfform>
</body>

<!---Get_Subject_Insert_IWR.cfm--->
<cflock scope="application" type="readonly" throwontimeout="no" timeout="60">
    <cfset dsname = Application.dsname>
    <cfset dslogin = Application.dslogin>
    <cfset dspassword = Application.dspassword>
    <cfset schema = Application.schema>
</cflock>

<cfquery name="Get_Subject_insert" datasource="#dsname#" username="#dslogin#"  password="#dspassword#">
	insert into #schema#.transaction_log(SESSION_ID,SCHEMA,TRANSACTION_NAME,USER_ID,SITE_ID,NPARM1,CPARM1)
	values(#client.session_id#,'#SCHEMA#','GET_SUBJECT',#client.user_id#,#client.site_id#,#url.subject_id#,'#url.function#')
</cfquery>
<cfquery name="Get_Subject_select" datasource="#dsname#" username="#dslogin#"  password="#dspassword#">
	select cparm1,result from current_transaction
	where session_id=#client.session_id# and transaction_name='GET_SUBJECT'
</cfquery>


[COLOR=red]<cflocation url="show_randomize_IWR.cfm?Status=1">[/color]

____________________________________
Just Imagine.
 
Thank you,

I think this should work out. This is what I needed.

Thanks a lot.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top