Here are some snippets of code. I actually use a handy custom tag so
most of this doesn't have to be re-written every time I want to
dynamically change a drop down. It is pretty flexible, but I am sure
you can take from it what you want/need when you see what it is doing.
There are several ways to skin this cat.
Let me know if this all makes any sense. :-)
After your popup saves to the database, you would run something like
this from the popup:
<script language="JavaScript1.1">
opener.window.reload_dropdown();
window.close();
</script>
The main page with the form would have something like this:
<iframe frameborder="0" width="0" height="0" name="iframe_reloader" id="
iframe_reloader " src="about:blank" scrolling="Yes"></iframe>
<script language="javaScript">
function reload_dropdown()
{
document.iframe_reloader.location.href = 'reloader.cfm';
}
</script>
In your reloader.cfm file (any of the options can be passed in to
control how this works dynamically.):
Run a query to get the new list of companies...
<cfparam name="url.formname" default=" name_of_your_form ">
<cfparam name="url.formfield" default=" company_dropdown_field ">
<cfparam name="url.valuefield" default=" query_column_for_option_value
">
<cfparam name="url.displayfield" default=" query_column_for_option_text
">
<cfparam name="url.selectedindex" default="">
<cfparam name="url.suppress_first_blank_option" default="false">
<script language="JavaScript1.1">
<cfset selectedindexset = 0>
var mForm = parent.document.#url.formname#;
var i;
//alert(#url.selectedindex#);
<cfif locRecordCount gt 0>
<cfset locIndex = 0>
<cfif not url.suppress_first_blank_option>
<cfset locRecordCount = locRecordCount + 1>
mForm.#url.formfield#.options.length =
#locRecordCount#;
mForm.#url.formfield#.options[#locIndex#].text = '';
mForm.#url.formfield#.options[#locIndex#].value = '';
<cfset locIndex = locIndex + 1>
<cfelse>
mForm.#url.formfield#.options.length =
#locRecordCount#;
</cfif>
<cfloop query="query_name">
mForm.#url.formfield#.options[#locIndex#].text =
'#jsstringformat(evaluate(url.displayfield))#';
mForm.#url.formfield#.options[#locIndex#].value =
'#jsstringformat(evaluate(url.valuefield))#';
//alert('#url.selectedindex# \n
#evaluate(url.valuefield)#');
<cfif url.selectedindex EQ evaluate(url.valuefield) OR
url.selectedindex EQ evaluate(url.displayfield)>
<cfset selectedindexset = 1>
mForm.#url.formfield#.selectedIndex =
#locIndex#;
//alert(#locIndex#);
<!--- If there is only one record on the
preload, automatically select that option by default --->
<cfelseif locRecordCount EQ 2>
<cfset selectedindexset = 1>
mForm.#url.formfield#.selectedIndex =
#locIndex#;
</cfif>
<cfset locIndex = locIndex +1>
</cfloop>
<cfelse>
mForm.#url.formfield#.length = 1;
mForm.#url.formfield#.options[0].text = '';
mForm.#url.formfield#.options[0].value = '';
</cfif>
<cfif selectedindexset EQ 0>
mForm.#url.formfield#.selectedIndex = -1;
</cfif>
</script>
-----Original Message-----
From: Pete Ruckelshaus [mailto:[EMAIL PROTECTED]
Sent: Tuesday, January 10, 2006 2:45 PM
To: CF-Talk
Subject: Re: Retaining form data after navigating away?
This sounds like the ideal approach. Do you have any code samples?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:229096
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54