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
Author

Accessing iframe elements in javascript

Manohar Saddala
Greenhorn

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


Regards,
manohar


manu
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
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";

Eric
Manohar Saddala
Greenhorn

Joined: Jul 11, 2007
Posts: 12
hi,

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.


Regards,
manohar
 
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