Solved

Closing a CFwindow and reloading calling page using javascript

Posted on 2009-07-15
5
608 Views
Last Modified: 2013-12-24
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
Comment
Question by:ESPMJB
  • 3
  • 2
5 Comments
 
LVL 27

Accepted Solution

by:
azadisaryev earned 500 total points
ID: 24867061
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
 
LVL 27

Expert Comment

by:azadisaryev
ID: 24867069
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
 

Author Comment

by:ESPMJB
ID: 24867418
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
 

Author Comment

by:ESPMJB
ID: 24867589
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
 

Author Closing Comment

by:ESPMJB
ID: 31603819
Thanks again
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now