Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Accessing iframe elements in javascript

 
Manohar Saddala
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic