Controlling parent window from iFrame

J

joshb

Hey guys,

I'm in the last steps of my project, just a small question here. What
I'm doing right now is using an iframe to populate my drop-down
listboxes and have them display dynamic information from the database.
What I'm trying to do is change the selectedIndex from the iFrame.
Here's a quick snippet of code:

<SCRIPT LANGUAGE="JavaScript">
function testFunc() {
var empID =
document.form1.ddlEmployee.options[document.form1.ddlEmployee.selectedIndex].value;
document.frames("iframequery").location.href=
"/queries.cfm?EmployeeID=" + empID;
return false;
}
</SCRIPT>

<SELECT NAME="ddlEmployee" onChange="return testFunc();">
<OPTION VALUE="">Employee</OPTION>
<CFOUTPUT QUERY="qryEmployee">
<OPTION VALUE="#EmployeeID#">#FirstName# #LastName#</OPTION>
</CFOUTPUT>
</SELECT>

Then, in queries.cfm...

<SCRIPT LANGUAGE="JavaScript">
function refreshWindow() {
parent.window.ddlLocation.setSelectedIndex = 2;
}
</SCRIPT>

....

<BODY ONLOAD="refreshWindow();">

Now, when I call refreshWindow(), I'm getting this error:

'parent.window.ddlLocation' is null or not an object

Anyway, if anyone knows how I can get this to work (setting the drop
down list from the iframe), I would really appreciate it.

Thanks!
Josh.
 
J

joshb

Never mind, I got it working.

I just created a function in the parent window called
changeLocation(loc) and called it from the iframe, passing through the
variable from queries.cfm.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top