#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2000
    Location
    singapore
    Posts
    2
    Rep Power
    0

    Exclamation


    Hi ! any one knows how to pass the value of a form from a main window to another child window's form value using javascript??

    the value need to be pass to the text field of the form value!

    The child window is open when a link in the main window is click and it pop_up the child window.
  2. #2
  3. o0o.o0o
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2001
    Location
    m00n
    Posts
    194
    Rep Power
    102

    Post


    Lets assume that you open a pop up from a main window that contains a form:
    Code:
    <form name="mainForm">
    <input name="formElementName" type="text" value="">
    ...
    </form>
    The form on the main window can be accessed by the pop up window by simply calling the value of the main form element you want to carry over in this manner:
    Code:
    opener.document.mainForm.formElementName.value
    follows the standard hierarchy:

    window.document.form.formElement.[property or method]

    This would go in the pop up window of course. It would need to be used on an "onLoad" event in the body tag, and it would look something like this:
    Code:
    <body onLoad="self.document.childForm.childFormElement.value = opener.document.mainForm.formElement.value;">
    
    <form name="childForm">
    <input name="childFormElement" type="text" value="">
    ...
    </form>
    Depending on the browser you are using, this method should work.

    You can find a lot of information about the Window Object at:
    http://developer.netscape.com/docs/m...sref/index.htm


    [Edited by estrabd on 02-13-2001 at 08:35 AM]

IMN logo majestic logo threadwatch logo seochat tools logo