Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 644
  • Last Modified:

Closing a CFwindow and reloading calling page using javascript

I have a inquiry page Results_mine.cfm that allows the user to define variables for a query.  I want to save off the variables upon the click of the "Save as New" button that calls the javascript function below.  The javascript function (below) calls a form allows a user to create a name for the inquiry and save off the values.  The call to the Results_Save.cfm?nUserResultID='+vv works perfectly when the form is posted; name and variables get written to the database. However at the end of the post within the Results_Save.cfm? I have the following code which I was hoping would shut the window and refresh the calling window;

<script>
ColdFusion.Window.show('SaveResults');
document.location.replace('ResultsConsole.cfm');
</script>

For some reason the code is ignored....I have tried alerts and it just isn't reading the javascript.

Ideally I really just want to shut the window and then just refresh the a dropdown cfselect on the calling page.  Problem is window is not shutting and the page is not getting refreshed.  

The questrion is why isnt the javascript being interpreted and Is it possible to bind the cfselect to give it the new value. upon insert into the database so I do not have to do a total page refresh?

at the end however within the calling page I have put a

function savenewform() {
	vv = "";
    v1 = document.resultsform.nCircuitID.value ;
    v2 = document.resultsform.nShowID.value ;
    v3 = document.resultsform.nDivisionTypeID.value ;
    v4 = document.resultsform.nClassTypeID.value ;
    v5 = document.resultsform.nHorseID.value ;
    v6 = document.resultsform.nRiderContactID.value;
    v7 = document.resultsform.nTrainerContactID.value ;
    v8 = document.resultsform.nOwnerContactID.value;
    v9 = document.resultsform.nTripRank.value;
    v10 = document.resultsform.nPrizeMoney.value;
    v11 = document.resultsform.nScores.value;
    v12 = document.resultsform.nFaults.value;
    v13 = document.resultsform.nYear.value;
	v14 = document.resultsform.nMonth.value;
    v15 = document.resultsform.nClassID.value;
    v16 = document.resultsform.nVideoFlag.value;
 
 
    ColdFusion.navigate('http://equestriansports.brandwise.com/brandwise/templates/espcustom/classes/Results_Save.cfm?nUserResultID='+vv
						+'&V1='+v1+'&V2='+v2+'&V3='+v3+'&V4='+v4+'&V5='+v5+'&V6='+v6+'&V7='+v7+'&V8='+v8+'&V9='+v9+'&V10='+v10+'&V11='+v11+'&V12='+v12
						+'&V13='+v13+'&V14='+v14+'&V15='+v15+'&V16='+v16
						,
						'SaveResults');
  	ColdFusion.Window.show('SaveResults');
}

Open in new window

0
ESPMJB
Asked:
ESPMJB
  • 3
  • 2
1 Solution
 
azadisaryevCommented:
if i understand you correctly, try this:

add this js function to the HEAD section of your main page (i.e. NOT the page loaded in cfwindow):

onSaveResults = function() {
ColdFusion.Window.show('SaveResults');
document.location.replace('ResultsConsole.cfm');
}

then add this line before the closing </body> tag in the page that IS loaded in cfwindow:
<cfset ajaxonload('onSaveResults')>


on your second issue - refreshing just the drop-down select instead of whole page - read this:
http://cfsilence.com/blog/client/index.cfm/2007/10/22/Refreshing-A-Bound-CFSelect

hth

Azadi
0
 
azadisaryevCommented:
hmm...
ColdFusion.Window.show('SaveResults') should probably instead be ColdFusion.Window.hide('SaveResults'), no? you want to 'close' the window, not show it, right?

Azadi
0
 
ESPMJBAuthor Commented:
Azadi
Once again, thanks for your great help, the first section did work.
On the link you sent me to it refers to the following;

"The getArt() function returns a query to the select which uses the 'value' and 'display' columns as defined in the cfselect tag.

<script>
getArt = function(){
var a = new artClass();
var artists = a.getArtistsForSelect();
return artists;
}
</script>

How does the javascript  "a.getArtistsforSelect()" function call a query? Is getArtistsforSelect the name of a query?
0
 
ESPMJBAuthor Commented:
Azadi
Maybe this is a simpler question that accomplishes the same result.

I want a CFSelect to with an "onchange" call to a javascript function that does the following;
call a query for a selected id within the cfselect.  The query would return a record with three values
ID1, ID2, ID3.  For example

<CFQUERY NAME="GetSearches" DATASOURCE="xyz">
select nID1,ID2,ID3 from searchlist
where searchlistID = 1
</CFQUERY>       

I then want to assign those new values to the current form as follows;  
    document.resultsform.ID1.value = "x";
    document.resultsform.ID2.value = "y";
    document.resultsform.ID3.value = "z";
   
can you easily make the call to the query or a cfc so I can refresh the form without reloading the page?

Any help on this would be greatly appreciated!!!

 
0
 
ESPMJBAuthor Commented:
Thanks again
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now