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

#1 mkatyal  Icon 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"/>	
<html>
	<head>
	    <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:ArtistGrid.lmsId@click}"  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:ArtistGrid.lmsId@click}&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:ArtistGrid.lmsId@click}&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:ArtistGrid.lmsId@click}&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:ArtistGrid.lmsId@click}"  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.reset(); 
				    f1.style.display = 'none';     
				    ColdFusion.Grid.refresh('clients', true); 
				  } 
				  else { 
				  var f1=document.forms.insertClient; 
				    f1.reset(); 
				    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>";  
	        }  
</script> 



 
<script>
	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>
	<script type="text/javascript"> 
		function DetailWindow(lmsId) { 
	      ColdFusion.window.show('cw1'); 
		} 
	</script> 
	<script type="text/javascript"> 
		function OCRWindow(OCR) { 
		var OCR = ColdFusion.getElementValue("ArtistGrid", "f1", "OCR");  
   		 ColdFusion.window.show('cw2'); 
		} 
	</script>
	<script type="text/javascript"> 
		function SMEWindow(SME) { 
		var SME = ColdFusion.getElementValue("ArtistGrid", "f1", "SME");  
   		 ColdFusion.window.show('cw4'); 
		} 
	</script>
	
	<script type="text/javascript"> 
		function ModWindow(lmsId) { 
		var Mod = ColdFusion.getElementValue("ArtistGrid", "f1", "lmsId");  
   		 ColdFusion.window.show('cw5'); 
		} 
	</script>
	<script type="text/javascript"> 
		function OPRWindow(lmsId) { 
		var Mod = ColdFusion.getElementValue("ArtistGrid", "f1", "lmsId");  
   		 ColdFusion.window.show('cw6'); 
		} 
	</script>
	 

		<script>
			    function init(){
			        var grid = ColdFusion.Grid.getGridObject("ArtistGrid");
					var TierName = ColdFusion.Grid.getGridObject('ArtistGrid');
			        grid.addListener("rowclick",onRowClick);

		
			    }
		    function onRowClick(g,rowIndex,e){
			        Ext.Msg.alert("Hello Msg Box","You clicked on row number " + rowIndex);
			    }
				
	    </script>
		<script>
			function init1(){
				
				var grid = ColdFusion.Grid.getGridObject('ArtistGrid')
				grid.on('rowdblclick',DetailWindow);
				//grid.addListener("rowdblclick",onRowClick);
			}
			ColdFusion.Event.registeronload(init1,null, false, true);
		</script>
	<!---add query for the priority select box filter later--->	
		
	    <style>body{padding:50px} </style> 
	</head>
	<body bgcolor="#DDD4A8">
	<h3>Lesson Management Issue Resolution Module</h3>
	<br>
	
		<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" />--->
		<cfgrid 
		    format="html" 
		    name="ArtistGrid" 
		    pagesize="15" 
		    sort="true"
			striperows="yes"
			bgcolor="##8B8B00"
		    colheadertextcolor="##4F4F2F"
			colheaderfontsize="12"
			bold="yes"
			striperowcolor="##CCCC99"
			selectonload="no"
			colHeaderAlign="center"
			highlighthref="true" 
			appendKey = "false" 
			selectmode="single"
						
		    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" />
				  
		</cfgrid>
		<div id="result">  
        </div> 
			<script>
			getSearchString = function(){
			    var s = ColdFusion.getElementValue('searchString');
			    return s; 
			}
			</script>
	<br />  
 		</cfform>
<cfset ajaxonload("init1")>
	     
	</body>
</html>





Here is the cfwindow page with checkboxes displayed.


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

<!--- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX --->
<!---  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  --->
<!--- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX --->

<CFIF ISDEFINED("URL.Id")>
	<CFSET lmsId = #URL.Id#>
<CFELSE>	
	<CFSET lmsId = 00>
</CFIF>	

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

	

<!---  OCR QUERY  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX--->
	<CFQUERY Name="ocrQry" DataSource="#request.dns#">
		SELECT LMIR.lmsId, UIC.TierId, UIC.TierName
			FROM Army.DBO.lmirOCRrelations as LMIR
				LEFT JOIN JLLIS.DBO.Tier AS UIC ON LMIR.TierId=UIC.TierId
			WHERE (LMIR.lmsId = #lmsId#) 
			ORDER BY UIC.TierName
	</CFQUERY>
	<!---<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!")
}

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

				<CFSET OCRlist = #OCRlist# & #ocrQry.TierId# & ","> 
			</CFOUTPUT>
		</CFLOOP>
		<tr>
		
	</table>
	<CFOUTPUT>
<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#">
	<CFELSE>
		<input type="hidden" id="lmirOCRrelationsTxt" name="lmirOCRrelationsTxt" value="-1,">
	</CFIF>	
	</CFOUTPUT>
</CFIF>

<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>

</CFFORM>




Is This A Good Question/Topic? 0
  • +

Replies To: how to submit from cfwindow

#2 Craig328  Icon User is offline

  • I make this look good
  • member icon

Reputation: 1926
  • View blog
  • Posts: 3,471
  • 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:

Quote

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