File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes access child elements in parent form Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "access child elements in parent form" Watch "access child elements in parent form" New topic
Author

access child elements in parent form

Rekha Pande
Ranch Hand

Joined: Jan 29, 2004
Posts: 145
Hi all,

I have this parent form, in which i have a text box to enter the number of rows that are required in the child form, it goes like this

parent form : purchase form
Child Form : Item Form

IN PARENT FORM:
Enter the number of items purchased : 3 (User enters three) // Purchase Form

In the parent form, i have a frame in which the child form is displayed with three rows and each row has 3 text boxes. // Items Form

Now when i click the submit button in the parent form i.e. the purchase form, i want to check whether the textboxes that are their in the child form (item form)are empty or not.

Please can some one guide me on this...!!

Thanks.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You can get to the values like this

You can run a function on the onsubmit of a form like this

For function:


Eric
Rekha Pande
Ranch Hand

Joined: Jan 29, 2004
Posts: 145
Hi Eric,

Thank you for your reply, I had tried your solution but with that i could access the parent elements from child but couldn't access the child elements from parent

So then i tried parent.framename.formname.elementname in the Parent form, and now it's working fine...!!!

Thank you so much...!!!
Rekha Pande
Ranch Hand

Joined: Jan 29, 2004
Posts: 145
And i really like this piece of code :
document.formName.elementName.style.backgroundColor="red";

I never knew this before... Thanks..!!!
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
parent.framename.document.formname.elementname

do not forget the document, certain browsers will not like the element reference without it.

Eric
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: access child elements in parent form