How can I use a cfwindow with a form in it to update the main page?

This seems simple enough but I can't figure it out. My main
page calls a query to get a list of departments. I have put this
list in a table inside a cfdiv tag. I have an add department link
on my page. When the user clicks on this link, I want a popup
window (cfwindow) to display containing a form to add a department.
Then when the user submits the form, the form should disappear and
the main page should show the updated list of departments.
I can't get the form to close without getting an error
stating that there already is a window with that name and the new
data doesn't display unless I refresh my screen.
Here's my departments.cfm page:
<html>
<head>
</head>
<cfinvoke component="department"
method="list"
returnvariable="departments">
</cfinvoke>
<body>
<cfwindow name="deptWindow" title="Department Window"
draggable="true" resizable="false"
initshow="false" height="400" width="600" x=200 y=100>
<cfform action="processDepartment.cfm"
onsubmit="ColdFusion.Window.hide('deptWindow')">
Department:
<cfinput type="text" name="deptname">
<cfinput type="submit" name="submit">
</cfform>
</cfwindow>
<a href="#"
onClick="ColdFusion.Window.show('deptWindow')">Add
Department</a>
<cfdiv>
<table>
<tr>
<th>Department</th>
<th>Action</th>
</tr>
<cfoutput query="departments">
<tr>
<td>#deptname#</td>
<td><a href="##"
onClick="ColdFusion.Window.show('deptWindow')">Edit</a></td>
</tr>
</cfoutput>
</table>
</cfdiv>
</body>
</html>
Here's my department.cfc page:
<cfcomponent output="false">
<cfset THIS.dsn="cf8test">
<cffunction name="list" access="remote" output="false"
returntype="Query">
<cfquery name="departments" datasource="#THIS.dsn#">
SELECT department_id, deptname
FROM departments
ORDER by deptname
</cfquery>
<cfreturn departments />
</cffunction>
<cffunction name="add" access="public" output="false"
returntype="Boolean">
<cfargument name="deptname" required="true"
type="string">
<cfquery datasource="#THIS.dsn#">
INSERT INTO departments(deptname)
VALUES (<cfqueryparam value="#Trim(ARGUMENTS.deptname)#"
cfsqltype="cf_sql_varchar">)
</cfquery>
<cfreturn true />
</cffunction>
</cfcomponent>
And finally, here's my processDepartment.cfm page:
<!--- Form Field Validation --->
<cfparam name="FORM.deptname" type="string">
<cfif IsDefined("FORM.id")>
<cfset method="update">
<cfelse>
<cfset method="add">
</cfif>
<cfinvoke component="department"
method="#method#">
<cfif IsDefined("FORM.id")>
<cfinvokeargument name="id"
value="#FORM.id#">
</cfif>
<cfinvokeargument name="deptname"
value="#Trim(FORM.deptname)#">
</cfinvoke>
<!--- When done go back to the Departments listing --->
<cflocation url="/departments.cfm">

Hi Jeff,
One way to do it is to write a JavaScript function that binds
to your CFC. The CFC should both insert the user values, and then
select all of the departments from the department table, and then
return the query set to the page. I wrote sort of a test page which
gets the state from the States table according to the state
abbreviation that the user types in from a CFWindow. The table
never gets updated, however, the result comes back from the CFC
through AJAX, then updates the main page. You can use this same
idea but you'll have to update your CFC a little bit. However, the
idea is the same.
Here's the code for my get State application. Especially
notice the following three lines of code in the JavaScript function
called getStates:
var d = new getStates2(); //this is the name of your CFC
d.setForm('form1'); //not sure if you need this, but I found
it somewhere
var stateName = d.getAllStates(); //the name of the function
inside your CFC
Anyway here's the code in full:
<style>
.stateClass {
font-family: arial;
font-weight: bold;
font-size: 12pt;
padding-top: 10px;
</style>
<cfajaxproxy cfc="getStates2">
<script language="javascript">
function enter_pressed(e){
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return false;
return (keycode == 13);
function getStates()
if(document.form1.theState.value == '') {
alert('Please make sure the textbox is not empty.');
return false;
var d = new getStates2();
d.setForm('form1');
var stateName = d.getAllStates();
ColdFusion.Window.hide('stateWin');
if (stateName == '')
document.getElementById('stateDiv').innerHTML = 'No such
state';
else
document.getElementById('stateDiv').innerHTML = 'The state
is ' + stateName;
</script>
<cfwindow name="stateWin" x="100" y="100" width="400"
height="200">
<form name="form1" method="post" onsubmit="return
false;">
<input name="theState" type="text" size="5"
onKeyPress="if(enter_pressed(event)){ getStates() }"
/>
<input type="button" value="get state"
onClick="getStates()">
</form>
</cfwindow>
<div id="stateDiv" class="stateClass">
</div>
<a
href="javascript:ColdFusion.Window.show('stateWin')">find a
state</a>

Similar Messages

  • How can i use Oracle intermedia with Oracle forms 9i

    Hi all,
    I have a requirment from one of our client that they want to manage a large amount of Images,by seeing the documents about the oracle interMedia we got some idea to manage this images ,but the client is alredy having a software which is been developed by Oracle forms9i and we need to develope this using oracle forms9i can anyone give us an idea that how can we make use of InterMedia through Oracle forms9i ....
    Thanks in advance....

    I am also trying to use interMedia objects with Oracle 9i forms. I've tried everything and I can't get it to work.
    So far I have a solution that loads images using WebUtil into a blob field in Forms 9i, then in a backend stored procedure I move the blob to an interMedia object. Which works, but the problem with the image item in Oracle forms is that the image format cannot be change at runtime, so the images will always be what you set at design time.
    Can someone out there please help.
    Thanks.
    Ray

  • How can i use Oracle interMedia with Oracle forms  Urgent

    Hi all,
    I have a requirment from one of our client that they want to manage a large amount of Images,by seeing the documents about the oracle interMedia we got some idea to manage this images ,but the client is alredy having a software which is been developed by Oracle forms9i and we need to develope this using oracle forms9i can anyone give us an idea that how can we make use of InterMedia through Oracle forms9i ....
    Thanks in advance....

    I will ask, but it would be good to ask in the Oracle Forms forum as well. Many tools recognize the interMedia columns and automatically handle them since they now can say "Oh, this is an image column, I know how to handle this". I am not sure where forms is in this regard.

  • How can I use an iPad with two itunes accounts?

    How can I use an iPad with two itunes accounts?
    Hi there
    My partner has a works iPad, which has her works Apps on (ones that are specifically made by her company and are NOT available in the App store).
    What I want to be able to do is to ALSO have my itunes account on there so that I can put all the apps I have purchased previously from my iPhone on it.
    This is so I can put on VLC player (thats already in my itunes account) so I can add videos to the iPad.
    How do I do this please?
    I tried it before by connecting it to my mac, but it wiped everything off the iPad completely and also deleted the data settings for using 3G.
    So I want to avoid this happening again the future as it had to be sent back to her head office to be sorted again.
    Any advise please?
    Thanks

    You can't. The iPad is desgined to be a 'one user' device and only really works with one apple ID at a time.
    The only way would be if she, at work and with her work apple id, downloaded your apps (repurchasing them of course).
    It's not meant to be a multiple user/multiple ID device.

  • How can i use text expander with the new Mavericks,

    how can i use text expander with the new Mavericks,

    I regret upgrading to mavericks for the same reason
    ftamez wrote:
    how can i use text expander with the new Mavericks,
    Now I have been searching - and you have to buy an app and it will cost you $34.99 (what a rip off)

  • How can i use "icloud backup" with ios 4.2.1?

    How can i use "icloud backup" with ios 4.2.1? I tried to update my ihpone 3G wih the newest IOs. Seems not to be possible.

    You cannot.
    It requires ios 5.
    Your iphone can only go to 4.2.1

  • How can i use MS word with MAVERICK

    how can i use MS word with MAVERICK?  None of the MS Office applications work with new IOS!!!

    What version of Microsoft Office Mac are you running?  You probably just need to update it to the latest release:
    http://www.microsoft.com/mac/downloads?pid=Mactopia_Office2011
    Office 2011 Mac's latest version is 14.3.8 for instance.

  • How can one use Mission Control with two monitors?  Please bring Spaces back

    How can one use Mission Control with two monitors.  With Spaces I could treat each space as a single desktop.
    SyBB

    I use two monitors at work and have no issue. I have my mail set to use Desktop 1 and iTunes set to the second monitor of Desktop 1. I have browsers set to Desktop 2 and Fusion and RDC set to Desktop 3.
    Two things that may help you. In System Preferences > Mission Control, disable the setting "Automatically rearrange spaces...". This screwed with assigning applications to certain spaces. And the other thing is don't use full screen on apps that support it. This just makes your second monitor superfluous.

  • How can I use Local SPAN with RSPAN ??

    How can I use Local SPAN with RSPAN ??
    I want to mirror traffics from ISP-A and ISP-B to Anomaly-detector module.
    so I had configured like this...
    C6500-A
    vlan 1000
    name RSPAN
    remote-span
    monitor session 10 source interface Gi5/1 - 2 rx
    monitor session 10 destination remote vlan 1000
    monitor session 20 destination anomaly-detector-module 3 data-port 1
    monitor session 20 source remote vlan 1000
    interface GigabitEthernet1/13
    switchport
    switchport trunk encapsulation dot1q
    switchport trunk allowed vlan 1000
    switchport mode trunk
    no ip address
    C6500-B
    vlan 1000
    name RSPAN
    remote-span
    monitor session 10 source interface Gi5/1 - 2 rx
    monitor session 10 destination remote vlan 1000
    interface GigabitEthernet1/13
    switchport
    switchport trunk encapsulation dot1q
    switchport trunk allowed vlan 1000
    switchport mode trunk
    no ip address
    end
    but it was not working..
    it wasn't any change of input packet hit count when
    I'd enter a command 'show anomaly-detector module 3 data-port 1 traffic'
    was upper configuration wrong..?
    Can I use VACL configuration ?

    try to change "monitor session 10 destination remote vlan 1000 " to "monitor session 10 destination anomaly-detector-module 3 data-port 1 " on C6500-A

  • How can i use jpg extension with forms 10g and webutil

    I have a form with webutil and i want to open imege jpg extension but thier are Bmp but my
    image jpg and image item has no jpg extension .
    How can i use jpg extension with forms 10g and webutil ?

    You can use the JFIF image format for jpg files.

  • How can i use 3D Features with 256 VRAM

    How can i use 3D Features with 256 VRAM

    Well, in theory you *could* install Photoshop CS6 version 13.0 and not update it.
    Is your video card replaceable?  They don't cost that much.
    -Noel

  • How Can i use Html frames with  simple JSP???

    How Can i use Html frames with simple JSP???
    Actually i am creating an application in which i have used Index.html as frame.
    Noew i am trying that if i click on a link of one frame(say menu frame) the \result shoul come to some other frame(say frame named mainwindow).
    Hoe can i do like this???
    Anand Pritam

    Well i am using..
    < Base target="mainwindow">
    But it is no working is there some other way??

  • How can i use iTunes 10 with my ipad that has ios7

    how can i use iTunes 10 with my ipad that has ios7

    jpbblues wrote:
    how can i use iTunes 10 with my ipad that has ios7
    You cannot. You need iTunes version 11 for iOS 7.
    iTunes free download from www.itunes.com/download

  • How can i use my iphone with more than one itunes

    how can i use my iphone with more than one itunes

    Sync iPod/iPad/iPhone with two computers
    Although it isn't possible to sync an Apple device with two different libraries it is possible to sync with the same logical library from multiple computers. Each library has an internal ID and when iTunes connects to your iPod/iPad/iPhone it compares the local ID with the one the device normally syncs with. If they are the same you can go ahead and sync...
    I have my library cloned to a small 1Tb USB drive which I can take between home & work. At either location I use SyncToy 2.1 to update the local copy with the external drive. Mac users should be able to find similar tools. I can open either of the local libraries or the one on the external drive and update the media content of my iPhone. The slight exception is Photos which normally connects to a specific folder on a specific machine, although that can easily be remapped to the current library if you create a "Photos" folder inside the iTunes Media folder so that syncing the iTunes folders keeps this up to date as well. I periodically sweep my library for new files & orphans with iTunes Folder Watch just in case I make changes at one location but then overwrite the library with a newer copy from the other. Again Mac users should be able to find similar tools.
    As long as your media is organised within an iTunes Music or Tunes Media folder, in turn held inside the main iTunes folder that has your library files (whether or not you let iTunes keep the media folder organised) each library can access items at the same relative path from the library folder so the library can be at different drives/paths on different machines. This solution ensures I always have adequate backups of my library and I can update my devices whenever I can connect to the same build of iTunes.
    When working with an iPhone earlier builds of iTunes would remove any file not physically present in the local library, even if there was an entry for it, making manual management practically redundant on the iPhone. This behaviour has been changed but it will still only permit manual management with a library that has the correct internal ID. If you don't want to sync your library between machines on a regular basis just copy the iTunes Library.itl file from the current "home" machine to any other you want to use, then clean out the library entries and import the local content you have on that box.
    tt2

  • How can I use Pegasus R6 with Mac mini?

    I bought Pegasus R6 (Promise Technology, Inc). I connected to my Mac mini. But Pegasus R6 did not appear on desktop. In order to use Pegasus, MacBook Pro?iMac must have MacBook Pro EFI Firmware Update installed. But Mac mini does not have EFI Firmware Update. How can I use Pegasus R6 with Mac mini?

    Does your Mac Mini have thunderbolt?

Maybe you are looking for

  • Can i install mountain lion on my macbook 2006, 2ghz intel core 2 duo, 2gb ram?

    hi , is it possible to install mountain lion on my macbook from 2006, 2ghz intel core 2 duo and 2 gb ram in the moment i use 10.6.8 and i want to update for installing iwork09, wich requiered 10.7 or more. i need the new iwork, cause my old pages and

  • Using HTTPService to import data from a XML file

    Hello there! I'm having some problem's with this import... If anyone can help, I would appreciate it! I'm using this type of information as data source: public var dataCollection:ArrayCollection = new ArrayCollection([ { id: "P1", name: "Porto", type

  • HT1338 how do you copy all deleted emails to external hard drive

    i am running out of space on my macbook pro...  what is the easiest way to put them on a external drive?

  • PE6-Photos missing from slideshow!!!

    I am just about done with my 25 minute slideshow, and what do you know, I open the slideshow in pe6, and many of my pictures are not there!!!  It is just some pictures and videos and the rest just have the color background!!!  What happened and is th

  • TCP/IP error 63

    Hello everyone, I have attached two vi's that communicate between my HMI and FP module using TCP/IP. Is there any reason why my connection would not re-establish after being broken e.g loss of power to the PC or even pulling the the network cable out