Solved

firefox form in frame

Posted on 2006-06-28
13
1,098 Views
Last Modified: 2012-08-14
Hi,

I have to send data from one frame to another frame form, no problem in
IE, in Firefox tring to use: document.getElementById("frame ID").contentWindow.document.name_of_form.name_of_field...
get error "document.getElementById("frame ID")" has no property, where is the error?

Thank you,

Grig.
0
Comment
Question by:grig
  • 6
  • 6
13 Comments
 
LVL 15

Expert Comment

by:justinbillig
ID: 17002977
Well this could be one of two things

either ... the id property doesn't accept id's with spaces .. so you have to have frame_ID as the id


or ....

if id property does accept spaces you don't have quotes around the id ... id=frame id  would cause problems ...

try either

id="frame_ID"

or

id="frame ID"
0
 

Author Comment

by:grig
ID: 17003168
it was just example, sorry, this is real program line:

tt=document.getElementById("hide").contentWindow.document.form_bot.weeks.value
0
 
LVL 19

Expert Comment

by:nschafer
ID: 17004171
Hi grig,

I generally use this format

  tt = window.frames[0].document.form_bot.weeks.value;
 
Perhaps that will work better for you.

Neal.
0
 

Author Comment

by:grig
ID: 17004378
Thank you Neal,
what is frames[0]. here?
0
 
LVL 19

Expert Comment

by:nschafer
ID: 17004397
window.frames is a collection of all the frames on the page.  frames[0] specifies the first frame.  When working with iframes, the first iframe defined on a page will be 0 the second will be 1 and so on.

When working with framesets I'm fairly certain it would be a bit different, but if you just have a normal web page with an iframe in it the above is how it works.

Neal.
0
 

Author Comment

by:grig
ID: 17004626
do I have to switch to the page with Iframe then?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 19

Expert Comment

by:nschafer
ID: 17004649
I don't understand your question.

The code I posted would run in the parent page, not in the iframe page.

Neal.
0
 

Author Comment

by:grig
ID: 17004947
I dont have iframe, I use frameset...
0
 
LVL 19

Expert Comment

by:nschafer
ID: 17006265
OK,  for some reason I thought you were using an iframe.  

here's how you can reference this from a frameset.

Lets assume I have the following frameset:

<FRAMESET ROWS="70%,30%" COLS="50%,50%">
  <FRAME NAME="frame1" SRC="test2.htm">
  <FRAME NAME="frame2" SRC="test3.htm">
</FRAMESET>

and I want to move data from Frame 1 to Frame 2

In Frame 2 I can reference Frame 1 like this:

  tt = parent.frames('frame1').document.form_bot.weeks.value;

Hope this helps,

Neal.

0
 

Author Comment

by:grig
ID: 17010922
Ye, it works fine, but only for IE, my question from begining - what I have to use for Mozilla browsers?
0
 
LVL 19

Expert Comment

by:nschafer
ID: 17011030
Sorry a small change is required and then it works in IE, FF, Opera, and Netscape.

  tt = parent.frames['frame1'].document.form_bot.weeks.value;

Neal.
0
 

Author Comment

by:grig
ID: 17011153

Works in IE, in FF have:
Error: parent.frames.bottomFrame.document.form_bot has no properties
0
 
LVL 19

Accepted Solution

by:
nschafer earned 125 total points
ID: 17011439
OK, lets run a couple of tests.

comment out the above line and add in the following:

alert(parent.frames['bottomFrame'].document);
  When run in FF it should alert you with [object HTMLDocument]

if that works we'll go to the next setp

alert(parent.frames['bottomFrame'].document.form_bot);
  When run in FF it should alert you with [object HTMLFormElement]

I beleive that you will probably get undefined instead of [objectHTMLFormElement].  If so then we want to look at the form declaration, so post back your form tag.  <form name="form_bot" ...>

If you do get the appropriate result from the above alert then try the next step

alert(parent.frames['bottomFrame'].document.form_bot.weeks);
  When run in FF it should alert you with [object HTMLInputElement]

If all of these give you the appropriate results then it should be working.  Based on the error message you posted I believe the error resides in the Form Element, but this should verify that.

Neal.

 
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
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…

895 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

18 Experts available now in Live!

Get 1:1 Help Now