1 Replies - 2647 Views - Last Post: 19 April 2011 - 06:08 AM Rate Topic: -----

#1 mkatyal   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 30-March 11

how to submit from cfwindow

Posted 19 April 2011 - 03:46 AM

I am using a cfgrid that had a add link that opens a cfwindow that displays some checkboxes. I have a button that calls a JS function that is supposed to insert or update the database. I cannot seem to pass the Id and the checkbox value for submit. It comes up with # signs. Basically how do i pass those values.

Here is the code with the grid and also the submit code(JS):
<cfsetting showdebugoutput="true">
<cfajaximport tags="cfwindow ,CFFORM, CFDIV"/>	
	    <title>Lesson Management Issue Resolution Module</title>
<CFINCLUDE Template="lmirDashBoard.cfm">

	<cfwindow  name="cw1"  refreshonshow="true"   modal="true" center="true" title="Lesson Types" initshow="false" width="350" height="200" 
 source="lmir.cfm?TierName=' Tiername &id={f1:[email protected]}"  bodystyle="background-color:rosybrown;"  headerstyle="background-color:DarkGrey;  font-size:medium; font-style:italic; font-weight:bold; color:black"/>
 	<cfwindow  name="cw2" refreshonshow="true"  modal="true" center="true" title="OCR(s)" initshow="false" width="400" height="200" 
 source="lmirOCRshow.cfm?id={f1:[email protected]}&OCR={f1:ArtistGrid.OCR}" bodystyle="background-color:rosybrown;"  headerstyle="background-color:DarkGrey; font-size:medium; font-style:italic; font-weight:bold; color:black"/>
 	<cfwindow  name="cw4" refreshonshow="true"  modal="true" center="true" title="Subject Matter Experts (SMEs)" initshow="false" width="750" height="200" 
 source="lmirSMEshow.cfm?id={f1:[email protected]}&OCR={f1:ArtistGrid.SME}" bodystyle="background-color:rosybrown;"  headerstyle="background-color:DarkGrey; font-size:medium; font-style:italic; font-weight:bold; color:black"/>

	<cfwindow  name="cw5" refreshonshow="true"  modal="true" center="true" title="Last Modified By" initshow="false" width="625" height="200" 
 source="lmirLastModInfo.cfm?id={f1:[email protected]}&lmsId={f1:ArtistGrid.lmsId}" bodystyle="background-color:rosybrown;"  headerstyle="background-color:DarkGrey; font-size:medium; font-style:italic; font-weight:bold; color:black"/>
 <cfwindow  name="cw6"  refreshonshow="true"   modal="true" center="true" title="Lesson Managers" initshow="false" width="350" height="200" 
 source="lmirOPRshow.cfm?TierName=' Tiername &id={f1:[email protected]}"  bodystyle="background-color:rosybrown;"  headerstyle="background-color:DarkGrey;  font-size:medium; font-style:italic; font-weight:bold; color:black"/>

	<script type="text/javascript">  
	       // function updateErrorHandler(id,message) {   
	       // }  
	        function doInsertClient() {  
	          arguments are form name, cfc and method to send form values to, javascript function to handle result,  
	           javascript function to handle error  */ 
	          ColdFusion.Ajax.submitForm('insertClient', 'lmirOCRdbUpdate.cfm?id=lmsId&OCR=#TierId#' , insertErrorHandler);  
			   var resultInsertHandler = function(res){ 
				var r = eval( "(" + res + ")" ); 
				var resultDiv = document.getElementById("result"); 
				var msgcolor = (r.SUCCESS) ? 'green' : 'red'; 
				resultDiv.innerHTML = "<p style=\"color:"+msgcolor+"\">"+r.MESSAGE+"</p>"; 
				 if (r.SUCCESS) { 
				    //rest and hide the form 
				    var aForm=document.forms.insertClient; 
				    f1.style.display = 'none';     
				    ColdFusion.Grid.refresh('clients', true); 
				  else { 
				  var f1=document.forms.insertClient; 
				    f1.style.display = 'none';  
        function insertErrorHandler(id, message) {  
	           alert("Error while updating\n Error code: "+id+"\n Message: "+message);  
	                var resultDiv = document.getElementById("result");  
	                resultDiv.innerHTML = "<p>OCR not inserted or updatedin database.</p>";  

	function clickHandler(ArtistGrid){
	 var row = Artistgrid.getSelectMode().getSelected();
	 var name = row.get('lmsId');
	 var title = row.get('Topic');
	 var url = "lmir.cfm?lmsId=" + name;
	<script type="text/javascript"> 
		function DetailWindow(lmsId) { 
	<script type="text/javascript"> 
		function OCRWindow(OCR) { 
		var OCR = ColdFusion.getElementValue("ArtistGrid", "f1", "OCR");  
	<script type="text/javascript"> 
		function SMEWindow(SME) { 
		var SME = ColdFusion.getElementValue("ArtistGrid", "f1", "SME");  
	<script type="text/javascript"> 
		function ModWindow(lmsId) { 
		var Mod = ColdFusion.getElementValue("ArtistGrid", "f1", "lmsId");  
	<script type="text/javascript"> 
		function OPRWindow(lmsId) { 
		var Mod = ColdFusion.getElementValue("ArtistGrid", "f1", "lmsId");  

			    function init(){
			        var grid = ColdFusion.Grid.getGridObject("ArtistGrid");
					var TierName = ColdFusion.Grid.getGridObject('ArtistGrid');

		    function onRowClick(g,rowIndex,e){
			        Ext.Msg.alert("Hello Msg Box","You clicked on row number " + rowIndex);
			function init1(){
				var grid = ColdFusion.Grid.getGridObject('ArtistGrid')
			ColdFusion.Event.registeronload(init1,null, false, true);
	<!---add query for the priority select box filter later--->	
	    <style>body{padding:50px} </style> 
	<body bgcolor="#DDD4A8">
	<h3>Lesson Management Issue Resolution Module</h3>
		<cfform name="f1">
		<cfinput name="searchString" />
		<cfinput type="button" name="searchBtn" value="Search" onclick="ColdFusion.Grid.refresh('ArtistGrid', false);" />
		<!---<cfselect name="Classification" query="getpriiority" value="Classification" display="Classification" />--->
			appendKey = "false" 
		    bind="cfc:lmir.getArt({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection}, getSearchString())">
			<cfgridcolumn name="Classification" header="Class" width="5" display="true" />
			<cfgridcolumn name="Abbrev" header="Type" width="50"  href="javascript:DetailWindow();" hrefkey="lmsId"/>
			<cfgridcolumn name="lmsId" header="Id" width="25" />
		    <cfgridcolumn name="topic" header="Topic" width="300" hrefkey="lmsId" />
			<cfgridcolumn name="documentDate" header="Doc.Date" width="75" />
			<cfgridcolumn name="TierName"  header="OPR" width="100" href="javascript:OPRWindow();" hrefkey="lmsId" />
			<cfgridcolumn name="OCR" header="OCR" width="50" href="javascript:OCRWindow();" hrefkey="OCR" />
			<cfgridcolumn name="SME" header="SME" width="50" href="javascript:SMEWindow();" hrefkey="SME"/>
			<cfgridcolumn name="LastModifiedDate" header="Last Modified" width="100" href="javascript:ModWindow();" hrefkey="lmsId" />
			<cfgridcolumn name="StatusText" header="Status" width="50" />
			<cfgridcolumn name="DueDate" header="Due Date" width="50" />
			<cfgridcolumn name="" header="&nbsp;" width="150" />
		<div id="result">  
			getSearchString = function(){
			    var s = ColdFusion.getElementValue('searchString');
			    return s; 
	<br />  
<cfset ajaxonload("init1")>

Here is the cfwindow page with checkboxes displayed.

<cfcache timespan="#CreateTimespan(0, 0, 0,1)#" >
<cfcache action="flush" >

<!---  C O L D F U S I O N   I N I T I A L I Z A T I O N   A N D   D A T A B A S E   C A L L S  --->

	<CFSET lmsId = #URL.Id#>
	<CFSET lmsId = 00>

<CFSET OCRlist = "-1,">
<cfparam name="OCR"  default="" type="string" >
<cfparam name="cfgridkey"  default="" type="string" >
	<!---<CFDUMP var="#Variables#"><bt></bt>--->
	<!--- cfgridkey =  #cfgridkey# 
	id is : #url.id#<br>--->
	OCR : #OCR#
	id   :#lmsId#
	<!---<CFDUMP var="#Request#">--->


	<CFQUERY Name="ocrQry" DataSource="#request.dns#">
		SELECT LMIR.lmsId, UIC.TierId, UIC.TierName
			FROM Army.DBO.lmirOCRrelations as LMIR
			WHERE (LMIR.lmsId = #lmsId#) 
			ORDER BY UIC.TierName
	<!---<cfdump var="#ocrQry#">--->
 <script language="Javascript">
function alertValues(insertClient)
    var cbs = insertClient["lmirOCRrelationsTxt"];
    var vals = ""
for (i=0; i<document.insertClient.lmirOCRrelationsTxt.length; i++){
if (document.insertClient.lmirOCRrelationsTxt[i].checked==true)
alert("Checkbox at index "+i+" is checked!")

<CFFORM name="insertClient">
<CFIF (ocrQry.RecordCount EQ 00)>
	<font color="#000000">No Office(s) of Coordinating Responsibility found...</font>
	<cfinclude template="lmirOCRupdate.cfm">
	<table border="1" style="width:425px;" style="background-color:#FFFFFF; border-color:#000000;" >
			<td class="lmirOCRupdate">Office(s) of Coordinating Responsibility</td>
		<CFLOOP Query="ocrQry">
					<td class="lmirOCRupdate">

				<CFSET OCRlist = #OCRlist# & #ocrQry.TierId# & ","> 
<tr><td align='center'><a href="javascript:ColdFusion.window.hide('cw2');"><font size="-4">Close</font></a></td></tr>

	<CFIF (#LEN(TRIM(OCRlist))# GT 1)>	
		<input type="hidden" id="lmirOCRrelationsTxt" name="lmirOCRrelationsTxt" value="#OCRlist#">
		<input type="hidden" id="lmirOCRrelationsTxt" name="lmirOCRrelationsTxt" value="-1,">

<tr><td><cfinput type="button" name="addClient" value="Add Client" onclick="doInsertClient();"></td></tr>	
<tr><td><cfinput type="button" name="show Alert" onclick="javascript:alertValues(this.insertClient);"></td></tr>


Is This A Good Question/Topic? 0
  • +

Replies To: how to submit from cfwindow

#2 Craig328   User is offline

  • I make this look good
  • member icon

Reputation: 2042
  • View blog
  • Posts: 3,644
  • Joined: 13-January 08

Re: how to submit from cfwindow

Posted 19 April 2011 - 06:08 AM

Okay...couple of things here. The last time you posted three weeks back, it was about this same issue. Back then I had said this:


Tell you what, come back with some examples of your code (and please, make sure it's code you've actually written so you understand what it's doing) and what you've tried to resolve your issues and we'll be glad to help out.

I've emphasized and underlined that part above because by now it's pretty clear that the code you're working on isn't your own. What you're dealing with there is a fairly involved presentation layer using cfwindow modals and Ajax to do the heavy lifting. You would need to know how to go about debugging Ajax in CF for you to get anywhere.

I appreciate that you've visited this time to post nearly 300 lines of code but you've mentioned nothing about your efforts (and results) to resolve this issue. I get the impression that you're probably in way over your head here and perhaps should consider hiring a CF dev with more experience or maybe contact the dev(s) who wrote this originally and ask for their assistance. This forum can help with single issues where you post some code but what you've done here is post practically every line of two pages which tells me you're not even sure where the offending code is...which in turn tells me you either haven't bothered to narrow down the issue through trying to figure it out yourself or you don't know how to.

There's nothing wrong with being a CF beginner but given that you've asked virtually identical questions 3 weeks apart and in this case vomited up the entirety of 2 code pages hints at something else involved here. Do you even own this code? Clearly you didn't write it as it's rather complicated and the actual author wouldn't need to ask "I cannot seem to pass the Id and the checkbox value for submit". That's a pretty rudimentary question to be asking for such an advanced piece of code. Nobody here can reproduce what you've done or even begin to suggest debugging efforts because the crucial backend Ajax piece is missing...and that's something I'm not sure you can even identify.

Do us all a favor: tell us a little about your situation and how it is you came to be involved with this code project and how much actual experience as a CF dev you have. We're here to help if we can but that help doesn't include helping a CF novice tackle projects where a CF expert is clearly needed.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1