Here is the situation. I have a parent window that has red and a yellow radio buttons default to yellow. When I select the red one, a popup window is displayed. I then must check atleast one of the three checkboxes. When the checkbox is checked, text is dynamically populated into a text field to be edited. When the user is done on this page, the data needs to be submitted back to the parent page as a hidden field to be passed to an action page. I am using Cold Fusion and need to use JS here to figure out how to pass the variables from the child to the parent page. I can get the box to display and can click on the check boxes and the text populates the fields, but I cannot seem to get the data to pass from the child to the parent. Could somone please help me!!
DAN
I figured the it should go into the popup page. I have an event item for closing the window but that may not be what I need.
also what is needed on the parent page. I have in input field that is has a hidden attribute. Really simple questions so I hope you understand that I know very little about JS and may as some very trivial questions.
thanks for the help
DAN
Ken Tholke
06-26-2001, 09:39 PM
A submit button is used for submitting a form to a server or to jump to a new location.
Try it this way by first adding the function inside the script tags in your pop up's head.
function passField(){
parent.opener.document.myHiddenField.value=document.forms[0].900COLORTEXT.value;
}
then change the button to type="button" and fire the event:
onClick=passField();setTimeout("close()",1000)
You don't really have to set a timeout for the window to close, but if the value being passed is quite lengthy, you don't want it getting cut off in mid stream. I have not done very much with cold fusion (in fact, I haven't done anything with cold fusion come to think of it) :) so there's no guarantee this will work, but it would work for any standard html form within a pop up.
dfred
06-26-2001, 09:57 PM
Did not do anything...infact when I hit the Button, it does not close the popup and does not pass values. This seems a lot trickier than I thought.
Any other thoughts?
If not, thanks for the ideas.
DAN
Jesuisiosono
06-26-2001, 10:13 PM
Hi,
I'm a little confused. Why "parent"? Are you using frames? If you have a simple popUp from an existing window, you should be starting the DOM with "opener"
Also, if you are using a "hiddenField", you need to specify the form's name.
function passField(){
opener.document.formName.myHiddenField.value=document.forms[0].900COLORTEXT.value;
}
if it is simply a variable, this should suffice:
function passField(){
opener.myVar.value=document.forms[0].900COLORTEXT.value;
}
Then again...I may just be confused :)
Ken Tholke
06-26-2001, 10:30 PM
I think it stems back from when I was a child and the gypsies kidnapped me and made me do terrible things :rolleyes:
Actually it is a case of very leanient browsers that have permitted me to get away with it. Thank you for setting me straight. At least I found where I stuck my JS Bible, so I guess a second thank you is in order as well. The missing form name was just sloppiness on my part, a thousand apologies dfred. Jesuisiosono's answer is what I meant.
cannot seem to pass the values or close the window. I think I am very close but cannot get over the hump.
Thanks
DAN
dfred
06-27-2001, 08:23 PM
I am very close to getting this right. The problem is that this popup window or the radio buttons that control the popup window are running through a loop to display them muptiple times depending on the number of items selected. This causes nothing to happen. I need to find a way to loop through the values that are on the popup page so when they are submitted to the parent page, they are seoperated thus the finishing touchees.
Thanks
Dan
dfred
06-28-2001, 02:53 PM
Still looking for a little more help.
I am very close to getting this to work correctly. The problem now is that this popup window or the radio buttons that control the popup window are running through a loop to display them muptiple times depending on the number of items displayed on the parent screen. So the popup window can be used for more than one item on the page. the problem seems to be that the page sees the entries from the popup page as having the same field names so if the popup page is used for more than one item on the page, then the text field entries are not comma delimited or there is only one entry. I need something that realizes that each time the popup window is opened, a new item is related to the popup box.
Please help me!!!!!
Vincent Puglia
06-28-2001, 03:11 PM
Hi Dan,
could you post your latest code or a url, so I can see what you've got? Thanks
Vinny
dfred
06-28-2001, 04:06 PM
the following JS code is on the popup page. I left off the Cold Fusion code which
will be displayed in the popup page and needs to be passed to the other page.
This code is check boxes and text boxes that are autopopulated depending on
which checkbox is checked.
<SCRIPT LANGUAGE="JavaScript">
<!--
<cfoutput>
var ID = 0
function NewWindow1()
{
msgWindow=window.open("red_reason_popup.cfm?ID=1","displayWindow","toolbar=no,width=450,height=280,directories=no,status=no,scrollbars=no,resize=no,menubar=no")
}
</cfoutput>
I left out a lot of the code on the parent page but wanted to show the JS code,
the loop, and the radio buttons that activate the JS code. I am using Cold Fusion
and using some JS. Hope this is not to confussing.
Thanks
dfred
06-28-2001, 07:36 PM
Here is my popup page Cold Fusion and JS:
<cfquery name = "gen_red_reas_900_qn"
datasource="#session.dbase#" username="#session.uname#" password="#session.pword#">
select
gen_red_text RedText900
from gen_red_reasons
where red_reason_code = '900'
</cfquery>
<cfquery name = "gen_red_reas_oth_qn"
datasource="#session.dbase#" username="#session.uname#" password="#session.pword#">
select
gen_red_text RedTextOTH
from gen_red_reasons
where upper(red_reason_code) = 'OTH'
</cfquery>
<cfquery name = "gen_red_reas_llc_qn"
datasource="#session.dbase#" username="#session.uname#" password="#session.pword#">
select
gen_red_text RedTextLLC
from gen_red_reasons
where upper(red_reason_code) = 'LLC'
</cfquery>
<html>
<head>
<title>Untitled</title>
<script language="JavaScript1.2" src="MBValidate.js" type="text/javascript"></script>
<SCRIPT LANGUAGE="JavaScript">
<!--
<cfoutput>
var ID = 0
function NewWindow1()
{
msgWindow=window.open("red_reason_popup.cfm?ID=1","displayWindow","toolbar=no,width=450,height=280,directories=no,status=no,scrollbars=no,resize=no,menubar=no")
}
</cfoutput>
// -->
</SCRIPT>
<link rel="stylesheet" href="../lib/d_style.css">
<cfquery name = "getLoc" DATASOURCE="#SESSION.DBASE#" username="#SESSION.uname#" PASSWORD="#SESSION.PWORD#">
Select l.location_name, l.loc_code
FROM locations l,
unit_infos u
WHERE l.loc_code = u.loc_Code and
u.primary_loc = 'T'
</cfquery>
<cfquery name="hgear_part_desig_qn"
datasource="#session.dbase#" username="#session.uname#" password="#session.pword#">
select
hgear_part_number,
hgear_desg
from hgears
order by hgear_part_number
</cfquery>
<cfquery name="hgear_part_desig2_qn"
datasource="#session.dbase#" username="#session.uname#" password="#session.pword#">
select
hgear_part_number part2,
hgear_desg desg2
from hgears
order by hgear_part_number
</cfquery>
<cfoutput>
<font color = "blue"><b>#getLoc.location_name#</b>
<b> - </b>
<!--- ---><b>Receipt Weapon </b></font>
</cfoutput>
<cfif #session.MBSuperUser# IS "T"><!--- If a superuser... --->
<font color = "silver"><b><i>Super-User Mode</i></b></font>
<cfelseif session.verify IS "yes">
<font color = "silver"><b><i>Verification Mode</i></b></font>
<cfelse>
<font color = "silver"><b><i>Initial Data Entry Mode</i></b></font>
</cfif>
<br>
Weapon Code: <cfoutput>#form.MAJ_ASM_NAME#</cfoutput>
Part Number: <cfoutput>#form.MAJ_ASM_PART_NBR#</cfoutput> 
<br><br>
</head>
<body>
<cfform name="receipt" action="receipt_action.cfm">
<cfoutput>
<input type="hidden" name="maj_asm_name" value="#form.maj_asm_name#">
<input type="hidden" name="maj_asm_part_nbr" value="#form.maj_asm_part_nbr#">
<input type="hidden" name="YELCOLORCODE" value="">
<input type="hidden" name="A900COLORTEXT" value="">
<input type="hidden" name="OTHCOLORTEXT" value="">
<input type="hidden" name="LLCCOLORTEXT" value="">
<input type="hidden" name="A900COLORCODE" value="">
<input type="hidden" name="LLCCOLORCODE" value="">
<input type="hidden" name="OTHCOLORCODE" value="">
</cfoutput>
<table>
<tr>
<th>Serial</th>
<th>ALT</th>
<th>H Gear</th>
<th>Op. Status</th>
</tr>
<!--- Putting together the numeric alts in a string for each alpha alt and putting them in a select list. --->
<cfquery name = "alt_codes_qn"
datasource="#session.dbase#" username="#session.uname#" password="#session.pword#">
select
alt_code
from alt_codes
where alt_code in (select distinct alt_code from alpha_numeric_alts)
order by 1
</cfquery>
<CFSET sNumericAltArray = ArrayNew(1)>
<CFSET sMyArray = ArrayNew(1)>
<CFSET sMyArrayAlpha = ArrayNew(1)>
<CFSET ArrayClear(sMyArray)>
<CFSET ArrayClear(sMyArrayAlpha)>
<CFLOOP query="alt_codes_qn">
<CFSET sNumAltTemp = alt_code >
<cfquery name = "alt_status_qn"
datasource = "site1"
maxrows = 500 dbtype="Oracle80"
username = "devalxdf0" password="dfredericks" >
select numeric_alt sNumAlt
from alpha_numeric_alts
where alt_code = <CFQUERYPARAM VALUE=#sNumAltTemp#
CFSQLType="CF_SQL_VARCHAR">
order by numeric_order
</cfquery>
<CFSET ArrayClear(sNumericAltArray)>
<!--- Create an array that holds the alpha alts to match up with the numerics --->
<CFSET tempAlpha = ArrayAppend(sMyArrayAlpha, #sNumAltTemp#) >
<CFLOOP query="alt_status_qn">
<CFSET temp = ArrayAppend(sNumericAltArray, #sNumAlt#) >
</CFLOOP>
<CFSET myList = ArrayToList(sNumericAltArray, ", ")>
<CFSET temp2 = ArrayAppend(sMyArray , myList)>
</CFLOOP>
<cfset loopcounter = "1">
<cfloop CONDITION="#loopcounter# LESS THAN OR EQUAL TO #form.weapon_count#">
<tr <cfif loopcounter mod 2 is 1 > bgcolor="lightblue" </cfif> >
<td>
<input type="text" name="maj_asm_serial_nbr" size="9" maxlength="9">
</td>
<td>
<select name="NumericAlts">
<option default=""></option>
<CFLOOP INDEX="loopcount" FROM="1" TO=#arraylen(sMyArray)#>
<!--- Set the value equall to the alpha alts and the list shows the numeric strings --->
<OPTION value=<CFOUTPUT>#sMyArrayAlpha[loopcount]#</CFOUTPUT>><CFOUTPUT>#sMyArray[loopcount]#</CFOUTPUT></option>
<!--- <OPTION value=<CFOUTPUT>'#sMyArray[loopcount]#'</CFOUTPUT>><CFOUTPUT>#sMyArray[loopcount]#</CFOUTPUT></option> --->
</CFLOOP>
</select>
</td>
<td>
<cfinclude template="/includes/hgear.cfm">
Just checking to see if anyone can help me. I saw a lot of people helping on popup windows so I hope some of you can help me now.
DAN
dfred
07-02-2001, 04:03 PM
Still checking to see if anyone can help me.
Vincent Puglia
07-02-2001, 04:20 PM
Hi Dan,
Sorry to have kept you waiting. Now I want to make sure I got everything straight.
You are trying to pass values back to a form ('receipt') in the opener? Exactly what occurs when you pass the fields?
Based on the code I see, it should work. So, the only thing I can think of offhand (I don't have my coldFusion book on hand) is that the cf tags are somehow inteferring with the way javascript is viewing the DOM (document object method).
In other words, it cannot see the "opener.document.receipt" because you declare it with a 'cfform" tag, and browsers are instructed to ignore things they don't recognize.
Which brings me to my suggestions:
1) create a global array variable to hold the fields in the opener:
var myFields = new Array();
2) pass the values to that array;
opener.myFields[0] = document.red_reason.maj_asm_name.value;
...
opener.myFields[x] = document.red_reason.YELCOLORCODE.value;
3) then either assign the array to your hidden fields or simply send the array.
Vinny
dfred
07-02-2001, 05:33 PM
Here is the situation...
I can get the popup window to work for each item on the page. for example, if I have 5 different rows with 5 different values, the radio buttons will work for each row. I can select the red radio button and it will open up the popup window and I can do what I need to do in the popup window. The window will even close. the issue involves passing those values. it seems that only one set of values will be submitted from the receipt page to an action page. It almost seems that when I select a second red radio button which brings up a popup window and pass that data to the receipt page, that new data overrides what was passed from the first red radio button and popup window.
All the data for serial numbers, or dates, or other fields pass to the action page in a comma delimited list, i need the values from the popup windows (if there are more than one used) to either pass in a comma delimited list, or pass individually with a 1,2,ect. added to the end of the code and text names.
I hope that makes sence.
if there are more that one popup windows used on the page, I need all the individual values to be passed to the receipt page so then those individual values can be passed on to the action page.
Thanks for the help...I know we are all busy and cannot always help right away or at all.
DAN
Vincent Puglia
07-02-2001, 06:53 PM
Hi Dan,
Now I'm really confused.
Are you trying to gather values from more than one popUp before sending the data? Did you try putting in alert()s to see what is being sent/kept/updated?
Vinny
dfred
07-02-2001, 07:41 PM
Yes there could be more than one popup on the same page.
the page loops through and displays multiple selections. for each selection, there will be a red/yellow radio button pair.
example: I select 5 objects to be displayed on the parent page. any one, all or none can have a problem which would require using the popup window and the data displayed in the popup window.
If I out of those 5 objects, 2 are red which means I need the popup window to display data, then the data from both popup windows needs to be passed. it seems that I am only getting one popup windows data being passed.
checkout the screen shop I made if what the parent page looks like.
Sorry for confussing you but with what I am tring to do I get confussed often.
DAN
Vincent Puglia
07-02-2001, 09:14 PM
Hi Dan,
I think it's getting a little clearer :)
This will alway overwrite the value in the opener:
opener....value = document...value;
because you are assigning the value on the right to the value on the left. What follows, however, will always append to the fieldValue on the left:
opener....value += document...value;
Now, the pitfalls are 2:
1) you must declare each and every left value to a blank:
document.receipt.fieldname.value = "";
This way you know what you start with.
2) You will need to delimit each popUp's values from the others
the 'delimiter' can be any unique character you want -- I generally use "|" (vertical bars) or "," (commas), dependent upon the situatation.
Hope this helps
Vinny
dfred
07-02-2001, 09:34 PM
I decided to post my popup window code. If you look at the js code, I did what I thought you said in your last post. I may not have added the code right because now my popup window will not submit and close. I am not sure if I declared the value correctly.
I am glad you understand what I am trying to accomplish.
DAN
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<cfquery name = "gen_red_reas_900_qn"
datasource="#session.dbase#" username="#session.uname#" password="#session.pword#">
select
gen_red_text RedText900
from gen_red_reasons
where red_reason_code = '900'
</cfquery>
<cfquery name = "gen_red_reas_oth_qn"
datasource="#session.dbase#" username="#session.uname#" password="#session.pword#">
select
gen_red_text RedTextOTH
from gen_red_reasons
where upper(red_reason_code) = 'OTH'
</cfquery>
<cfquery name = "gen_red_reas_llc_qn"
datasource="#session.dbase#" username="#session.uname#" password="#session.pword#">
select
gen_red_text RedTextLLC
from gen_red_reasons
where upper(red_reason_code) = 'LLC'
</cfquery>
<html>
<head>
<title>Untitled</title>
<script language="JavaScript1.2" src="MBValidate.js" type="text/javascript"></script>
You cannot do this within the passFields function:
document.receipt.YELCOLORCODE.value="";
in fact, it should be giving you an error because you shouldn't have a form named 'receipt' within the same document as the function.
When I posted that, what I meant was to make sure the fields within the receipt form were of a known value.
For simplicities sake, just kill those lines and run it. Also, within your parent/opener page insert the following code at the end of the page, just before the </body> tag.
run it with only one popup and then with more than one.
Vinny
dfred
07-02-2001, 09:50 PM
Just some more info to help you figure out what I am doing. When I deleted the declared values, I was able to close the window and submit the form. Here is what my debug shows as the submitted items. I am thinking there may have to be a loop stating if one is checked add if not then don't add. I am thinking that the actual info on the page may be effecting the outcome since each checkbox has a default value which may be causing problems. Let me know what you think.
just wanted to get this to the top of the forum to see what other ideas people may have for me. I am very close to figuring this out.
dfred
07-05-2001, 04:31 PM
thought I would get this back into circulation. I have another solution to my data passing problem which entails using a table to store the values till the parent page is submitted. Maybe someone can see this and give me some help.