Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grouped CFOutputs and Javascript 1

Status
Not open for further replies.

programmher

Programmer
May 25, 2000
235
US
I am also posting this on the javascript board in case someone there can help.

I have a cfquery result on a child form that has four cfoutputs. My problem is I have to update the parent form with variables from the child form.

I am performing my update with javascript. The update executes but does not send my selected variable. I have tried placing the javascript various places within the outputs, but do not get my desired result.

I have three questions

1 - Has anyone ever attempted this?

2 - Does my problem lie with my various cfoutputs or with my javascript?

3 - What is my solution?
 
Before I can tell you a solution, I need to better understand what you're saying.

You said, "... a child form that has four cfoutputs. My problem is I have to update the parent form with variables from the child form."

Are you saying that you have a Parent window, which opens a child window, and there are form inputs on the child, and that you need to pass the choices the user makes on that child window back to the parent window via javascript?

If this is what you're saying then you need a hidden variable on the parent form for every variable you have on the child.

You need a function on the child that will prep local variables for every input, and pass those local variables when the user clicks SUBMIT or whatever.

name = document.forms["form"].name.value;
city = document.forms["form"].city.value;
zip = document.forms["form"].zip.value;


To access functions on the parent use window.opener.functionName(name,city,zip) . This will pass 3 parameters to a function called functionName() on the parent.

Use a function on the parent that will receive variables, and then set all the form hidden parameters (hidName,hidCity,hidZip) = to those that were passed.

document.forms["parentForm"].hidCity.value = city;
..etc

After the variables are received and the hidden parameters are set, close the child window. Then when the user submits the parent form, all the hidden parameters come with it.

Hope this leads you to a more specific issue.

 
Stran,

I am able to successfully pass back variables. Just not the correct variables.

My parent form passes a real estate key value to the child form.

The child form then executes a query that returns all the data associated with that real estate key.

Because another developer used four groups in her cfoutput statements, I am unable to send my selected values back to the parent form. (Ex - If I select the values associated with record number 3, the values associated with record number 12 might get sent to the parent form.) The actual record number changes depending on where I embed my javascript.

Does this clarify my situation any?
 
hey programmher

OMG haha.. thats a problem I hadn't considered. That absolutely clarified your issue... but I can't suggest a javascript solution around that unless you have a set of seperate <script> tags for each... wait are you saying she has

<CFOUTPUT query=&quot;x&quot; group=&quot;a,b,c,d&quot;>

</CFOUTPUT>

? Can I see the output tag? hehe this is interesting.
 
No problem, Stran!


I wish the grouping was like your example. I probably wouldn't have this problem!


Here is the first grouping:

<cfoutput query =&quot;GetREstateInfo&quot; GROUP=&quot;Agent_salesoffice&quot; > city, state, zip

NEXT GROUPING:

<cfoutput GROUP=&quot;opoffice_desc&quot;>

agent operating office (some agents sale from different offices

NEXT GROUPING:

<cfoutput GROUP=&quot;realestate_key&quot;>

The actual and unique key assigned to the salesagent. My script is also embedded and referenced here. Other variables (like sales agent numbers, home city, state, zip, etc. follow.

Thanks for taking a look at this!!!

 
I don't see this being too difficult to fix but I'm not clear on what variable you're trying to pass back and where it has the correct value. Is the variable one you pass to the child form initially that you need back or do you need to pull it from the query that the child form executes? I assume the variable is part of the query GetREstateInfo but is it unique only to the innermost grouping or is it shared at the highest level grouping? I don't see this being a problem to fix with a <cfset> but I just need to understand which variable you need to catch.

GJ
 
GunJack,

I am attempting to pass back to/update the parent form with the result of the query that the child form executes. Some values might be shared at the highest grouping level (i.e. city or state). The actual agent key differtiates the other information.

How would I use <cfset> to signify the correct set of variables with my JS? Perhaps a better question is how are these four groupings affecting which variables are sent back to the parent page? If I select the first record, tha last record is sent. If I select the third record, the last record is sent. If I could understand that, I could probable be able to correctly code this portion of my script.
 
I'm still not clear on what you're trying to do so it's hard to offer help. You say that you're trying to pass back the results of a query but that could mean a lot. Are you attempting to pass back the entire result set (i.e. all records), are you attempting to pass back a single identifier (i.e. primary key) for a specific agent, or are you attempting to pass back something else like the recordcount, etc... If you can be specific about what your query does, exactly what you're trying to pass back, and how your attempting to pass back the results, I should be able to tell you how to fix it or explain how the groupings are affecting your results.

GJ
 
GJ,

I am attempting to pass back information associated with a specific agent. Below is the query:

select agent_city,
agent_state,
Estate.Office_key,
agent_salesoffice,
opoffice,
realestate_key,
agent_address,
agent_address2,
agent_sales,
edate,
x_date,
agent_notes


<cfoutput query =&quot;GetREstateInfo&quot; GROUP=&quot;Agent_salesoffice&quot; > city, state
NEXT GROUPING:

<cfoutput GROUP=&quot;opoffice_desc&quot;>

agent operating office (some agents sale from different offices

NEXT GROUPING:


<cfoutput GROUP=&quot;realestate_key&quot;>

<script language=&quot;javascript&quot;>

function SetEstateInfo()

{

opener.document.Estate.Office.value = '#opsoffice#';
opener.document.Estate.City.value = '#agent_city#';
opener.document.Estate.State.value = #agent_state#;
opener.document.Estate.Comments.value = '#agent_notes#';

window.close();

}

</script>

<A HREF=&quot;Javascript:SetEstateInfo();&quot;>

FROM Estate,Agents
agent_key =#AgentKey#

Thanks for taking the time to help me resolve this and make sense of it!!


 
When you pass in an #AgentKey#, will the query return exactly one record or multiple records? If multiple records, are these values different for each record (#opsoffice#,#agent_city#,#agent_state#,#agent_notes#)? If they are different for each record, how do you determine which set (i.e. which specific record) that you want to return?

GJ
 
GJ-

The query will return multiple records. The values are different for each record. The set I want to return is deteremined by an <a href=JS...> associated with the agent_key (which is unique). All the values will pass - just not the record set I select.

What is also odd is that when I refer to the record item using <a href &quot;cfform.cfm?agent_key = #agent_key#&quot;> I can see the correct line number is selected! Just not when I attempt to pass it JS. JS still grabs the last record. I might have to attempt to pass the variables from the child to the parent by referencing all the variable in the string...tedious, but it might work. *sigh*
 
I think I see the problem. When you loop through the multiple records, you're creating multiple JS functions with the same name. The problem as I see it is that when you click on one of the links, JS is arbitrarily picking one of the functions to execute but it may not be the one next to the link you clicked. Try this and I think it will give you what you want.

function SetEstateInfo#currentRow#()
.....
.....
.....
<A HREF=&quot;Javascript:SetEstateInfo#currentRow#();&quot;>

By putting the #currentRow# value at the end of the function, you are assured that all of your function names will be unique and the link will execute the correct one.

Let me know if this isn't it,
GJ
 
THAT DID IT!!!!!! Words can not express my gratitude!!!!

I do have one last question.

I tried this, only I used

function SetEstateInfo#count#()
.....
.....
.....
<A HREF=&quot;Javascript:SetEstateInfo#count#();&quot;>

It kept erring on the # sign. Any idea why?

Again - THANK YOU!!!!!!!!!!!!!!!!!
 
I assume you mean CF gave an error and not JS. If CF, then it would mean count is not a defined variable.

You could create a count variable and increment it each time through the loop but since you have a built in #currentRow# variable which is unique, I used that instead.

GJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top