Solved

firefox form in frame

Posted on 2006-06-28
13
1,101 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Mouse event to control image and transparency. 4 34
JS does not refresh 6 30
Hide Table in merge 3 31
html border input line 7 13
In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
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…

856 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