Is there a way to display a form as a pop-up window, with input fields and a submit button, and then retrieve the user's selection from the session? The challenge lies in integrating JS code for the pop-up window with CF server-side code, leading to the session variable being output before it is updated. Here is the scenario along with some relevant snippets of code:
Scenario:
1. User initiates ShowForm(..)
2. ShowForm(..) opens a pop-up window for the user to make a selection
3. User's result is stored in the session
4. Function returns the submitted result
form.cfc
<cffunction name="ShowForm" access="public" output="true" returntype="string">
<script>
window.showModalDialog('formpage.cfm',null,"dialogHeight=400px,dialogLeft=150px");
</script>
<cfreturn session.form_result> <!--- @toFix: Return happens before setting form_result --->
</cffunction>
formpage.cfm
<cfajaxproxy cfc="components.sess_mgr" jsclassname="JSMaskProxy">
<script>
function submitSelection(formObj)
{
for (i=0; i<intSelValue.length; i++)
result.push(intSelValue[i]);
var instCfProxy = new JSMaskProxy();
instCfProxy.setToSession(result); // updates session.form_result
//window.returnValue=result;
window.close();
}
</script>
<form name="frmDtls">
<td align="center"><input type="button" id="selectButton" name="selectButton" onClick="submitSelection(details);">
</form>
How can this problem be solved?
ColdFusion.navigate(..) function allows for a callback function and an error handler, but currently only supports client-side functions. If the callback function could also be a CF or server-side page, it might resolve this issue of dependencies.
Additionally, it would be ideal to retrieve the value from window.showModalDialog instead of the session, but the main focus here is on addressing the JS-CF integration challenge.