473,386 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

input values not recognized in dinamicly loaded IFRAMEs

problem: input values not recognized in dinamicly loaded IFRAMEs

here is the thing I have a parent window that has an IFRAME
I then load a diffrent page into the IFRAME that contains an input

when I try to access - iFrm.document.all["grid_name"].value

i get an error saying that - "value is null or not an object"

I tryed checking to make sure the page is fully loaded using:
document.readyState=="complete"
and it is loaded and completed

the weirdest thing is that when debugging the error I can see the value
in the debbuger
and after that I get the value alerted just fine
so how come I get an error ?????

parent.html:

<script>
function loadIframe()
{
var iDiv = document.getElementById("pannel1");
alert("iDiv.id = " + iDiv.id);
var iFrm = document.getElementById("ifrm");
//ByTagName("IFRAME")[0];
alert("iFrm.id = " + iFrm.id);
iFrm.src="child.html"; //ALSO WORKS:
location.href="child.html";
}

function showGridName()
{
var iFrm = document.getElementById("ifrm");
alert("iFrm.src = " + iFrm.src);
var gridName = iFrm.document.all["grid_name"].value;
alert("gridName");
}
</script>
</head>
<body>
<input type="button" value="load frame" onclick="loadIframe();">&nbsp;
<input type="button" value="grid name" onclick="showGridName();">
<div id="pannel1" name="pannel1">
<IFRAME id="ifrm" name="ifrm" src="blank.html" grid_name="grid2">
</IFRAME>
</div>
</body>
<html>

child.html - in IFRAME

<html><body>
<form name="frm" action="blank.html">
<input type="hidden" id="grid_name" name="grid_name">
<input type="submit" value="send">
</form>
</body><html>

blank.html in IFRAME:

<html><body>blank page</body><html>

Jun 28 '06 #1
7 2215
shocron wrote:
problem: input values not recognized in dinamicly loaded
IFRAMEs

here is the thing I have a parent window that has an
IFRAME I then load a diffrent page into the IFRAME that
contains an input

when I try to access - iFrm.document.all["grid_name"].value

i get an error saying that - "value is null or not an
object"

<snip>

The - document - property of IFRAME elements (if implemented at all as
it is non-standard) may or may not refer to the document contained
within the IFRAME. Often they refer to the document in which the element
is contained (which has no input element).

Generally, the most cross-browser and reliable approach to accessing the
contents of sub-frames is to use the - frames - collection of the
window/global object that contains the frame, give the IFRAME/FRAME a
name attribute and index the - frames - collection with that name. The
result of such a reference is the global/window object for the contained
frame, which will have (assuming the frame has loaded) a - document -
property that refers to the document within the frame.

Richard.
Jun 28 '06 #2
I have also tried -

document.frames['myFrameName'].document.all["myInput"].value

but I get the same error value is not recognized although
I can see the value in debug mode

when I try to access - iFrm.document.all["grid_name"].value

i get an error saying that - "value is null or not an
object"

<snip>

The - document - property of IFRAME elements (if implemented at all as
it is non-standard) may or may not refer to the document contained
within the IFRAME. Often they refer to the document in which the element
is contained (which has no input element).

Generally, the most cross-browser and reliable approach to accessing the
contents of sub-frames is to use the - frames - collection of the
window/global object that contains the frame, give the IFRAME/FRAME a
name attribute and index the - frames - collection with that name. The
result of such a reference is the global/window object for the contained
frame, which will have (assuming the frame has loaded) a - document -
property that refers to the document within the frame.

Richard.


Jun 29 '06 #3
shocron wrote:
I have also tried -

document.frames['myFrameName'].document.all["myInput"].value

but I get the same error value is not recognized although
I can see the value in debug mode
Hi,

I think you want:
parent.frames['myFrameName'].document...

Futhermore: document.all[..] is bad. It is not standard and will fail on
non-IE browsers.
Use the following way to address an element in a form:
document.forms["formname"]["elementname"].value

or in your case:

parent.frames['myFrameName'].document.forms["formname"]["elementname"].value

Or use getElementById("myElement") to get a reference to myElement.

One other thing to watch: Are you maybe using different domains for the
maindocument and the document in the IFRAME? JS is not able to script
across different domains (luckily).

Regards,
Erwin Moller


> when I try to access - iFrm.document.all["grid_name"].value
>
> i get an error saying that - "value is null or not an
> object"

<snip>

The - document - property of IFRAME elements (if implemented at all as
it is non-standard) may or may not refer to the document contained
within the IFRAME. Often they refer to the document in which the element
is contained (which has no input element).

Generally, the most cross-browser and reliable approach to accessing the
contents of sub-frames is to use the - frames - collection of the
window/global object that contains the frame, give the IFRAME/FRAME a
name attribute and index the - frames - collection with that name. The
result of such a reference is the global/window object for the contained
frame, which will have (assuming the frame has loaded) a - document -
property that refers to the document within the frame.

Richard.


Jun 29 '06 #4
I tried -
document.frames[0].document.forms[0]["elementname"].value

and it worked.

this is the first time I have used the syntax
document.forms["form_name"]["element_name].value

and it is the only syntax that worked
all others .all["id"].value .getElementByID()
document.formName.elementName.value
have all failed miserably

which makes you think - how come there is no reference, nowhere for
the correct, cross browser, fail safe syntax to use

thanks

Jun 29 '06 #5
shocron wrote:
I tried -
document.frames[0].document.forms[0]["elementname"].value

and it worked.

this is the first time I have used the syntax
document.forms["form_name"]["element_name].value

and it is the only syntax that worked
all others .all["id"].value .getElementByID()
document.formName.elementName.value
have all failed miserably

which makes you think - how come there is no reference, nowhere for
the correct, cross browser, fail safe syntax to use
What makes you think there is no reference to this?
The use of .all[] is IE only, it is described in any good book/site, and
should be avoided unless you are a M$-only guy.

You DO test your pages on Firefox before publishing them on the net, don't
you?

I would like to misuse this oppertunity to advise a great book to you:
'Dynamic HTML, the definitive reference' from O'Reilly.

No, I do not work for them. :-)

Regards,
Erwin Moller

thanks


Jun 30 '06 #6
still doesn't work
let me explain my situation
I have number of tabs in a web page named pannel1...pannelxx
in some of the tabs I have an IFRAME containing my pages
I want to load my IFRAME dynamicly when I click the tab

so I do:

var pannelDiv = window.document.getElementById('panelpanel'+i);
var theFrame = pannelDiv.getElementsByTagName("IFRAME")[0];

and then I load the frame using: theFrame.src = "myPage.html";

now here comes the tricky part
when I try from to access an input inside my frame

using:
var frameName=theFrame.id;

alert(document.frames[frameName].document.forms[0]["grid_name"].value);

or any of the syntaxes I have mentioned before It fails
needless to say it works fine when the Iframe is preloaded
and not loaded dynamicly

then I just use

var grid_name = eval(frameName+".getGridName()");

one syntax did work however using
frame index like frames[3].document,,,
the problem is that not all tabs have an Iframe so I dont know the
ordinal no
for the frame in advance just it's name

any ideas ???

Jul 3 '06 #7

shocron написав:
needless to say it works fine when the Iframe is preloaded
and not loaded dynamicly
>needless to say it works fine when the Iframe is preloaded
and not loaded dynamicly
Set timeout between loading document into iframe and accessing its
elements:

function f1()
{
....
theFrame.src="some.htm";
setTimeout("getIFrameData('"+theFrame.id+"')", 50);
...
}

function getIFrameData(frameId)
{
var doc;
if (document.all) //IE
doc = frames[frameId].document;
else //Gecko based browsers
doc = document.getElementById(frameId).contentDocument;

//here you can access iframe document data
......
}

Jul 3 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Dan Popa | last post by:
Check out the following 2 links: http://www.batisdev.com/admin/test_1images.asp http://www.batisdev.com/admin/test_2images.asp First page contain 4 IFRAMES and 1 IMG tags. Second page contain 4...
5
by: Pete Wason | last post by:
Hiall! I have a demo viewer page for javascript stuff that has three buttons "DEMO" "HTML" and "JSCR", and an IFRAME called 'viewer'. Initially, the IFRAME gets loaded with the actual demo...
2
by: MrMike | last post by:
Hello. I'm building a webform that allows users to add records to a database. The code that adds the new record to the database is below. Basically a user popualtes 3 textboxes on the webform and...
4
by: Mark | last post by:
I am loading source files into several iframes, with each load happening after some user-generated event (like clicking a button). The loading works but I need to determine when the source file is...
5
by: ramonred | last post by:
Hi All, this is the error: Input string was not in a correct format. this is the code I am trying to debug: <code> string sql = @" INSERT INTO (UserID, Login, Password, FirstName, LastName,...
4
by: krzysiek | last post by:
hello, i have several radiolists and checkboxlist that are generated dinamicly based on datasource. So frankly speaking i don't know names and number of that web controls cose they are always...
7
by: Drew Berkemeyer | last post by:
I've encounted a pretty strange problem and I'm not quite sure what to make of it. I have a web service that consumes an XML file as well as a few other parameters. This web service works fine...
4
by: Fabio Cavassini | last post by:
I want to implement a good Persistent State checking feature, this feature should show the user the Save button only when there are changes to save, if there are no changes, the button will be...
2
by: rohitchawla | last post by:
have a problem with this code when working in IE it gives me 0,0 coords when i use iframe tag but gives correct coords when using firefox function GetRealOffset(id) { var elem =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.