Closed Thread Icon

Topic awaiting preservation: submitting a nameless form that's in an iframe (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=8296" title="Pages that link to Topic awaiting preservation: submitting a nameless form that&amp;#039;s in an iframe (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: submitting a nameless form that&#039;s in an iframe <span class="small">(Page 1 of 1)</span>\

 
Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 09-03-2002 20:43

Curiosity, really, is what's behind this...

Let's say I have a page, with an iframe.
In that iframe, is another page, which has a form.
This form does NOT have a "name" or "id".

I'd like to find a way to submit that form.

I tried
document.getElementById('myiframe').form[0].submit();
but I get a "null or not an object" error.

Ideas?

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 09-03-2002 20:49

Perhaps

document.getElementById('myiframe').document.form[0].submit();

? Just a guess. But I assume that if document.getElementById('myiframe') gives you a reference to part of the page contained in the IFRAME, then it's the window object in that iframe, not directly the document object. But I wouldn't be surprised if this doesn't work either.

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 09-03-2002 21:49

Yeah, that has the same issue....

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 09-03-2002 22:54

So the real question here is probably how to get to the Window object of a page in an IFRAME.

andy_j
Nervous Wreck (II) Inmate

From: uk
Insane since: Aug 2002

posted posted 09-04-2002 00:04

You can reference this by using the frames array but only after the page has loaded.

Then if you need to reference your unnamed form, if there is only one on the page, its easy

document.frames[0].document.forms[0].submit();

sort of like this



[This message has been edited by andy_j (edited 09-04-2002).]

genis
Paranoid (IV) Inmate

From: Dallas, TX
Insane since: Aug 2002

posted posted 09-04-2002 01:01

I'm just guessing you're trying to submit that form with a button outside the iframe?

how bout a little code snippet to let us see how its setup?

andy_j
Nervous Wreck (II) Inmate

From: uk
Insane since: Aug 2002

posted posted 09-04-2002 01:26

I used this code in the main page containing the iframe

<script language="javascript">
function submitIt() {
document.frames[0].document.forms[0].submit();
}
</script>

so the document.frames[0] - references the only frame on the page (the iframe). The 0 is the first and only element in the frames array.

the document.forms[0] will reference the forms array in your iframe source. Again there is only one form so its array position will be 0;

Then just put it all together and call submit()

document.frames[0].document.forms[0].submit()

The example i linked to just shows that you get the same result either using the submit button in the iframe or using the submit link at the top



[This message has been edited by andy_j (edited 09-04-2002).]

lallous
Paranoid (IV) Inmate

From: Lebanon
Insane since: May 2001

posted posted 09-04-2002 09:13

Pugzly, Slime's method would work but should replace 'form' with 'forms'

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 09-04-2002 14:51

Slime's method gives me the same "null or not an object" error. Even with "forms"

« BackwardsOnwards »

Show Forum Drop Down Menu