Meaningless Drivel is fun!*
The moose likes HTML, CSS and JavaScript and the fly likes Accessing iframe elements in javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Accessing iframe elements in javascript" Watch "Accessing iframe elements in javascript" New topic

Accessing iframe elements in javascript

Manohar Saddala

Joined: Jul 11, 2007
Posts: 12
Hi All,

I have an html page which consists of iframe. In the iframe i had defined a form with two input elements and one button element.when i click the button in will be calling a javascript.

what my problem is in the javascript i am unable to get the input elements values defined in the form and i am unable to perform the form related functions like form.action(), form.submit().. etc..

Please help me regarding the issue..


Eric Pascarello

Joined: Nov 08, 2001
Posts: 15376
Talk to the iframe from the parent:
document.getElementById("iframeId").formName.elementName.value = "foo";

Talk to the parent from the iframe
parent.formName.elementName.value = "bar";

Manohar Saddala

Joined: Jul 11, 2007
Posts: 12

i had tried the way you had said but iam getting the error like is null or not an object.

my page was designed like below:

in the body tag
i have an button which calls a javascript funtion
i have a iframe which has a form as a member to the iframe.I the form i had an text box.

what i want to do is when i click on the button in the javascript i need to validate the value in the textbox and then i want to submit the form to server side.

Consider Paul's rocket mass heater.
subject: Accessing iframe elements in javascript
Similar Threads
Accessing indexed properties in Javascript
Form submission and iFrame
how to pass field value in an IFrame to its parent
how to hide and show iframe withen form ?
Login Encryption