Solved

firefox form in frame

Posted on 2006-06-28
13
1,103 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…

733 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